UPDATED ERRORS
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ import torchvision.transforms as T
|
|
| 10 |
import urllib.request
|
| 11 |
import json
|
| 12 |
import cv2
|
| 13 |
-
import uuid
|
| 14 |
|
| 15 |
# Model Configs
|
| 16 |
MODEL_CONFIGS = {
|
|
@@ -237,6 +236,9 @@ def predict(image, model_name, noise_level):
|
|
| 237 |
if model_name is None:
|
| 238 |
return {"Error": "Please select a model"}, None, None
|
| 239 |
|
|
|
|
|
|
|
|
|
|
| 240 |
if noise_level > 0:
|
| 241 |
image = add_adversarial_noise(image, noise_level)
|
| 242 |
|
|
@@ -287,6 +289,9 @@ def get_class_specific_attention(image, model_name, class_query):
|
|
| 287 |
if not class_query or class_query.strip() == "":
|
| 288 |
return None, None, "Please enter a class name"
|
| 289 |
|
|
|
|
|
|
|
|
|
|
| 290 |
class_query_lower = class_query.lower().strip()
|
| 291 |
matching_idx = None
|
| 292 |
matched_label = None
|
|
@@ -355,7 +360,7 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="gray",
|
|
| 355 |
with gr.Row(variant="panel"):
|
| 356 |
with gr.Column(scale=1, min_width=300):
|
| 357 |
gr.Markdown("### π· Input")
|
| 358 |
-
input_image = gr.Image(type="pil", label="Upload Image", height=300, interactive=True
|
| 359 |
model_dropdown = gr.Dropdown(
|
| 360 |
choices=[f"{name} - {MODEL_CONFIGS[name]['desc']}" for name in MODEL_CONFIGS.keys()],
|
| 361 |
label="Select Model",
|
|
@@ -371,7 +376,7 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="gray",
|
|
| 371 |
info="Add noise to test model robustness",
|
| 372 |
interactive=True
|
| 373 |
)
|
| 374 |
-
run_button = gr.Button("π Run Prediction", variant="primary"
|
| 375 |
|
| 376 |
with gr.Column(scale=2):
|
| 377 |
gr.Markdown("### π Results")
|
|
|
|
| 10 |
import urllib.request
|
| 11 |
import json
|
| 12 |
import cv2
|
|
|
|
| 13 |
|
| 14 |
# Model Configs
|
| 15 |
MODEL_CONFIGS = {
|
|
|
|
| 236 |
if model_name is None:
|
| 237 |
return {"Error": "Please select a model"}, None, None
|
| 238 |
|
| 239 |
+
# Extract model name from dropdown (remove description)
|
| 240 |
+
model_name = model_name.split(" - ")[0]
|
| 241 |
+
|
| 242 |
if noise_level > 0:
|
| 243 |
image = add_adversarial_noise(image, noise_level)
|
| 244 |
|
|
|
|
| 289 |
if not class_query or class_query.strip() == "":
|
| 290 |
return None, None, "Please enter a class name"
|
| 291 |
|
| 292 |
+
# Extract model name from dropdown (remove description)
|
| 293 |
+
model_name = model_name.split(" - ")[0]
|
| 294 |
+
|
| 295 |
class_query_lower = class_query.lower().strip()
|
| 296 |
matching_idx = None
|
| 297 |
matched_label = None
|
|
|
|
| 360 |
with gr.Row(variant="panel"):
|
| 361 |
with gr.Column(scale=1, min_width=300):
|
| 362 |
gr.Markdown("### π· Input")
|
| 363 |
+
input_image = gr.Image(type="pil", label="Upload Image", height=300, interactive=True)
|
| 364 |
model_dropdown = gr.Dropdown(
|
| 365 |
choices=[f"{name} - {MODEL_CONFIGS[name]['desc']}" for name in MODEL_CONFIGS.keys()],
|
| 366 |
label="Select Model",
|
|
|
|
| 376 |
info="Add noise to test model robustness",
|
| 377 |
interactive=True
|
| 378 |
)
|
| 379 |
+
run_button = gr.Button("π Run Prediction", variant="primary")
|
| 380 |
|
| 381 |
with gr.Column(scale=2):
|
| 382 |
gr.Markdown("### π Results")
|