Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -70,7 +70,7 @@ def preprocess_video_in(video_path):
|
|
70 |
cap.release()
|
71 |
|
72 |
# 'image' is the first frame extracted from video_in
|
73 |
-
return first_frame, gr.State([]), gr.State([]), first_frame, first_frame, output_dir,
|
74 |
|
75 |
def get_point(point_type, tracking_points, trackings_input_label, first_frame_path, evt: gr.SelectData):
|
76 |
print(f"You selected {evt.value} at {evt.index} from {evt.target}")
|
@@ -256,12 +256,13 @@ def sam_process(input_first_frame_image, checkpoint, tracking_points, trackings_
|
|
256 |
|
257 |
return "output_first_frame.jpg", frame_names, inference_state
|
258 |
|
259 |
-
def propagate_to_all(checkpoint, stored_inference_state, stored_frame_names):
|
260 |
#### PROPAGATION ####
|
261 |
sam2_checkpoint, model_cfg = load_model(checkpoint)
|
262 |
predictor = build_sam2_video_predictor(model_cfg, sam2_checkpoint)
|
263 |
inference_state = stored_inference_state
|
264 |
frame_names = stored_frame_names
|
|
|
265 |
# Define a directory to save the JPEG images
|
266 |
frames_output_dir = "frames_output_images"
|
267 |
os.makedirs(frames_output_dir, exist_ok=True)
|
@@ -365,7 +366,7 @@ with gr.Blocks() as demo:
|
|
365 |
|
366 |
propagate_btn.click(
|
367 |
fn = propagate_to_all,
|
368 |
-
inputs = [checkpoint, stored_inference_state, stored_frame_names],
|
369 |
outputs = [output_propagated]
|
370 |
)
|
371 |
|
|
|
70 |
cap.release()
|
71 |
|
72 |
# 'image' is the first frame extracted from video_in
|
73 |
+
return first_frame, gr.State([]), gr.State([]), first_frame, first_frame, output_dir, None, None
|
74 |
|
75 |
def get_point(point_type, tracking_points, trackings_input_label, first_frame_path, evt: gr.SelectData):
|
76 |
print(f"You selected {evt.value} at {evt.index} from {evt.target}")
|
|
|
256 |
|
257 |
return "output_first_frame.jpg", frame_names, inference_state
|
258 |
|
259 |
+
def propagate_to_all(checkpoint, stored_inference_state, stored_frame_names, video_frames_dir):
|
260 |
#### PROPAGATION ####
|
261 |
sam2_checkpoint, model_cfg = load_model(checkpoint)
|
262 |
predictor = build_sam2_video_predictor(model_cfg, sam2_checkpoint)
|
263 |
inference_state = stored_inference_state
|
264 |
frame_names = stored_frame_names
|
265 |
+
video_dir = video_frames_dir
|
266 |
# Define a directory to save the JPEG images
|
267 |
frames_output_dir = "frames_output_images"
|
268 |
os.makedirs(frames_output_dir, exist_ok=True)
|
|
|
366 |
|
367 |
propagate_btn.click(
|
368 |
fn = propagate_to_all,
|
369 |
+
inputs = [checkpoint, stored_inference_state, stored_frame_names, video_frames_dir],
|
370 |
outputs = [output_propagated]
|
371 |
)
|
372 |
|