Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,14 +31,19 @@ def dl(inp):
|
|
31 |
#out = f'{e}'
|
32 |
return out
|
33 |
|
34 |
-
def process_vid(file):
|
35 |
new_video_in = str(file)
|
36 |
capture = cv2.VideoCapture(new_video_in)
|
37 |
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
38 |
rev_img_searcher = ReverseImageSearcher()
|
39 |
html_out=""
|
|
|
|
|
|
|
|
|
40 |
try:
|
41 |
-
for i in range(frame_count-1):
|
|
|
42 |
print(i)
|
43 |
capture.set(cv2.CAP_PROP_POS_FRAMES, i)
|
44 |
ret, frame_f = capture.read(i)
|
@@ -66,12 +71,13 @@ def process_vid(file):
|
|
66 |
Img: <a href='{search_item.image_url}' target='_blank' rel='noopener noreferrer'>{search_item.image_url}</a><br>
|
67 |
<img class='my_im' src='{search_item.image_url}'><br>
|
68 |
</div>"""
|
69 |
-
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
70 |
else:
|
|
|
71 |
pass
|
72 |
except Exception as e:
|
73 |
return (gr.HTML(f'{e}'))
|
74 |
-
return (gr.HTML('No frame matches found.'))
|
75 |
|
76 |
def process_im(file):
|
77 |
read_file = Image.open(file)
|
@@ -104,6 +110,7 @@ def rev_im(image_url):
|
|
104 |
Img: <a href='{search_item.image_url}' target='_blank' rel='noopener noreferrer'>{search_item.image_url}</a><br>
|
105 |
<img class='my_im' src='{search_item.image_url}'><br>
|
106 |
</div>"""
|
|
|
107 |
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
108 |
|
109 |
def shuf(tog):
|
@@ -132,15 +139,22 @@ with gr.Blocks() as app:
|
|
132 |
vid_url=gr.Textbox(label="Video URL")
|
133 |
vid_url_btn=gr.Button("Load URL")
|
134 |
inp_vid=gr.Video(label="Search Video")
|
135 |
-
|
|
|
|
|
|
|
|
|
136 |
gr.Column()
|
137 |
#paste_clip = gr.Button("Paste from Clipboard")
|
138 |
with gr.Row():
|
139 |
html_out = gr.HTML("""""")
|
|
|
|
|
|
|
140 |
vid_url_btn.click(dl,vid_url,inp_vid)
|
141 |
source_tog.change(shuf,[source_tog],[url_box,im_box,vid_box])
|
142 |
inp_im.change(process_im,inp_im,[inp_url])
|
143 |
-
go_btn_vid.click(process_vid,inp_vid,[html_out])
|
144 |
go_btn_im.click(rev_im,inp_url,[html_out])
|
145 |
go_btn_url.click(rev_im,inp_url,[html_out])
|
146 |
app.launch()
|
|
|
31 |
#out = f'{e}'
|
32 |
return out
|
33 |
|
34 |
+
def process_vid(file,cur_frame):
|
35 |
new_video_in = str(file)
|
36 |
capture = cv2.VideoCapture(new_video_in)
|
37 |
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
38 |
rev_img_searcher = ReverseImageSearcher()
|
39 |
html_out=""
|
40 |
+
if cur_frame == ""
|
41 |
+
start_frame = 0
|
42 |
+
elif cur_frame != "":
|
43 |
+
start_frame = int(cur_frame)
|
44 |
try:
|
45 |
+
for i in range(start_frame, frame_count-1):
|
46 |
+
|
47 |
print(i)
|
48 |
capture.set(cv2.CAP_PROP_POS_FRAMES, i)
|
49 |
ret, frame_f = capture.read(i)
|
|
|
71 |
Img: <a href='{search_item.image_url}' target='_blank' rel='noopener noreferrer'>{search_item.image_url}</a><br>
|
72 |
<img class='my_im' src='{search_item.image_url}'><br>
|
73 |
</div>"""
|
74 |
+
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'), "Complete", i)
|
75 |
else:
|
76 |
+
yield (None,f"Searching Frame: {i}", "")
|
77 |
pass
|
78 |
except Exception as e:
|
79 |
return (gr.HTML(f'{e}'))
|
80 |
+
return (gr.HTML('No frame matches found.'),"","")
|
81 |
|
82 |
def process_im(file):
|
83 |
read_file = Image.open(file)
|
|
|
110 |
Img: <a href='{search_item.image_url}' target='_blank' rel='noopener noreferrer'>{search_item.image_url}</a><br>
|
111 |
<img class='my_im' src='{search_item.image_url}'><br>
|
112 |
</div>"""
|
113 |
+
|
114 |
return (gr.HTML(f'<h1>Total Found: {count}</h1><br>{html_out}'))
|
115 |
|
116 |
def shuf(tog):
|
|
|
139 |
vid_url=gr.Textbox(label="Video URL")
|
140 |
vid_url_btn=gr.Button("Load URL")
|
141 |
inp_vid=gr.Video(label="Search Video")
|
142 |
+
stat_box=gr.Textbox("Status")
|
143 |
+
with gr.Row():
|
144 |
+
go_btn_vid=gr.Button()
|
145 |
+
next_btn=gr.Button()
|
146 |
+
|
147 |
gr.Column()
|
148 |
#paste_clip = gr.Button("Paste from Clipboard")
|
149 |
with gr.Row():
|
150 |
html_out = gr.HTML("""""")
|
151 |
+
with gr.Row(visible=True):
|
152 |
+
hid_box=gr.Textbox()
|
153 |
+
next_btn.click(process_vid,[inp_vid,hid_box],[html_out,hid_box])
|
154 |
vid_url_btn.click(dl,vid_url,inp_vid)
|
155 |
source_tog.change(shuf,[source_tog],[url_box,im_box,vid_box])
|
156 |
inp_im.change(process_im,inp_im,[inp_url])
|
157 |
+
go_btn_vid.click(process_vid,inp_vid,[html_out,stat_box,hid_box])
|
158 |
go_btn_im.click(rev_im,inp_url,[html_out])
|
159 |
go_btn_url.click(rev_im,inp_url,[html_out])
|
160 |
app.launch()
|