Nunzio commited on
Commit
4d2f437
·
1 Parent(s): e96b8d2
Files changed (1) hide show
  1. app.py +9 -19
app.py CHANGED
@@ -21,19 +21,6 @@ MODELS = {
21
 
22
 
23
  image_list = loadPreloadedImages(gta_image_dir, city_image_dir, turin_image_dir)
24
- uuid_to_path = dict()
25
-
26
- for i in range(len(image_list)):
27
- uid = str(uuid.uuid5(uuid.NAMESPACE_URL, image_list[i][1]))
28
- uuid_to_path[uid] = image_list[i][1]
29
- image_list[i][1] = uid
30
-
31
- def handle_image_click(uid):
32
- print(uid)
33
- print(type(uid))
34
- print(uuid_to_path.get(uid))
35
- return Image.open(uuid_to_path.get(uid)).convert("RGB")
36
-
37
 
38
 
39
  # %% prediction on an image
@@ -97,12 +84,15 @@ with gr.Blocks(title="Semantic Segmentation Predictors") as demo:
97
  gr.Markdown("## Preloaded images to be used for testing the model")
98
  gr.Markdown("You can use images from the Grand Theft Auto V video game, the Cityscapes dataset or even from Turin")
99
  with gr.Row():
100
- image_gallery = gr.Gallery(value=image_list, label="Preloaded Examples",
101
- type="value", columns=5, rows=4,
102
- height=1050, allow_preview=False, show_label=False,
103
- )
104
-
105
- image_gallery.select(fn=handle_image_click, inputs=[], outputs=image_input)
 
 
 
106
 
107
  submit_btn.click(
108
  fn=run_prediction,
 
21
 
22
 
23
  image_list = loadPreloadedImages(gta_image_dir, city_image_dir, turin_image_dir)
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
 
26
  # %% prediction on an image
 
84
  gr.Markdown("## Preloaded images to be used for testing the model")
85
  gr.Markdown("You can use images from the Grand Theft Auto V video game, the Cityscapes dataset or even from Turin")
86
  with gr.Row():
87
+ def create_image_selector(image):
88
+ def select_image():
89
+ image_input.value = image
90
+ return gr.update(value=image, visible=True)
91
+ return select_image
92
+
93
+ for img, path in image_list:
94
+ img_component = gr.Image(value=img, interactive=True, show_label=False)
95
+ img_component.select(fn=create_image_selector, inputs=[], outputs=image_input)
96
 
97
  submit_btn.click(
98
  fn=run_prediction,