reab5555 commited on
Commit
53eff3d
·
verified ·
1 Parent(s): 9f8bcd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -105,8 +105,8 @@ def gradio_app():
105
  def process_and_update(video, target):
106
  frames, error = process_video(video, target, progress_bar)
107
  if frames is not None:
108
- return frames, frames[0], error, len(frames) - 1, 0
109
- return None, None, error, 100, 0
110
 
111
  def update_frame(frame_index, frames):
112
  if frames and 0 <= frame_index < len(frames):
@@ -115,7 +115,7 @@ def gradio_app():
115
 
116
  video_input.upload(process_and_update,
117
  inputs=[video_input, target_input],
118
- outputs=[processed_frames, output_image, error_output, frame_slider.maximum, frame_slider.value])
119
 
120
  frame_slider.change(update_frame,
121
  inputs=[frame_slider, processed_frames],
@@ -123,12 +123,11 @@ def gradio_app():
123
 
124
  def use_sample_video():
125
  sample_video_path = "Drone Video of African Wildlife Wild Botswan.mp4"
126
- frames, output_image, error, slider_max, slider_value = process_and_update(sample_video_path, "Elephant")
127
- return frames, output_image, error, slider_max, slider_value
128
 
129
  use_sample_button.click(use_sample_video,
130
  inputs=None,
131
- outputs=[processed_frames, output_image, error_output, frame_slider.maximum, frame_slider.value])
132
 
133
  return app
134
 
 
105
  def process_and_update(video, target):
106
  frames, error = process_video(video, target, progress_bar)
107
  if frames is not None:
108
+ return frames, frames[0], error, gr.Slider(maximum=len(frames) - 1, value=0)
109
+ return None, None, error, gr.Slider(maximum=100, value=0)
110
 
111
  def update_frame(frame_index, frames):
112
  if frames and 0 <= frame_index < len(frames):
 
115
 
116
  video_input.upload(process_and_update,
117
  inputs=[video_input, target_input],
118
+ outputs=[processed_frames, output_image, error_output, frame_slider])
119
 
120
  frame_slider.change(update_frame,
121
  inputs=[frame_slider, processed_frames],
 
123
 
124
  def use_sample_video():
125
  sample_video_path = "Drone Video of African Wildlife Wild Botswan.mp4"
126
+ return process_and_update(sample_video_path, "Elephant")
 
127
 
128
  use_sample_button.click(use_sample_video,
129
  inputs=None,
130
+ outputs=[processed_frames, output_image, error_output, frame_slider])
131
 
132
  return app
133