Spaces:
Running on Zero
Running on Zero
Rename mask UI to field; fix sigma at 0.2
Browse files
app.py
CHANGED
|
@@ -625,7 +625,7 @@ def apply_example(example):
|
|
| 625 |
mcx,
|
| 626 |
mcy,
|
| 627 |
example.get("mask_radius", 0.3),
|
| 628 |
-
|
| 629 |
example.get("eps_max_mult", 4.0),
|
| 630 |
example.get("eps_min_mult", 1.0),
|
| 631 |
example.get("step_max_mult", 4.0),
|
|
@@ -664,13 +664,13 @@ with gr.Blocks(title="Human Hallucination Prediction", css="""
|
|
| 664 |
# Inputs (track path so save filenames use stimulus name when from example)
|
| 665 |
default_image_path = os.path.join("stimuli", "urbanoffice1.jpg")
|
| 666 |
image_input = gr.Image(
|
| 667 |
-
label="Input Image (click to set
|
| 668 |
type="pil",
|
| 669 |
value=_image_to_pil(default_image_path),
|
| 670 |
)
|
| 671 |
current_image_path_state = gr.State(value=default_image_path)
|
| 672 |
mask_preview = gr.Image(
|
| 673 |
-
label="
|
| 674 |
type="pil",
|
| 675 |
interactive=False,
|
| 676 |
)
|
|
@@ -705,13 +705,13 @@ with gr.Blocks(title="Human Hallucination Prediction", css="""
|
|
| 705 |
|
| 706 |
with gr.Row():
|
| 707 |
use_adaptive_eps_check = gr.State(value=False)
|
| 708 |
-
use_adaptive_step_check = gr.Checkbox(value=True, label="Use adaptive step size (stronger/weaker updates by
|
| 709 |
with gr.Row():
|
| 710 |
-
mask_center_x_slider = gr.Slider(minimum=-1.0, maximum=1.0, value=0.5, step=0.05, label="
|
| 711 |
-
mask_center_y_slider = gr.Slider(minimum=-1.0, maximum=1.0, value=0.0, step=0.05, label="
|
| 712 |
with gr.Row():
|
| 713 |
-
mask_radius_slider = gr.Slider(minimum=0.01, maximum=1.0, value=0.2, step=0.01, label="
|
| 714 |
-
|
| 715 |
eps_max_mult_slider = gr.State(value=1.0)
|
| 716 |
eps_min_mult_slider = gr.State(value=1.0)
|
| 717 |
with gr.Row():
|
|
@@ -810,7 +810,7 @@ with gr.Blocks(title="Human Hallucination Prediction", css="""
|
|
| 810 |
outputs=[params_section],
|
| 811 |
)
|
| 812 |
|
| 813 |
-
# Click on input image or
|
| 814 |
def _mask_preview_inputs():
|
| 815 |
return [image_input, mask_center_x_slider, mask_center_y_slider, mask_radius_slider]
|
| 816 |
|
|
|
|
| 625 |
mcx,
|
| 626 |
mcy,
|
| 627 |
example.get("mask_radius", 0.3),
|
| 628 |
+
0.2, # fixed field sigma (fall-off); not exposed in simple UI
|
| 629 |
example.get("eps_max_mult", 4.0),
|
| 630 |
example.get("eps_min_mult", 1.0),
|
| 631 |
example.get("step_max_mult", 4.0),
|
|
|
|
| 664 |
# Inputs (track path so save filenames use stimulus name when from example)
|
| 665 |
default_image_path = os.path.join("stimuli", "urbanoffice1.jpg")
|
| 666 |
image_input = gr.Image(
|
| 667 |
+
label="Input Image (click to set field center)",
|
| 668 |
type="pil",
|
| 669 |
value=_image_to_pil(default_image_path),
|
| 670 |
)
|
| 671 |
current_image_path_state = gr.State(value=default_image_path)
|
| 672 |
mask_preview = gr.Image(
|
| 673 |
+
label="Field center preview (click to set center — circle shows field)",
|
| 674 |
type="pil",
|
| 675 |
interactive=False,
|
| 676 |
)
|
|
|
|
| 705 |
|
| 706 |
with gr.Row():
|
| 707 |
use_adaptive_eps_check = gr.State(value=False)
|
| 708 |
+
use_adaptive_step_check = gr.Checkbox(value=True, label="Use adaptive step size (stronger/weaker updates by field)")
|
| 709 |
with gr.Row():
|
| 710 |
+
mask_center_x_slider = gr.Slider(minimum=-1.0, maximum=1.0, value=0.5, step=0.05, label="Field center X")
|
| 711 |
+
mask_center_y_slider = gr.Slider(minimum=-1.0, maximum=1.0, value=0.0, step=0.05, label="Field center Y")
|
| 712 |
with gr.Row():
|
| 713 |
+
mask_radius_slider = gr.Slider(minimum=0.01, maximum=1.0, value=0.2, step=0.01, label="Field radius")
|
| 714 |
+
mask_sigma_slider = gr.State(value=0.2)
|
| 715 |
eps_max_mult_slider = gr.State(value=1.0)
|
| 716 |
eps_min_mult_slider = gr.State(value=1.0)
|
| 717 |
with gr.Row():
|
|
|
|
| 810 |
outputs=[params_section],
|
| 811 |
)
|
| 812 |
|
| 813 |
+
# Click on input image or field preview to set Gaussian field center
|
| 814 |
def _mask_preview_inputs():
|
| 815 |
return [image_input, mask_center_x_slider, mask_center_y_slider, mask_radius_slider]
|
| 816 |
|