jomasego commited on
Commit
9443255
·
1 Parent(s): 8685779

Fix: Restructure Gradio UI and event handlers in app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -138,8 +138,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
138
  # BACKEND_VIDEO_URL = "https://your-modal-or-backend-url/process_video_analysis"
139
  # BACKEND_TOPIC_URL = "https://your-modal-or-backend-url/analyze_topic"
140
 
141
- demo.launch()
142
-
143
  with gr.Tab("Demo (for Manual Testing)"):
144
  gr.Markdown("### Manually test video URLs or paths for interpretation and observe the JSON response.")
145
  demo_interface.render()
@@ -150,7 +148,7 @@ demo.launch()
150
 
151
  with gr.Row():
152
  topic_input = gr.Textbox(label="Enter Topic", placeholder="e.g., 'best cat videos', 'Python programming tutorials'", scale=3)
153
- max_videos_input = gr.Number(label="Max Videos to Analyze", value=3, minimum=1, maximum=5, step=1, scale=1) # Max 5 for UI, backend might support more
154
 
155
  topic_analysis_output = gr.JSON(label="Topic Analysis Results")
156
 
@@ -165,7 +163,7 @@ demo.launch()
165
  )
166
 
167
  def clear_topic_outputs():
168
- return [None, 3, None] # topic_input, max_videos_input (reset to default), topic_analysis_output
169
  topic_clear_button.click(fn=clear_topic_outputs, inputs=[], outputs=[topic_input, max_videos_input, topic_analysis_output])
170
 
171
  gr.Examples(
@@ -181,6 +179,5 @@ demo.launch()
181
  )
182
  gr.Markdown("**Note:** This process involves searching for videos and then analyzing each one. It can take a significant amount of time, especially for multiple videos. The backend has a long timeout, but please be patient.")
183
 
184
- # Launch the Gradio application
185
- if __name__ == "__main__":
186
- app.launch(debug=True, server_name="0.0.0.0")
 
138
  # BACKEND_VIDEO_URL = "https://your-modal-or-backend-url/process_video_analysis"
139
  # BACKEND_TOPIC_URL = "https://your-modal-or-backend-url/analyze_topic"
140
 
 
 
141
  with gr.Tab("Demo (for Manual Testing)"):
142
  gr.Markdown("### Manually test video URLs or paths for interpretation and observe the JSON response.")
143
  demo_interface.render()
 
148
 
149
  with gr.Row():
150
  topic_input = gr.Textbox(label="Enter Topic", placeholder="e.g., 'best cat videos', 'Python programming tutorials'", scale=3)
151
+ max_videos_input = gr.Number(label="Max Videos to Analyze", value=3, minimum=1, maximum=5, step=1, scale=1)
152
 
153
  topic_analysis_output = gr.JSON(label="Topic Analysis Results")
154
 
 
163
  )
164
 
165
  def clear_topic_outputs():
166
+ return [None, 3, None]
167
  topic_clear_button.click(fn=clear_topic_outputs, inputs=[], outputs=[topic_input, max_videos_input, topic_analysis_output])
168
 
169
  gr.Examples(
 
179
  )
180
  gr.Markdown("**Note:** This process involves searching for videos and then analyzing each one. It can take a significant amount of time, especially for multiple videos. The backend has a long timeout, but please be patient.")
181
 
182
+ # Final launch of the Gradio app
183
+ demo.launch()