am-om commited on
Commit
441f41f
·
1 Parent(s): 4c95fc4
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -17,7 +17,7 @@ def track_video_via_api(input_video_path):
17
  files = {'video': (os.path.basename(input_video_path), video_file, 'video/mp4')}
18
 
19
  # Send the video to the backend API and stream the response
20
- with requests.post(BACKEND_URL, files=files, stream=True, timeout=300) as response:
21
  response.raise_for_status()
22
 
23
  # Save the processed video that the backend sends back
@@ -35,10 +35,15 @@ def track_video_via_api(input_video_path):
35
  status = f"API Error: {e}"
36
  yield status, None, None
37
 
 
 
 
 
 
 
38
  # --- GRADIO UI (from your original app.py) ---
39
  with gr.Blocks() as demo:
40
- gr.Markdown("<h1 style='text-align:center;'>Vehicle and Pedestrian Tracker</h1>")
41
-
42
  input_video = gr.Video(label="Upload Video")
43
  start_btn = gr.Button("Start Tracking")
44
  status_display = gr.HTML("") # Initially empty
 
17
  files = {'video': (os.path.basename(input_video_path), video_file, 'video/mp4')}
18
 
19
  # Send the video to the backend API and stream the response
20
+ with requests.post(BACKEND_URL, files=files, stream=True, timeout= 600 ) as response:
21
  response.raise_for_status()
22
 
23
  # Save the processed video that the backend sends back
 
35
  status = f"API Error: {e}"
36
  yield status, None, None
37
 
38
+ except requests.exceptions.ReadTimeout:
39
+ gr.Error("The processing took too long (more than 10 minutes). Please try a shorter video.")
40
+ return None
41
+
42
+
43
+
44
  # --- GRADIO UI (from your original app.py) ---
45
  with gr.Blocks() as demo:
46
+ gr.Markdown("<h1 style='text-align:center; font-size:4em;'>Vehicle and Pedestrian Segmentation</h1>") gr.Markdown("Note: Processing on the free tier can take several minutes. Please be patient after clicking 'Start Tracking'.")
 
47
  input_video = gr.Video(label="Upload Video")
48
  start_btn = gr.Button("Start Tracking")
49
  status_display = gr.HTML("") # Initially empty