apailang commited on
Commit
596c82d
Β·
1 Parent(s): 5676e9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -145,10 +145,20 @@ def detect_video(video):
145
 
146
  # return open(video_path_1, "rb"), open(video_path_2, "rb")
147
 
148
- def display_two_videos(video_path_1, video_path_2):
149
  path1=os.path.join(os.path.dirname(__file__), "data/c_base_detected.mp4")
150
  path2= os.path.join(os.path.dirname(__file__), "data/c_tuned_detected.mp4")
151
- return open(path1, "rb"), open(path2, "rb")
 
 
 
 
 
 
 
 
 
 
152
 
153
  #os.path.join(os.path.dirname(__file__), "files/a.mp4")
154
 
@@ -223,8 +233,8 @@ tuned_image = gr.Interface(
223
  video = gr.Interface(
224
  fn=display_two_videos,
225
  inputs=[
226
- gr.Textbox(label="Path to detected base model Video",value="data/c_base_detected.mp4",info="video has been pre-processed"),
227
- gr.Textbox(label="Path to tuned base model Video",value="data/c_tuned_detected.mp4",info="video has been pre-processed")
228
  ],
229
  outputs=[gr.Video(label="base model"), gr.Video(label="Tuned model")], # Specify video outputs
230
  title="Comparing base vs tuned detected video",
 
145
 
146
  # return open(video_path_1, "rb"), open(video_path_2, "rb")
147
 
148
+ def display_two_videos():
149
  path1=os.path.join(os.path.dirname(__file__), "data/c_base_detected.mp4")
150
  path2= os.path.join(os.path.dirname(__file__), "data/c_tuned_detected.mp4")
151
+ cap1 = cv2.VideoCapture(path1)
152
+ cap2 = cv2.VideoCapture(path2)
153
+
154
+ while True:
155
+ ret1, frame1 = cap1.read()
156
+ ret2, frame2 = cap2.read()
157
+ if not ret1 or not ret2:
158
+ break
159
+ yield frame1, frame2 # Yield frames from both videos as a tuple
160
+
161
+ # return open(path1, "rb"), open(path2, "rb")
162
 
163
  #os.path.join(os.path.dirname(__file__), "files/a.mp4")
164
 
 
233
  video = gr.Interface(
234
  fn=display_two_videos,
235
  inputs=[
236
+ # gr.Textbox(label="Path to detected base model Video",value="data/c_base_detected.mp4",info="video has been pre-processed"),
237
+ # gr.Textbox(label="Path to tuned base model Video",value="data/c_tuned_detected.mp4",info="video has been pre-processed")
238
  ],
239
  outputs=[gr.Video(label="base model"), gr.Video(label="Tuned model")], # Specify video outputs
240
  title="Comparing base vs tuned detected video",