Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -252,8 +252,22 @@ output_image_component = gr.Image(type="pil", label="Segmented Image")
|
|
252 |
# ]
|
253 |
# Filter out non-existent example files to prevent errors
|
254 |
# example_paths = [ex for ex in example_paths if os.path.exists(ex)]
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
iface = gr.Interface(
|
258 |
fn=segment_image,
|
259 |
inputs=[input_image_component, model_choice_component],
|
@@ -261,7 +275,7 @@ iface = gr.Interface(
|
|
261 |
title=title,
|
262 |
description=description,
|
263 |
article=article,
|
264 |
-
examples=
|
265 |
allow_flagging="never",
|
266 |
theme="shivi/calm_seafoam"
|
267 |
)
|
|
|
252 |
# ]
|
253 |
# Filter out non-existent example files to prevent errors
|
254 |
# example_paths = [ex for ex in example_paths if os.path.exists(ex)]
|
255 |
+
# Base list of example image paths/URLs
|
256 |
+
base_example_images = [
|
257 |
+
"cats-on-rock-1948.jpg",
|
258 |
+
"dogs.png",
|
259 |
+
"000000484893.jpg",
|
260 |
+
"https://reachomk.github.io/gen2seg/images/comparison/vertical/7.png",
|
261 |
+
"https://reachomk.github.io/gen2seg/images/comparison/horizontal/11.png",
|
262 |
+
"https://reachomk.github.io/gen2seg/images/comparison/vertical/2.jpg"
|
263 |
+
]
|
264 |
+
|
265 |
+
# Generate examples for each image with both model choices
|
266 |
+
model_choices_for_examples = list(MODEL_IDS.keys()) # ["SD", "MAE-H"]
|
267 |
+
formatted_examples = []
|
268 |
+
for img_path_or_url in base_example_images:
|
269 |
+
for model_choice in model_choices_for_examples:
|
270 |
+
formatted_examples.append([img_path_or_url, model_choice])
|
271 |
iface = gr.Interface(
|
272 |
fn=segment_image,
|
273 |
inputs=[input_image_component, model_choice_component],
|
|
|
275 |
title=title,
|
276 |
description=description,
|
277 |
article=article,
|
278 |
+
examples=formatted_examples if formatted_examples else None, # Pass None if no examples
|
279 |
allow_flagging="never",
|
280 |
theme="shivi/calm_seafoam"
|
281 |
)
|