John2J commited on
Commit
a230b4d
·
verified ·
1 Parent(s): faf3a2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -53,7 +53,7 @@ COLOR_PALETTE = [
53
  ]
54
 
55
  random_seed = 42
56
- video_length = 201
57
  W = 1024
58
  H = W
59
  device = "cpu"
@@ -216,6 +216,14 @@ def get_source_info(video_state):
216
  del vr
217
  return (fps if fps and fps > 0 else 15.0), (w, h)
218
 
 
 
 
 
 
 
 
 
219
  def preprocess_for_removal(images, masks):
220
  out_images = []
221
  out_masks = []
@@ -480,7 +488,7 @@ with gr.Blocks() as demo:
480
  clear_btn = gr.Button("Clear All Clicks")
481
 
482
  with gr.Row(elem_id="my-btn"):
483
- n_frames_slider = gr.Slider(minimum=1, maximum=201, value=81, step=1, label="Tracking Frames N")
484
  track_btn = gr.Button("Tracking")
485
  video_output = gr.Video(label="Tracking Result", elem_id="my-video")
486
 
 
53
  ]
54
 
55
  random_seed = 42
56
+ video_length = 9000
57
  W = 1024
58
  H = W
59
  device = "cpu"
 
216
  del vr
217
  return (fps if fps and fps > 0 else 15.0), (w, h)
218
 
219
+ def on_video_change(video_path):
220
+ if not video_path:
221
+ return gr.update()
222
+ vr = VideoReader(video_path, ctx=cpu(0))
223
+ n = len(vr)
224
+ del vr
225
+ return gr.update(maximum=max(9000, n), value=n, label=f"Tracking Frames N (video has {n})")
226
+
227
  def preprocess_for_removal(images, masks):
228
  out_images = []
229
  out_masks = []
 
488
  clear_btn = gr.Button("Clear All Clicks")
489
 
490
  with gr.Row(elem_id="my-btn"):
491
+ n_frames_slider = gr.Slider(minimum=1, maximum=9000, value=81, step=1, label="Tracking Frames N")
492
  track_btn = gr.Button("Tracking")
493
  video_output = gr.Video(label="Tracking Result", elem_id="my-video")
494