Spaces:
Running
on
Zero
Running
on
Zero
Clean up
Browse files
app.py
CHANGED
|
@@ -1011,7 +1011,7 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1011 |
)
|
| 1012 |
|
| 1013 |
video_in_pointbox.change(
|
| 1014 |
-
_on_video_change_pointbox,
|
| 1015 |
inputs=[app_state, video_in_pointbox],
|
| 1016 |
outputs=[app_state, frame_slider_pointbox, preview_pointbox, load_status_pointbox],
|
| 1017 |
show_progress=True,
|
|
@@ -1023,13 +1023,13 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1023 |
return update_frame_display(state_in, int(idx))
|
| 1024 |
|
| 1025 |
frame_slider_pointbox.change(
|
| 1026 |
-
_sync_frame_idx_pointbox,
|
| 1027 |
inputs=[app_state, frame_slider_pointbox],
|
| 1028 |
outputs=preview_pointbox,
|
| 1029 |
)
|
| 1030 |
|
| 1031 |
video_in_text.change(
|
| 1032 |
-
_on_video_change_text,
|
| 1033 |
inputs=[app_state, video_in_text],
|
| 1034 |
outputs=[app_state, frame_slider_text, preview_text, load_status_text, active_prompts_display],
|
| 1035 |
show_progress=True,
|
|
@@ -1041,7 +1041,7 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1041 |
return update_frame_display(state_in, int(idx))
|
| 1042 |
|
| 1043 |
frame_slider_text.change(
|
| 1044 |
-
_sync_frame_idx_text,
|
| 1045 |
inputs=[app_state, frame_slider_text],
|
| 1046 |
outputs=preview_text,
|
| 1047 |
)
|
|
@@ -1051,14 +1051,14 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1051 |
s.current_obj_id = int(oid)
|
| 1052 |
return gr.update()
|
| 1053 |
|
| 1054 |
-
obj_id_inp.change(_sync_obj_id, inputs=[app_state, obj_id_inp], outputs=[])
|
| 1055 |
|
| 1056 |
def _sync_label(s: AppState, lab: str):
|
| 1057 |
if s is not None and lab is not None:
|
| 1058 |
s.current_label = str(lab)
|
| 1059 |
return gr.update()
|
| 1060 |
|
| 1061 |
-
label_radio.change(_sync_label, inputs=[app_state, label_radio], outputs=[])
|
| 1062 |
|
| 1063 |
def _sync_prompt_type(s: AppState, val: str):
|
| 1064 |
if s is not None and val is not None:
|
|
@@ -1072,15 +1072,15 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1072 |
return updates
|
| 1073 |
|
| 1074 |
prompt_type.change(
|
| 1075 |
-
_sync_prompt_type,
|
| 1076 |
inputs=[app_state, prompt_type],
|
| 1077 |
outputs=[label_radio, clear_old_chk],
|
| 1078 |
)
|
| 1079 |
|
| 1080 |
preview_pointbox.select(
|
| 1081 |
-
on_image_click,
|
| 1082 |
-
[preview_pointbox, app_state, frame_slider_pointbox, obj_id_inp, label_radio, clear_old_chk],
|
| 1083 |
-
preview_pointbox,
|
| 1084 |
)
|
| 1085 |
|
| 1086 |
def _on_text_apply(state: AppState, frame_idx: int, text: str):
|
|
@@ -1088,13 +1088,13 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1088 |
return img, status, active_prompts
|
| 1089 |
|
| 1090 |
text_apply_btn.click(
|
| 1091 |
-
_on_text_apply,
|
| 1092 |
inputs=[app_state, frame_slider_text, text_prompt_input],
|
| 1093 |
outputs=[preview_text, text_status, active_prompts_display],
|
| 1094 |
)
|
| 1095 |
|
| 1096 |
reset_prompts_btn.click(
|
| 1097 |
-
reset_prompts,
|
| 1098 |
inputs=[app_state],
|
| 1099 |
outputs=[app_state, preview_text, text_status, active_prompts_display],
|
| 1100 |
)
|
|
@@ -1129,25 +1129,25 @@ with gr.Blocks(title="SAM3", theme=Soft(primary_hue="blue", secondary_hue="rose"
|
|
| 1129 |
render_btn_text.click(_render_video, inputs=[app_state], outputs=[playback_video_text])
|
| 1130 |
|
| 1131 |
propagate_btn_pointbox.click(
|
| 1132 |
-
propagate_masks,
|
| 1133 |
inputs=[app_state],
|
| 1134 |
outputs=[app_state, propagate_status_pointbox, frame_slider_pointbox],
|
| 1135 |
)
|
| 1136 |
|
| 1137 |
propagate_btn_text.click(
|
| 1138 |
-
propagate_masks,
|
| 1139 |
inputs=[app_state],
|
| 1140 |
outputs=[app_state, propagate_status_text, frame_slider_text],
|
| 1141 |
)
|
| 1142 |
|
| 1143 |
reset_btn_pointbox.click(
|
| 1144 |
-
reset_session,
|
| 1145 |
inputs=app_state,
|
| 1146 |
outputs=[app_state, preview_pointbox, frame_slider_pointbox, frame_slider_pointbox, load_status_pointbox],
|
| 1147 |
)
|
| 1148 |
|
| 1149 |
reset_btn_text.click(
|
| 1150 |
-
reset_session,
|
| 1151 |
inputs=app_state,
|
| 1152 |
outputs=[
|
| 1153 |
app_state,
|
|
|
|
| 1011 |
)
|
| 1012 |
|
| 1013 |
video_in_pointbox.change(
|
| 1014 |
+
fn=_on_video_change_pointbox,
|
| 1015 |
inputs=[app_state, video_in_pointbox],
|
| 1016 |
outputs=[app_state, frame_slider_pointbox, preview_pointbox, load_status_pointbox],
|
| 1017 |
show_progress=True,
|
|
|
|
| 1023 |
return update_frame_display(state_in, int(idx))
|
| 1024 |
|
| 1025 |
frame_slider_pointbox.change(
|
| 1026 |
+
fn=_sync_frame_idx_pointbox,
|
| 1027 |
inputs=[app_state, frame_slider_pointbox],
|
| 1028 |
outputs=preview_pointbox,
|
| 1029 |
)
|
| 1030 |
|
| 1031 |
video_in_text.change(
|
| 1032 |
+
fn=_on_video_change_text,
|
| 1033 |
inputs=[app_state, video_in_text],
|
| 1034 |
outputs=[app_state, frame_slider_text, preview_text, load_status_text, active_prompts_display],
|
| 1035 |
show_progress=True,
|
|
|
|
| 1041 |
return update_frame_display(state_in, int(idx))
|
| 1042 |
|
| 1043 |
frame_slider_text.change(
|
| 1044 |
+
fn=_sync_frame_idx_text,
|
| 1045 |
inputs=[app_state, frame_slider_text],
|
| 1046 |
outputs=preview_text,
|
| 1047 |
)
|
|
|
|
| 1051 |
s.current_obj_id = int(oid)
|
| 1052 |
return gr.update()
|
| 1053 |
|
| 1054 |
+
obj_id_inp.change(fn=_sync_obj_id, inputs=[app_state, obj_id_inp], outputs=[])
|
| 1055 |
|
| 1056 |
def _sync_label(s: AppState, lab: str):
|
| 1057 |
if s is not None and lab is not None:
|
| 1058 |
s.current_label = str(lab)
|
| 1059 |
return gr.update()
|
| 1060 |
|
| 1061 |
+
label_radio.change(fn=_sync_label, inputs=[app_state, label_radio], outputs=[])
|
| 1062 |
|
| 1063 |
def _sync_prompt_type(s: AppState, val: str):
|
| 1064 |
if s is not None and val is not None:
|
|
|
|
| 1072 |
return updates
|
| 1073 |
|
| 1074 |
prompt_type.change(
|
| 1075 |
+
fn=_sync_prompt_type,
|
| 1076 |
inputs=[app_state, prompt_type],
|
| 1077 |
outputs=[label_radio, clear_old_chk],
|
| 1078 |
)
|
| 1079 |
|
| 1080 |
preview_pointbox.select(
|
| 1081 |
+
fn=on_image_click,
|
| 1082 |
+
inputs=[preview_pointbox, app_state, frame_slider_pointbox, obj_id_inp, label_radio, clear_old_chk],
|
| 1083 |
+
outputs=preview_pointbox,
|
| 1084 |
)
|
| 1085 |
|
| 1086 |
def _on_text_apply(state: AppState, frame_idx: int, text: str):
|
|
|
|
| 1088 |
return img, status, active_prompts
|
| 1089 |
|
| 1090 |
text_apply_btn.click(
|
| 1091 |
+
fn=_on_text_apply,
|
| 1092 |
inputs=[app_state, frame_slider_text, text_prompt_input],
|
| 1093 |
outputs=[preview_text, text_status, active_prompts_display],
|
| 1094 |
)
|
| 1095 |
|
| 1096 |
reset_prompts_btn.click(
|
| 1097 |
+
fn=reset_prompts,
|
| 1098 |
inputs=[app_state],
|
| 1099 |
outputs=[app_state, preview_text, text_status, active_prompts_display],
|
| 1100 |
)
|
|
|
|
| 1129 |
render_btn_text.click(_render_video, inputs=[app_state], outputs=[playback_video_text])
|
| 1130 |
|
| 1131 |
propagate_btn_pointbox.click(
|
| 1132 |
+
fn=propagate_masks,
|
| 1133 |
inputs=[app_state],
|
| 1134 |
outputs=[app_state, propagate_status_pointbox, frame_slider_pointbox],
|
| 1135 |
)
|
| 1136 |
|
| 1137 |
propagate_btn_text.click(
|
| 1138 |
+
fn=propagate_masks,
|
| 1139 |
inputs=[app_state],
|
| 1140 |
outputs=[app_state, propagate_status_text, frame_slider_text],
|
| 1141 |
)
|
| 1142 |
|
| 1143 |
reset_btn_pointbox.click(
|
| 1144 |
+
fn=reset_session,
|
| 1145 |
inputs=app_state,
|
| 1146 |
outputs=[app_state, preview_pointbox, frame_slider_pointbox, frame_slider_pointbox, load_status_pointbox],
|
| 1147 |
)
|
| 1148 |
|
| 1149 |
reset_btn_text.click(
|
| 1150 |
+
fn=reset_session,
|
| 1151 |
inputs=app_state,
|
| 1152 |
outputs=[
|
| 1153 |
app_state,
|