Nymbo commited on
Commit
8e871e6
·
verified ·
1 Parent(s): 04d0121

replacing boxes with columns for 4.44.1

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -62,14 +62,8 @@ def process_vid(file, cur_frame, every_n):
62
  capture.set(cv2.CAP_PROP_POS_FRAMES, i)
63
  ret, frame_f = capture.read()
64
 
65
- # Validate frame read
66
- if not ret or frame_f is None:
67
- print(f"Failed to read frame at index {i}.")
68
- continue
69
-
70
- # Check if frame is empty
71
- if frame_f.size == 0:
72
- print(f"Frame at index {i} is empty.")
73
  continue
74
 
75
  frame_path = f"{uid}-vid_tmp{i}.png"
@@ -78,7 +72,6 @@ def process_vid(file, cur_frame, every_n):
78
  out_url = f'https://nymbo-reverse-image.hf.space/file={out}'
79
  print(f"Frame saved: {out}")
80
 
81
- # Perform reverse image search
82
  res = rev_img_searcher.search(out_url)
83
  if res:
84
  out_cnt = 0
@@ -146,12 +139,13 @@ def rev_im(image):
146
  # Gradio app interface
147
  with gr.Blocks() as app:
148
  source_tog = gr.Radio(choices=["Image", "Video"], value="Image")
149
- im_box = gr.Box(visible=True)
150
  inp_url = gr.Textbox(label="Image URL")
151
  load_im_btn = gr.Button("Load Image")
152
  inp_im = gr.Image(label="Search Image", type='filepath')
153
  go_btn_im = gr.Button()
154
- vid_box = gr.Box(visible=False)
 
155
  vid_url = gr.Textbox(label="Video URL")
156
  vid_url_btn = gr.Button("Load URL")
157
  inp_vid = gr.Video(label="Search Video")
@@ -166,7 +160,7 @@ with gr.Blocks() as app:
166
 
167
  im_load = load_im_btn.click(lambda url: url, inp_url, inp_im)
168
  vid_load = vid_url_btn.click(dl, vid_url, [inp_vid, html_out, stat_box])
169
- vid_proc = go_btn_vid.click(process_vid, [inp_vid, "", every_n], [html_out, stat_box])
170
  im_proc = go_btn_im.click(rev_im, inp_im, [html_out])
171
  source_tog.change(shuf, [source_tog], [im_box, vid_box])
172
 
 
62
  capture.set(cv2.CAP_PROP_POS_FRAMES, i)
63
  ret, frame_f = capture.read()
64
 
65
+ if not ret or frame_f is None or frame_f.size == 0:
66
+ print(f"Failed to read or empty frame at index {i}.")
 
 
 
 
 
 
67
  continue
68
 
69
  frame_path = f"{uid}-vid_tmp{i}.png"
 
72
  out_url = f'https://nymbo-reverse-image.hf.space/file={out}'
73
  print(f"Frame saved: {out}")
74
 
 
75
  res = rev_img_searcher.search(out_url)
76
  if res:
77
  out_cnt = 0
 
139
  # Gradio app interface
140
  with gr.Blocks() as app:
141
  source_tog = gr.Radio(choices=["Image", "Video"], value="Image")
142
+ im_box = gr.Column(visible=True)
143
  inp_url = gr.Textbox(label="Image URL")
144
  load_im_btn = gr.Button("Load Image")
145
  inp_im = gr.Image(label="Search Image", type='filepath')
146
  go_btn_im = gr.Button()
147
+
148
+ vid_box = gr.Column(visible=False)
149
  vid_url = gr.Textbox(label="Video URL")
150
  vid_url_btn = gr.Button("Load URL")
151
  inp_vid = gr.Video(label="Search Video")
 
160
 
161
  im_load = load_im_btn.click(lambda url: url, inp_url, inp_im)
162
  vid_load = vid_url_btn.click(dl, vid_url, [inp_vid, html_out, stat_box])
163
+ vid_proc = go_btn_vid.click(process_vid, [inp_vid, None, every_n], [html_out, stat_box])
164
  im_proc = go_btn_im.click(rev_im, inp_im, [html_out])
165
  source_tog.change(shuf, [source_tog], [im_box, vid_box])
166