Spaces:
Runtime error
Runtime error
Update app.py
Browse files218 unmodified lines21922022122222322462 unmodified lines28728828929029129229329494 unmodified lines38939039139239339429 unmodified lines42442542642742842975 unmodified lines505506507508509510218 unmodified linesvideo_frames_dir, # extracted_frames_output_dir defined in 'preprocess_video_in' functionscanned_frames,working_frame: str = None, # current frame being added pointsprogress=gr.Progress(track_tqdm=True)):62 unmodified linesplt.savefig(first_frame_output_filename, format='jpg')plt.close()torch.cuda.empty_cache()return "output_first_frame.jpg", frame_names, inference_state, gr.update(value=working_frame, visible=True)def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type, progress=gr.Progress(track_tqdm=True)):#### PROPAGATION ####94 unmodified linesscanned_frames = gr.State()stored_inference_state = gr.State()stored_frame_names = gr.State()with gr.Column():gr.Markdown("# SAM2 Video Predictor")gr.Markdown("This is a simple demo for video segmentation with SAM2.")29 unmodified linesvideo_in = gr.Video(label="Video IN")with gr.Column():working_frame = gr.Dropdown(label="working frame ID", choices=[""], value=None, visible=False, allow_custom_value=False, interactive=True)output_result = gr.Image(label="current working mask ref")with gr.Row():75 unmodified linesvideo_frames_dir,scanned_frames,working_frame,],outputs = [output_result,218 unmodified lines21922022122222322422562 unmodified lines28828929029129229329429529629729829994 unmodified lines39439539639739839940029 unmodified lines43043143243343443543675 unmodified lines512513514515516517518218 unmodified linesvideo_frames_dir, # extracted_frames_output_dir defined in 'preprocess_video_in' functionscanned_frames,working_frame: str = None, # current frame being added pointsavailable_frames_to_check,progress=gr.Progress(track_tqdm=True)):62 unmodified linesplt.savefig(first_frame_output_filename, format='jpg')plt.close()torch.cuda.empty_cache()# Assuming available_frames_to_check.value is a listif working_frame not in available_frames_to_check.value:available_frames_to_check.value.append(working_frame)return "output_first_frame.jpg", frame_names, inference_state, gr.update(choices=available_frames_to_check.value, value=working_frame, visible=True)def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type, progress=gr.Progress(track_tqdm=True)):#### PROPAGATION ####94 unmodified linesscanned_frames = gr.State()stored_inference_state = gr.State()stored_frame_names = gr.State()available_frames_to_check = gr.State([])with gr.Column():gr.Markdown("# SAM2 Video Predictor")gr.Markdown("This is a simple demo for video segmentation with SAM2.")29 unmodified linesvideo_in = gr.Video(label="Video IN")with gr.Column():working_frame = gr.Dropdown(label="working frame ID", choices=[""], value=None, visible=False, allow_custom_value=False, interactive=True)output_result = gr.Image(label="current working mask ref")with gr.Row():75 unmodified linesvideo_frames_dir,scanned_frames,working_frame,available_frames_to_check,],outputs = [output_result,
app.py+9-1