Update ui/ui_components.py
Browse files- ui/ui_components.py +5 -10
ui/ui_components.py
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
* All callbacks live in ui/callbacks.py
|
| 7 |
* Adds live previews for the first frame of the uploaded video
|
| 8 |
and for the custom background image
|
| 9 |
-
*
|
| 10 |
"""
|
| 11 |
|
| 12 |
from __future__ import annotations
|
|
@@ -36,11 +36,6 @@
|
|
| 36 |
.sm { font-size: 13px; opacity: 0.85; }
|
| 37 |
#statusbox { min-height: 120px; }
|
| 38 |
.preview-img { border-radius: var(--radius); border: 1px solid rgba(0,0,0,.08); }
|
| 39 |
-
.bg-preview-persistent {
|
| 40 |
-
border: 2px solid rgba(0,120,255,0.3);
|
| 41 |
-
background: rgba(0,120,255,0.05);
|
| 42 |
-
min-height: 200px;
|
| 43 |
-
}
|
| 44 |
"""
|
| 45 |
|
| 46 |
# Keep in sync with utils/cv_processing.PROFESSIONAL_BACKGROUNDS
|
|
@@ -206,7 +201,7 @@ def create_interface() -> gr.Blocks:
|
|
| 206 |
# ------------------------------------------------------------------
|
| 207 |
btn_load.click(cb_load_models, outputs=statusbox)
|
| 208 |
|
| 209 |
-
#
|
| 210 |
btn_run.click(
|
| 211 |
cb_process_video,
|
| 212 |
inputs=[
|
|
@@ -219,13 +214,13 @@ def create_interface() -> gr.Blocks:
|
|
| 219 |
preview_mask,
|
| 220 |
preview_greenscreen,
|
| 221 |
],
|
| 222 |
-
outputs=[out_video, statusbox
|
| 223 |
)
|
| 224 |
|
| 225 |
btn_cancel.click(cb_cancel, outputs=statusbox)
|
| 226 |
btn_refresh.click(cb_status, outputs=[model_status, cache_status])
|
| 227 |
|
| 228 |
-
# Clear button -
|
| 229 |
btn_clear.click(
|
| 230 |
cb_clear,
|
| 231 |
outputs=[out_video, statusbox, gen_preview, gen_path, custom_bg_preview_img]
|
|
@@ -240,7 +235,7 @@ def create_interface() -> gr.Blocks:
|
|
| 240 |
|
| 241 |
use_gen_as_custom.click(cb_use_gen_bg, inputs=[gen_path], outputs=[custom_bg])
|
| 242 |
|
| 243 |
-
# Live previews
|
| 244 |
video.change(cb_video_changed, inputs=[video], outputs=[video_preview])
|
| 245 |
custom_bg.change(cb_custom_bg_preview, inputs=[custom_bg], outputs=[custom_bg_preview_img])
|
| 246 |
|
|
|
|
| 6 |
* All callbacks live in ui/callbacks.py
|
| 7 |
* Adds live previews for the first frame of the uploaded video
|
| 8 |
and for the custom background image
|
| 9 |
+
* FIXED: Background preview NOT touched by process button
|
| 10 |
"""
|
| 11 |
|
| 12 |
from __future__ import annotations
|
|
|
|
| 36 |
.sm { font-size: 13px; opacity: 0.85; }
|
| 37 |
#statusbox { min-height: 120px; }
|
| 38 |
.preview-img { border-radius: var(--radius); border: 1px solid rgba(0,0,0,.08); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
"""
|
| 40 |
|
| 41 |
# Keep in sync with utils/cv_processing.PROFESSIONAL_BACKGROUNDS
|
|
|
|
| 201 |
# ------------------------------------------------------------------
|
| 202 |
btn_load.click(cb_load_models, outputs=statusbox)
|
| 203 |
|
| 204 |
+
# FIXED: Process button only updates what needs to change
|
| 205 |
btn_run.click(
|
| 206 |
cb_process_video,
|
| 207 |
inputs=[
|
|
|
|
| 214 |
preview_mask,
|
| 215 |
preview_greenscreen,
|
| 216 |
],
|
| 217 |
+
outputs=[out_video, statusbox], # Only 2 outputs - NOT touching preview!
|
| 218 |
)
|
| 219 |
|
| 220 |
btn_cancel.click(cb_cancel, outputs=statusbox)
|
| 221 |
btn_refresh.click(cb_status, outputs=[model_status, cache_status])
|
| 222 |
|
| 223 |
+
# Clear button - only clears what it needs to
|
| 224 |
btn_clear.click(
|
| 225 |
cb_clear,
|
| 226 |
outputs=[out_video, statusbox, gen_preview, gen_path, custom_bg_preview_img]
|
|
|
|
| 235 |
|
| 236 |
use_gen_as_custom.click(cb_use_gen_bg, inputs=[gen_path], outputs=[custom_bg])
|
| 237 |
|
| 238 |
+
# Live previews - only update when actually changing backgrounds
|
| 239 |
video.change(cb_video_changed, inputs=[video], outputs=[video_preview])
|
| 240 |
custom_bg.change(cb_custom_bg_preview, inputs=[custom_bg], outputs=[custom_bg_preview_img])
|
| 241 |
|