Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -356,7 +356,7 @@ def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_
|
|
356 |
print(f"JPEG_IMAGES: {jpeg_images}")
|
357 |
|
358 |
if vis_frame_type == "check":
|
359 |
-
return gr.update(value=jpeg_images), gr.update(value=None), gr.update(choices=available_frames_to_check, value=working_frame, visible=True), available_frames_to_check
|
360 |
elif vis_frame_type == "render":
|
361 |
# Create a video clip from the image sequence
|
362 |
original_fps = get_video_fps(video_in)
|
@@ -372,7 +372,7 @@ def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_
|
|
372 |
codec='libx264'
|
373 |
)
|
374 |
|
375 |
-
return gr.update(value=None), gr.update(value=final_vid_output_path), working_frame, available_frames_to_check
|
376 |
|
377 |
def update_ui(vis_frame_type):
|
378 |
if vis_frame_type == "check":
|
@@ -399,7 +399,7 @@ def reset_propagation(predictor, stored_inference_state):
|
|
399 |
|
400 |
predictor.reset_state(stored_inference_state)
|
401 |
print(f"RESET State: {stored_inference_state} ")
|
402 |
-
return gr.update(value=None, visible=False), stored_inference_state, None, ["frame_0.jpg"], first_frame_path
|
403 |
|
404 |
with gr.Blocks() as demo:
|
405 |
first_frame_path = gr.State()
|
@@ -453,7 +453,7 @@ with gr.Blocks() as demo:
|
|
453 |
with gr.Row():
|
454 |
vis_frame_type = gr.Radio(label="Propagation level", choices=["check", "render"], value="check", scale=2)
|
455 |
propagate_btn = gr.Button("Propagate", scale=1)
|
456 |
-
|
457 |
output_propagated = gr.Gallery(label="Propagated Mask samples gallery", visible=False)
|
458 |
output_video = gr.Video(visible=False)
|
459 |
# output_result_mask = gr.Image()
|
@@ -545,7 +545,7 @@ with gr.Blocks() as demo:
|
|
545 |
reset_prpgt_brn.click(
|
546 |
fn = reset_propagation,
|
547 |
inputs = [loaded_predictor, stored_inference_state],
|
548 |
-
outputs = [output_propagated, stored_inference_state, output_result, available_frames_to_check, input_first_frame_image, working_frame],
|
549 |
queue=False
|
550 |
)
|
551 |
|
@@ -557,7 +557,7 @@ with gr.Blocks() as demo:
|
|
557 |
).then(
|
558 |
fn = propagate_to_all,
|
559 |
inputs = [video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type, available_frames_to_check, working_frame],
|
560 |
-
outputs = [output_propagated, output_video, working_frame, available_frames_to_check]
|
561 |
)
|
562 |
|
563 |
demo.launch(show_api=False, show_error=True)
|
|
|
356 |
print(f"JPEG_IMAGES: {jpeg_images}")
|
357 |
|
358 |
if vis_frame_type == "check":
|
359 |
+
return gr.update(value=jpeg_images), gr.update(value=None), gr.update(choices=available_frames_to_check, value=working_frame, visible=True), available_frames_to_check, gr.update(visible=True)
|
360 |
elif vis_frame_type == "render":
|
361 |
# Create a video clip from the image sequence
|
362 |
original_fps = get_video_fps(video_in)
|
|
|
372 |
codec='libx264'
|
373 |
)
|
374 |
|
375 |
+
return gr.update(value=None), gr.update(value=final_vid_output_path), working_frame, available_frames_to_check, gr.update(visible=True)
|
376 |
|
377 |
def update_ui(vis_frame_type):
|
378 |
if vis_frame_type == "check":
|
|
|
399 |
|
400 |
predictor.reset_state(stored_inference_state)
|
401 |
print(f"RESET State: {stored_inference_state} ")
|
402 |
+
return gr.update(value=None, visible=False), stored_inference_state, None, ["frame_0.jpg"], first_frame_path, gr.update(visible=False)
|
403 |
|
404 |
with gr.Blocks() as demo:
|
405 |
first_frame_path = gr.State()
|
|
|
453 |
with gr.Row():
|
454 |
vis_frame_type = gr.Radio(label="Propagation level", choices=["check", "render"], value="check", scale=2)
|
455 |
propagate_btn = gr.Button("Propagate", scale=1)
|
456 |
+
reset_prpgt_brn = gr.Button("Reset", scale=0.75, visible=False)
|
457 |
output_propagated = gr.Gallery(label="Propagated Mask samples gallery", visible=False)
|
458 |
output_video = gr.Video(visible=False)
|
459 |
# output_result_mask = gr.Image()
|
|
|
545 |
reset_prpgt_brn.click(
|
546 |
fn = reset_propagation,
|
547 |
inputs = [loaded_predictor, stored_inference_state],
|
548 |
+
outputs = [output_propagated, stored_inference_state, output_result, available_frames_to_check, input_first_frame_image, working_frame, reset_prpgt_brn],
|
549 |
queue=False
|
550 |
)
|
551 |
|
|
|
557 |
).then(
|
558 |
fn = propagate_to_all,
|
559 |
inputs = [video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type, available_frames_to_check, working_frame],
|
560 |
+
outputs = [output_propagated, output_video, working_frame, available_frames_to_check, reset_prpgt_brn]
|
561 |
)
|
562 |
|
563 |
demo.launch(show_api=False, show_error=True)
|