mfarre HF staff commited on
Commit
9c021ca
·
1 Parent(s): 167ab4b

initial test

Browse files
Files changed (1) hide show
  1. app.py +36 -23
app.py CHANGED
@@ -118,45 +118,58 @@ def create_ui(examples_path: str):
118
  )
119
  process_btn = gr.Button("Process Video", variant="primary")
120
 
121
- processing_msg = gr.Markdown(visible=False)
122
 
123
- with gr.Row(visible=False) as results_row:
124
  with gr.Column():
125
- video_description = gr.Markdown(label="Video Analysis")
126
  with gr.Column():
127
- highlight_types = gr.Markdown(label="Detected Highlights")
128
 
129
- with gr.Row(visible=False) as output_row:
130
- output_video = gr.Video(label="Highlight Video")
131
- download_btn = gr.Button("Download Highlights")
132
-
133
- error_msg = gr.Markdown(visible=False)
134
 
135
  def on_process(video):
136
  if not video:
137
- return None, None, None, "Please upload a video", False, False
138
-
139
- processing_msg.visible = True
140
- processing_msg.value = "Starting video processing..."
 
 
 
141
 
 
142
  output_path, desc, highlights, err = process_video(video)
143
 
144
  if err:
145
- return None, None, None, err, False, False
 
 
 
 
 
 
146
 
147
- return output_path, desc, highlights, "", True, True
 
 
 
 
 
 
148
 
149
  process_btn.click(
150
  on_process,
151
  inputs=[input_video],
152
- outputs=[
153
- output_video,
154
- video_description,
155
- highlight_types,
156
- error_msg,
157
- results_row,
158
- output_row
159
- ]
160
  )
161
 
162
  return app
 
118
  )
119
  process_btn = gr.Button("Process Video", variant="primary")
120
 
121
+ status = gr.Markdown(visible=True)
122
 
123
+ with gr.Row() as results_row:
124
  with gr.Column():
125
+ video_description = gr.Markdown(visible=False)
126
  with gr.Column():
127
+ highlight_types = gr.Markdown(visible=False)
128
 
129
+ with gr.Row() as output_row:
130
+ output_video = gr.Video(label="Highlight Video", visible=False)
131
+ download_btn = gr.Button("Download Highlights", visible=False)
 
 
132
 
133
  def on_process(video):
134
  if not video:
135
+ return {
136
+ status: "Please upload a video",
137
+ video_description: gr.update(visible=False),
138
+ highlight_types: gr.update(visible=False),
139
+ output_video: gr.update(visible=False),
140
+ download_btn: gr.update(visible=False)
141
+ }
142
 
143
+ status.value = "Processing video..."
144
  output_path, desc, highlights, err = process_video(video)
145
 
146
  if err:
147
+ return {
148
+ status: f"Error: {err}",
149
+ video_description: gr.update(visible=False),
150
+ highlight_types: gr.update(visible=False),
151
+ output_video: gr.update(visible=False),
152
+ download_btn: gr.update(visible=False)
153
+ }
154
 
155
+ return {
156
+ status: "Processing complete!",
157
+ video_description: gr.update(value=desc, visible=True),
158
+ highlight_types: gr.update(value=highlights, visible=True),
159
+ output_video: gr.update(value=output_path, visible=True),
160
+ download_btn: gr.update(visible=True)
161
+ }
162
 
163
  process_btn.click(
164
  on_process,
165
  inputs=[input_video],
166
+ outputs=[status, video_description, highlight_types, output_video, download_btn]
167
+ )
168
+
169
+ download_btn.click(
170
+ lambda x: x,
171
+ inputs=[output_video],
172
+ outputs=[output_video]
 
173
  )
174
 
175
  return app