tomerk commited on
Commit
c91ed12
·
verified ·
1 Parent(s): 5d5c12f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -208,10 +208,10 @@ def analyze_stream(prompt, chatbot):
208
  cap.release()
209
  return chatbot
210
 
211
- def analyze_video_file(prompt, video_path, chatbot):
212
  global stop_capture
213
  stop_capture = False # Reset the stop flag when analysis starts
214
-
215
  cap = cv2.VideoCapture(video_path)
216
 
217
  # Get video properties
@@ -228,7 +228,7 @@ def analyze_video_file(prompt, video_path, chatbot):
228
  while not stop_capture:
229
  ret, frame = cap.read()
230
  if not ret:
231
- break
232
  frames.append(frame)
233
 
234
  # Split the video into chunks of frames corresponding to 5 seconds
@@ -261,7 +261,7 @@ with gr.Blocks(title="Conntour", fill_height=True) as demo:
261
  prompt = gr.Textbox(label="Enter your prompt alert")
262
  start_btn = gr.Button("Start")
263
  stop_btn = gr.Button("Stop")
264
- start_btn.click(analyze_stream, inputs=[prompt, chatbot], outputs=[chatbot], queue=True)
265
  stop_btn.click(stop_capture_func)
266
 
267
  demo.launch(favicon_path='favicon.ico', auth=(user_name, password))
 
208
  cap.release()
209
  return chatbot
210
 
211
+ def analyze_video_file(prompt, chatbot):
212
  global stop_capture
213
  stop_capture = False # Reset the stop flag when analysis starts
214
+ video_path = "https://uqnmqpvwlbpmdvutucia.supabase.co/storage/v1/object/public/videos_test/junction.mp4?t=2024-12-26T09%3A58%3A11.931Z"
215
  cap = cv2.VideoCapture(video_path)
216
 
217
  # Get video properties
 
228
  while not stop_capture:
229
  ret, frame = cap.read()
230
  if not ret:
231
+ cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
232
  frames.append(frame)
233
 
234
  # Split the video into chunks of frames corresponding to 5 seconds
 
261
  prompt = gr.Textbox(label="Enter your prompt alert")
262
  start_btn = gr.Button("Start")
263
  stop_btn = gr.Button("Stop")
264
+ start_btn.click(analyze_video_file, inputs=[prompt, chatbot], outputs=[chatbot], queue=True)
265
  stop_btn.click(stop_capture_func)
266
 
267
  demo.launch(favicon_path='favicon.ico', auth=(user_name, password))