update
Browse files16 unmodified lines1718192021222311 unmodified lines3536373839404142434416 unmodified linesfiles = {'video': (os.path.basename(input_video_path), video_file, 'video/mp4')}# Send the video to the backend API and stream the responsewith requests.post(BACKEND_URL, files=files, stream=True, timeout=300) as response:response.raise_for_status()# Save the processed video that the backend sends back11 unmodified linesstatus = f"API Error: {e}"yield status, None, None# --- GRADIO UI (from your original app.py) ---with gr.Blocks() as demo:gr.Markdown("<h1 style='text-align:center;'>Vehicle and Pedestrian Tracker</h1>")input_video = gr.Video(label="Upload Video")start_btn = gr.Button("Start Tracking")status_display = gr.HTML("") # Initially empty16 unmodified lines1718192021222311 unmodified lines35363738394041424344454647484916 unmodified linesfiles = {'video': (os.path.basename(input_video_path), video_file, 'video/mp4')}# Send the video to the backend API and stream the responsewith requests.post(BACKEND_URL, files=files, stream=True, timeout= 600 ) as response:response.raise_for_status()# Save the processed video that the backend sends back11 unmodified linesstatus = f"API Error: {e}"yield status, None, Noneexcept requests.exceptions.ReadTimeout:gr.Error("The processing took too long (more than 10 minutes). Please try a shorter video.")return None# --- GRADIO UI (from your original app.py) ---with gr.Blocks() as demo: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'.")input_video = gr.Video(label="Upload Video")start_btn = gr.Button("Start Tracking")status_display = gr.HTML("") # Initially empty
app.py+8-3