Spaces:
Running
on
Zero
Running
on
Zero
Upload 2 files
Browse filesadded a default
app.py
CHANGED
|
@@ -247,9 +247,18 @@ def apply_example(example):
|
|
| 247 |
]
|
| 248 |
|
| 249 |
# Define the interface
|
| 250 |
-
with gr.Blocks(title="Generative Inference Demo"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
gr.Markdown("# Generative Inference Demo")
|
| 252 |
-
gr.Markdown("This demo showcases how neural networks can perceive visual illusions through generative inference.")
|
| 253 |
|
| 254 |
gr.Markdown("""
|
| 255 |
**How to use this demo:**
|
|
@@ -262,7 +271,7 @@ with gr.Blocks(title="Generative Inference Demo") as demo:
|
|
| 262 |
with gr.Row():
|
| 263 |
with gr.Column(scale=1):
|
| 264 |
# Inputs
|
| 265 |
-
image_input = gr.Image(label="Input Image", type="pil")
|
| 266 |
|
| 267 |
with gr.Row():
|
| 268 |
model_choice = gr.Dropdown(
|
|
@@ -278,25 +287,25 @@ with gr.Blocks(title="Generative Inference Demo") as demo:
|
|
| 278 |
)
|
| 279 |
|
| 280 |
with gr.Row():
|
| 281 |
-
eps_slider = gr.Slider(minimum=0.01, maximum=3.0, value=0
|
| 282 |
-
iterations_slider = gr.Slider(minimum=1, maximum=600, value=
|
| 283 |
|
| 284 |
with gr.Row():
|
| 285 |
-
initial_noise_slider = gr.Slider(minimum=0.0, maximum=1.0, value=0.
|
| 286 |
label="Initial Noise Ratio")
|
| 287 |
-
diffusion_noise_slider = gr.Slider(minimum=0.0, maximum=0.05, value=0.
|
| 288 |
label="Diffusion Noise Ratio") # Corrected name
|
| 289 |
|
| 290 |
with gr.Row():
|
| 291 |
-
step_size_slider = gr.Slider(minimum=0.01, maximum=2.0, value=0
|
| 292 |
label="Step Size") # Added step size slider
|
| 293 |
layer_choice = gr.Dropdown(
|
| 294 |
choices=["all", "conv1", "bn1", "relu", "maxpool", "layer1", "layer2", "layer3", "layer4", "avgpool"],
|
| 295 |
-
value="
|
| 296 |
label="Model Layer"
|
| 297 |
)
|
| 298 |
|
| 299 |
-
run_button = gr.Button("Run Inference", variant="primary")
|
| 300 |
|
| 301 |
with gr.Column(scale=2):
|
| 302 |
# Outputs
|
|
|
|
| 247 |
]
|
| 248 |
|
| 249 |
# Define the interface
|
| 250 |
+
with gr.Blocks(title="Generative Inference Demo", css="""
|
| 251 |
+
.purple-button {
|
| 252 |
+
background-color: #8B5CF6 !important;
|
| 253 |
+
color: white !important;
|
| 254 |
+
border: none !important;
|
| 255 |
+
}
|
| 256 |
+
.purple-button:hover {
|
| 257 |
+
background-color: #7C3AED !important;
|
| 258 |
+
}
|
| 259 |
+
""") as demo:
|
| 260 |
gr.Markdown("# Generative Inference Demo")
|
| 261 |
+
gr.Markdown("This demo showcases how neural networks can perceive visual illusions and develop Gestalt principles of perceptual organization through generative inference.")
|
| 262 |
|
| 263 |
gr.Markdown("""
|
| 264 |
**How to use this demo:**
|
|
|
|
| 271 |
with gr.Row():
|
| 272 |
with gr.Column(scale=1):
|
| 273 |
# Inputs
|
| 274 |
+
image_input = gr.Image(label="Input Image", type="pil", value=os.path.join("stimuli", "Neon_Color_Circle.jpg"))
|
| 275 |
|
| 276 |
with gr.Row():
|
| 277 |
model_choice = gr.Dropdown(
|
|
|
|
| 287 |
)
|
| 288 |
|
| 289 |
with gr.Row():
|
| 290 |
+
eps_slider = gr.Slider(minimum=0.01, maximum=3.0, value=20.0, step=0.01, label="Epsilon (Perturbation Size)")
|
| 291 |
+
iterations_slider = gr.Slider(minimum=1, maximum=600, value=101, step=1, label="Number of Iterations") # Updated max to 600
|
| 292 |
|
| 293 |
with gr.Row():
|
| 294 |
+
initial_noise_slider = gr.Slider(minimum=0.0, maximum=1.0, value=0.8, step=0.01,
|
| 295 |
label="Initial Noise Ratio")
|
| 296 |
+
diffusion_noise_slider = gr.Slider(minimum=0.0, maximum=0.05, value=0.003, step=0.001,
|
| 297 |
label="Diffusion Noise Ratio") # Corrected name
|
| 298 |
|
| 299 |
with gr.Row():
|
| 300 |
+
step_size_slider = gr.Slider(minimum=0.01, maximum=2.0, value=1.0, step=0.01,
|
| 301 |
label="Step Size") # Added step size slider
|
| 302 |
layer_choice = gr.Dropdown(
|
| 303 |
choices=["all", "conv1", "bn1", "relu", "maxpool", "layer1", "layer2", "layer3", "layer4", "avgpool"],
|
| 304 |
+
value="layer3",
|
| 305 |
label="Model Layer"
|
| 306 |
)
|
| 307 |
|
| 308 |
+
run_button = gr.Button("Run Inference", variant="primary", elem_classes="purple-button")
|
| 309 |
|
| 310 |
with gr.Column(scale=2):
|
| 311 |
# Outputs
|