Update app.py
Browse files107 unmodified lines108109110111112113114119 unmodified lines234235236237238239240241242243244245246151 unmodified lines398399400401402403404107 unmodified linesif os.path.splitext(p)[-1] in [".jpg", ".jpeg", ".JPG", ".JPEG"]]scanned_frames.sort(key=lambda p: int(os.path.splitext(p)[0]))print(f"SCANNED_FRAMES: {scanned_frames}")return [first_frame, # first_frame_path119 unmodified linesprint("PREDICTOR READY")# `video_dir` a directory of JPEG frames with filenames like `<frame_index>.jpg`print(f"STATE FRAME OUTPUT DIRECTORY: {video_frames_dir}")video_dir = video_frames_dir# scan all the JPEG frame names in this directoryframe_names = scanned_framesprint(f"STORED INFERENCE STEP: {stored_inference_state}")if stored_inference_state is None:# Init SAM2 inference_stateinference_state = predictor.init_state(video_path=video_dir)151 unmodified linesdef reset_propagation(first_frame_path, predictor, stored_inference_state):predictor.reset_state(stored_inference_state)print(f"RESET State: {stored_inference_state} ")return first_frame_path, gr.State([]), gr.State([]), gr.update(value=None, visible=False), stored_inference_state, None, ["frame_0.jpg"], first_frame_path, "frame_0.jpg", gr.update(visible=False)with gr.Blocks() as demo:107 unmodified lines108109110111112113114119 unmodified lines234235236237238239240241242243244245246151 unmodified lines398399400401402403404107 unmodified linesif os.path.splitext(p)[-1] in [".jpg", ".jpeg", ".JPG", ".JPEG"]]scanned_frames.sort(key=lambda p: int(os.path.splitext(p)[0]))# print(f"SCANNED_FRAMES: {scanned_frames}")return [first_frame, # first_frame_path119 unmodified linesprint("PREDICTOR READY")# `video_dir` a directory of JPEG frames with filenames like `<frame_index>.jpg`# print(f"STATE FRAME OUTPUT DIRECTORY: {video_frames_dir}")video_dir = video_frames_dir# scan all the JPEG frame names in this directoryframe_names = scanned_frames# print(f"STORED INFERENCE STEP: {stored_inference_state}")if stored_inference_state is None:# Init SAM2 inference_stateinference_state = predictor.init_state(video_path=video_dir)151 unmodified linesdef reset_propagation(first_frame_path, predictor, stored_inference_state):predictor.reset_state(stored_inference_state)# print(f"RESET State: {stored_inference_state} ")return first_frame_path, gr.State([]), gr.State([]), gr.update(value=None, visible=False), stored_inference_state, None, ["frame_0.jpg"], first_frame_path, "frame_0.jpg", gr.update(visible=False)with gr.Blocks() as demo:
app.py+4-4