Spaces:
Sleeping
Sleeping
Nunzio commited on
Commit ·
f6252ee
1
Parent(s): d18a7c1
TRIED FIXING SELECTION
Browse files
app.py
CHANGED
|
@@ -12,8 +12,9 @@ city_image_dir = "./preloadedImages/cityScapes"
|
|
| 12 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 13 |
|
| 14 |
|
| 15 |
-
def load_example(
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
# %% prediction on an image
|
|
@@ -75,21 +76,21 @@ with gr.Blocks(title="Semantic Segmentation Predictors") as demo:
|
|
| 75 |
gr.Markdown("## Preloaded GTA V images to be used for testing the model")
|
| 76 |
with gr.Row():
|
| 77 |
gta_gallery = gr.Gallery(value=loadPreloadedImages(gta_image_dir),
|
| 78 |
-
label="GTA V Examples", show_label=False, columns=5,
|
| 79 |
-
rows=1, height=200,
|
| 80 |
)
|
| 81 |
|
| 82 |
with gr.Row():
|
| 83 |
gr.Markdown("## Preloaded Cityscapes images to be used for testing the model")
|
| 84 |
with gr.Row():
|
| 85 |
city_gallery = gr.Gallery(value=loadPreloadedImages(city_image_dir),
|
| 86 |
-
label="Cityscapes Examples", show_label=False, columns=5,
|
| 87 |
-
rows=1, height=256,
|
| 88 |
)
|
| 89 |
|
| 90 |
-
gta_gallery.select(fn=load_example, inputs=[gta_gallery], outputs=[image_input])
|
| 91 |
-
city_gallery.select(fn=load_example, inputs=[city_gallery], outputs=[image_input])
|
| 92 |
-
|
| 93 |
submit_btn.click(
|
| 94 |
fn=run_prediction,
|
| 95 |
inputs=[image_input, model_selector],
|
|
|
|
| 12 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 13 |
|
| 14 |
|
| 15 |
+
def load_example(index:int=0, useGta:bool=True)-> gr.Image:
|
| 16 |
+
example_img = loadPreloadedImages(gta_image_dir if useGta else city_image_dir)
|
| 17 |
+
return gr.update(value=example_img[index if 0 <= index < len(example_img) else 0], visible=True)
|
| 18 |
|
| 19 |
|
| 20 |
# %% prediction on an image
|
|
|
|
| 76 |
gr.Markdown("## Preloaded GTA V images to be used for testing the model")
|
| 77 |
with gr.Row():
|
| 78 |
gta_gallery = gr.Gallery(value=loadPreloadedImages(gta_image_dir),
|
| 79 |
+
label="GTA V Examples", show_label=False, columns=5, type="index",
|
| 80 |
+
rows=1, height=200, allow_preview=False
|
| 81 |
)
|
| 82 |
|
| 83 |
with gr.Row():
|
| 84 |
gr.Markdown("## Preloaded Cityscapes images to be used for testing the model")
|
| 85 |
with gr.Row():
|
| 86 |
city_gallery = gr.Gallery(value=loadPreloadedImages(city_image_dir),
|
| 87 |
+
label="Cityscapes Examples", show_label=False, columns=5, type="index",
|
| 88 |
+
rows=1, height=256, allow_preview=False
|
| 89 |
)
|
| 90 |
|
| 91 |
+
gta_gallery.select(fn=load_example, inputs=[gta_gallery, True], outputs=[predict(image_input)])
|
| 92 |
+
city_gallery.select(fn=load_example, inputs=[city_gallery, False], outputs=[predict(image_input)])
|
| 93 |
+
|
| 94 |
submit_btn.click(
|
| 95 |
fn=run_prediction,
|
| 96 |
inputs=[image_input, model_selector],
|