Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,18 +21,22 @@ def process_vid(file):
|
|
21 |
new_video_in = str(file)
|
22 |
capture = cv2.VideoCapture(new_video_in)
|
23 |
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
|
24 |
rev_img_searcher = ReverseImageSearcher()
|
25 |
try:
|
26 |
for i in frame_count-1:
|
|
|
27 |
capture.set(cv2.CAP_PROP_POS_FRAMES, i)
|
28 |
ret, frame_f = capture.read(i)
|
29 |
frame_f.write(f"{uid}-vid_tmp.png")
|
30 |
out = os.path.abspath(f"{uid}-vid_tmp.png")
|
31 |
-
|
32 |
res = rev_img_searcher.search(out)
|
|
|
33 |
if len(res) > 0:
|
34 |
count = 0
|
35 |
for search_item in res:
|
|
|
36 |
count+=1
|
37 |
out_dict={
|
38 |
'Title': f'{search_item.page_title}',
|
@@ -109,7 +113,7 @@ with gr.Blocks() as app:
|
|
109 |
with gr.Box(visible=False) as im_box:
|
110 |
inp_im=gr.Image(label="Search Image",type='filepath')
|
111 |
go_btn_im=gr.Button()
|
112 |
-
|
113 |
inp_vid=gr.Video(label="Search Video",type='filepath')
|
114 |
go_btn_vid=gr.Button()
|
115 |
gr.Column()
|
|
|
21 |
new_video_in = str(file)
|
22 |
capture = cv2.VideoCapture(new_video_in)
|
23 |
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
24 |
+
capture.release()
|
25 |
rev_img_searcher = ReverseImageSearcher()
|
26 |
try:
|
27 |
for i in frame_count-1:
|
28 |
+
print(i)
|
29 |
capture.set(cv2.CAP_PROP_POS_FRAMES, i)
|
30 |
ret, frame_f = capture.read(i)
|
31 |
frame_f.write(f"{uid}-vid_tmp.png")
|
32 |
out = os.path.abspath(f"{uid}-vid_tmp.png")
|
33 |
+
print(out)
|
34 |
res = rev_img_searcher.search(out)
|
35 |
+
print (res)
|
36 |
if len(res) > 0:
|
37 |
count = 0
|
38 |
for search_item in res:
|
39 |
+
print (f'counting {count}')
|
40 |
count+=1
|
41 |
out_dict={
|
42 |
'Title': f'{search_item.page_title}',
|
|
|
113 |
with gr.Box(visible=False) as im_box:
|
114 |
inp_im=gr.Image(label="Search Image",type='filepath')
|
115 |
go_btn_im=gr.Button()
|
116 |
+
with gr.Box(visible=False) as vid_box:
|
117 |
inp_vid=gr.Video(label="Search Video",type='filepath')
|
118 |
go_btn_vid=gr.Button()
|
119 |
gr.Column()
|