mik170802 commited on
Commit
824e90d
·
1 Parent(s): c3d3f5a

aggiunte immagini

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. gradio_ui/app.py +122 -15
  2. gradio_ui/handlers.py +119 -2
  3. gradio_ui/tabs/compare.py +15 -0
  4. gradio_ui/tabs/draw_defects.py +15 -0
  5. gradio_ui/tabs/upload.py +16 -1
  6. sample_images/bottle/broken_large/000.png +3 -0
  7. sample_images/bottle/broken_large/001.png +3 -0
  8. sample_images/bottle/broken_small/000.png +3 -0
  9. sample_images/bottle/broken_small/001.png +3 -0
  10. sample_images/bottle/contamination/000.png +3 -0
  11. sample_images/bottle/contamination/001.png +3 -0
  12. sample_images/bottle/good/000.png +3 -0
  13. sample_images/cable/bent_wire/000.png +3 -0
  14. sample_images/cable/bent_wire/001.png +3 -0
  15. sample_images/cable/cable_swap/000.png +3 -0
  16. sample_images/cable/cable_swap/001.png +3 -0
  17. sample_images/cable/combined/000.png +3 -0
  18. sample_images/cable/combined/001.png +3 -0
  19. sample_images/cable/cut_inner_insulation/000.png +3 -0
  20. sample_images/cable/cut_inner_insulation/001.png +3 -0
  21. sample_images/cable/good/000.png +3 -0
  22. sample_images/capsule/crack/000.png +3 -0
  23. sample_images/capsule/crack/001.png +3 -0
  24. sample_images/capsule/faulty_imprint/000.png +3 -0
  25. sample_images/capsule/faulty_imprint/001.png +3 -0
  26. sample_images/capsule/good/000.png +3 -0
  27. sample_images/capsule/poke/000.png +3 -0
  28. sample_images/capsule/poke/001.png +3 -0
  29. sample_images/capsule/scratch/000.png +3 -0
  30. sample_images/capsule/scratch/001.png +3 -0
  31. sample_images/carpet/color/000.png +3 -0
  32. sample_images/carpet/color/001.png +3 -0
  33. sample_images/carpet/cut/000.png +3 -0
  34. sample_images/carpet/cut/001.png +3 -0
  35. sample_images/carpet/good/000.png +3 -0
  36. sample_images/carpet/hole/000.png +3 -0
  37. sample_images/carpet/hole/001.png +3 -0
  38. sample_images/carpet/metal_contamination/000.png +3 -0
  39. sample_images/carpet/metal_contamination/001.png +3 -0
  40. sample_images/grid/bent/000.png +3 -0
  41. sample_images/grid/bent/001.png +3 -0
  42. sample_images/grid/broken/000.png +3 -0
  43. sample_images/grid/broken/001.png +3 -0
  44. sample_images/grid/glue/000.png +3 -0
  45. sample_images/grid/glue/001.png +3 -0
  46. sample_images/grid/good/000.png +3 -0
  47. sample_images/grid/metal_contamination/000.png +3 -0
  48. sample_images/grid/metal_contamination/001.png +3 -0
  49. sample_images/hazelnut/crack/000.png +3 -0
  50. sample_images/hazelnut/crack/001.png +3 -0
gradio_ui/app.py CHANGED
@@ -6,6 +6,8 @@ by assembling all tab components and wiring event handlers.
6
  """
7
 
8
  import gradio as gr
 
 
9
 
10
  from core import get_available_models, MVTEC_CATEGORIES
11
  from gradio_ui.handlers import (
@@ -15,6 +17,7 @@ from gradio_ui.handlers import (
15
  predict_compare,
16
  update_categories,
17
  update_compare_categories,
 
18
  )
19
  from gradio_ui.content import MAIN_HEADER
20
  from gradio_ui.tabs import (
@@ -69,7 +72,7 @@ def create_app() -> gr.Blocks:
69
  # =========================================================================
70
  upload_components["model_dropdown"].change(
71
  fn=update_categories,
72
- inputs=[upload_components["model_dropdown"]],
73
  outputs=[upload_components["category_dropdown"]]
74
  )
75
 
@@ -86,18 +89,42 @@ def create_app() -> gr.Blocks:
86
  ]
87
  )
88
 
89
- # Allow Enter key on image upload
90
- upload_components["image_input"].change(
91
- fn=predict,
92
- inputs=[
93
- upload_components["image_input"],
94
- upload_components["model_dropdown"],
95
- upload_components["category_dropdown"]
96
- ],
97
- outputs=[
98
- upload_components["result_image"],
99
- upload_components["result_text"]
100
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  )
102
 
103
  # =========================================================================
@@ -105,7 +132,7 @@ def create_app() -> gr.Blocks:
105
  # =========================================================================
106
  sketch_components["model_dropdown"].change(
107
  fn=update_categories,
108
- inputs=[sketch_components["model_dropdown"]],
109
  outputs=[sketch_components["category_dropdown"]]
110
  )
111
 
@@ -122,12 +149,52 @@ def create_app() -> gr.Blocks:
122
  ]
123
  )
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  # =========================================================================
126
  # Event handlers for Tab 3 (Compare)
127
  # =========================================================================
128
  compare_components["model_checkboxes"].change(
129
  fn=update_compare_categories,
130
- inputs=[compare_components["model_checkboxes"]],
131
  outputs=[compare_components["category_dropdown"]]
132
  )
133
 
@@ -143,6 +210,46 @@ def create_app() -> gr.Blocks:
143
  compare_components["summary"]
144
  ]
145
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  return app
148
 
 
6
  """
7
 
8
  import gradio as gr
9
+ import numpy as np
10
+ from PIL import Image
11
 
12
  from core import get_available_models, MVTEC_CATEGORIES
13
  from gradio_ui.handlers import (
 
17
  predict_compare,
18
  update_categories,
19
  update_compare_categories,
20
+ get_category_from_sample,
21
  )
22
  from gradio_ui.content import MAIN_HEADER
23
  from gradio_ui.tabs import (
 
72
  # =========================================================================
73
  upload_components["model_dropdown"].change(
74
  fn=update_categories,
75
+ inputs=[upload_components["model_dropdown"], upload_components["category_dropdown"]],
76
  outputs=[upload_components["category_dropdown"]]
77
  )
78
 
 
89
  ]
90
  )
91
 
92
+ # Sample gallery selection handler for Upload tab
93
+ def on_upload_sample_select(evt: gr.SelectData, current_model: str, gallery_value: list):
94
+ """Handler for sample image selection in upload tab."""
95
+ if evt is None:
96
+ return None, gr.Dropdown()
97
+
98
+ # Get the selected index and retrieve original path from gallery data
99
+ idx = evt.index
100
+ if gallery_value and idx < len(gallery_value):
101
+ item = gallery_value[idx]
102
+ if isinstance(item, tuple):
103
+ image_path, label = item
104
+ category = get_category_from_sample(label)
105
+ else:
106
+ image_path = item
107
+ category = get_category_from_sample(str(image_path))
108
+ else:
109
+ return None, gr.Dropdown()
110
+
111
+ try:
112
+ img = np.array(Image.open(image_path).convert("RGB"))
113
+ except Exception as e:
114
+ print(f"Error loading image: {e}")
115
+ return None, gr.Dropdown()
116
+
117
+ trained = get_trained_categories(current_model)
118
+ if trained and category in trained:
119
+ return img, gr.Dropdown(choices=trained, value=category)
120
+ elif trained:
121
+ return img, gr.Dropdown(choices=trained, value=trained[0])
122
+ return img, gr.Dropdown(choices=MVTEC_CATEGORIES, value=category)
123
+
124
+ upload_components["sample_gallery"].select(
125
+ fn=on_upload_sample_select,
126
+ inputs=[upload_components["model_dropdown"], upload_components["sample_gallery"]],
127
+ outputs=[upload_components["image_input"], upload_components["category_dropdown"]]
128
  )
129
 
130
  # =========================================================================
 
132
  # =========================================================================
133
  sketch_components["model_dropdown"].change(
134
  fn=update_categories,
135
+ inputs=[sketch_components["model_dropdown"], sketch_components["category_dropdown"]],
136
  outputs=[sketch_components["category_dropdown"]]
137
  )
138
 
 
149
  ]
150
  )
151
 
152
+ # Sample gallery selection handler for Sketch tab
153
+ def on_sketch_sample_select(evt: gr.SelectData, current_model: str, gallery_value: list):
154
+ """Handler for sample image selection in sketch tab."""
155
+ if evt is None:
156
+ return None, gr.Dropdown()
157
+
158
+ # Get the selected index and retrieve original path from gallery data
159
+ idx = evt.index
160
+ if gallery_value and idx < len(gallery_value):
161
+ item = gallery_value[idx]
162
+ if isinstance(item, tuple):
163
+ image_path, label = item
164
+ category = get_category_from_sample(label)
165
+ else:
166
+ image_path = item
167
+ category = get_category_from_sample(str(image_path))
168
+ else:
169
+ return None, gr.Dropdown()
170
+
171
+ try:
172
+ img = np.array(Image.open(image_path).convert("RGB"))
173
+ # For ImageEditor, return the image in the expected format
174
+ editor_value = {"background": img, "layers": [], "composite": img}
175
+ except Exception as e:
176
+ print(f"Error loading image: {e}")
177
+ return None, gr.Dropdown()
178
+
179
+ trained = get_trained_categories(current_model)
180
+ if trained and category in trained:
181
+ return editor_value, gr.Dropdown(choices=trained, value=category)
182
+ elif trained:
183
+ return editor_value, gr.Dropdown(choices=trained, value=trained[0])
184
+ return editor_value, gr.Dropdown(choices=MVTEC_CATEGORIES, value=category)
185
+
186
+ sketch_components["sample_gallery"].select(
187
+ fn=on_sketch_sample_select,
188
+ inputs=[sketch_components["model_dropdown"], sketch_components["sample_gallery"]],
189
+ outputs=[sketch_components["image_editor"], sketch_components["category_dropdown"]]
190
+ )
191
+
192
  # =========================================================================
193
  # Event handlers for Tab 3 (Compare)
194
  # =========================================================================
195
  compare_components["model_checkboxes"].change(
196
  fn=update_compare_categories,
197
+ inputs=[compare_components["model_checkboxes"], compare_components["category_dropdown"]],
198
  outputs=[compare_components["category_dropdown"]]
199
  )
200
 
 
210
  compare_components["summary"]
211
  ]
212
  )
213
+
214
+ # Sample gallery selection handler for Compare tab
215
+ def on_compare_sample_select(evt: gr.SelectData, selected_models: list, gallery_value: list):
216
+ """Handler for sample image selection in compare tab."""
217
+ if evt is None:
218
+ return None, gr.Dropdown()
219
+
220
+ # Get the selected index and retrieve original path from gallery data
221
+ idx = evt.index
222
+ if gallery_value and idx < len(gallery_value):
223
+ item = gallery_value[idx]
224
+ if isinstance(item, tuple):
225
+ image_path, label = item
226
+ category = get_category_from_sample(label)
227
+ else:
228
+ image_path = item
229
+ category = get_category_from_sample(str(image_path))
230
+ else:
231
+ return None, gr.Dropdown()
232
+
233
+ try:
234
+ img = np.array(Image.open(image_path).convert("RGB"))
235
+ except Exception as e:
236
+ print(f"Error loading image: {e}")
237
+ return None, gr.Dropdown()
238
+
239
+ # Get common categories for selected models
240
+ from gradio_ui.handlers import get_common_categories
241
+ common = get_common_categories(selected_models)
242
+ if common and category in common:
243
+ return img, gr.Dropdown(choices=common, value=category)
244
+ elif common:
245
+ return img, gr.Dropdown(choices=common, value=common[0])
246
+ return img, gr.Dropdown(choices=MVTEC_CATEGORIES, value=category)
247
+
248
+ compare_components["sample_gallery"].select(
249
+ fn=on_compare_sample_select,
250
+ inputs=[compare_components["model_checkboxes"], compare_components["sample_gallery"]],
251
+ outputs=[compare_components["image_input"], compare_components["category_dropdown"]]
252
+ )
253
 
254
  return app
255
 
gradio_ui/handlers.py CHANGED
@@ -256,33 +256,150 @@ def get_common_categories(model_names: list) -> list:
256
  return list(common) if common else MVTEC_CATEGORIES
257
 
258
 
259
- def update_categories(model_name: str):
260
  """
261
  Updates available categories based on selected model.
 
262
 
263
  Args:
264
  model_name: Selected model name
 
265
 
266
  Returns:
267
  Updated Gradio Dropdown component
268
  """
269
  trained = get_trained_categories(model_name)
270
  if trained:
 
 
 
271
  return gr.Dropdown(choices=trained, value=trained[0])
 
 
 
272
  return gr.Dropdown(choices=MVTEC_CATEGORIES, value="bottle")
273
 
274
 
275
- def update_compare_categories(selected_models: list):
276
  """
277
  Update categories dropdown based on selected models.
 
278
 
279
  Args:
280
  selected_models: List of selected model names
 
281
 
282
  Returns:
283
  Updated Gradio Dropdown component
284
  """
285
  common = get_common_categories(selected_models)
286
  if common:
 
 
 
287
  return gr.Dropdown(choices=common, value=common[0])
 
 
 
288
  return gr.Dropdown(choices=MVTEC_CATEGORIES, value="bottle")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  return list(common) if common else MVTEC_CATEGORIES
257
 
258
 
259
+ def update_categories(model_name: str, current_category: str = None):
260
  """
261
  Updates available categories based on selected model.
262
+ Keeps the current category if it's available for the new model.
263
 
264
  Args:
265
  model_name: Selected model name
266
+ current_category: Currently selected category to preserve if possible
267
 
268
  Returns:
269
  Updated Gradio Dropdown component
270
  """
271
  trained = get_trained_categories(model_name)
272
  if trained:
273
+ # Keep current category if it's available in the new model
274
+ if current_category and current_category in trained:
275
+ return gr.Dropdown(choices=trained, value=current_category)
276
  return gr.Dropdown(choices=trained, value=trained[0])
277
+ # Keep current category if using all categories
278
+ if current_category and current_category in MVTEC_CATEGORIES:
279
+ return gr.Dropdown(choices=MVTEC_CATEGORIES, value=current_category)
280
  return gr.Dropdown(choices=MVTEC_CATEGORIES, value="bottle")
281
 
282
 
283
+ def update_compare_categories(selected_models: list, current_category: str = None):
284
  """
285
  Update categories dropdown based on selected models.
286
+ Keeps the current category if it's available for all selected models.
287
 
288
  Args:
289
  selected_models: List of selected model names
290
+ current_category: Currently selected category to preserve if possible
291
 
292
  Returns:
293
  Updated Gradio Dropdown component
294
  """
295
  common = get_common_categories(selected_models)
296
  if common:
297
+ # Keep current category if it's in common categories
298
+ if current_category and current_category in common:
299
+ return gr.Dropdown(choices=common, value=current_category)
300
  return gr.Dropdown(choices=common, value=common[0])
301
+ # Keep current category if using all categories
302
+ if current_category and current_category in MVTEC_CATEGORIES:
303
+ return gr.Dropdown(choices=MVTEC_CATEGORIES, value=current_category)
304
  return gr.Dropdown(choices=MVTEC_CATEGORIES, value="bottle")
305
+
306
+
307
+ def get_sample_images() -> list:
308
+ """
309
+ Returns a list of sample images from the MVTecAD test set.
310
+
311
+ Returns:
312
+ List of tuples (image_path, label) for gallery display
313
+ """
314
+ from core import DIR_DATASET
315
+
316
+ samples = []
317
+
318
+ for category in MVTEC_CATEGORIES:
319
+ test_dir = DIR_DATASET / category / "test"
320
+ if not test_dir.exists():
321
+ continue
322
+
323
+ # Get all defect types for this category
324
+ for defect_type in test_dir.iterdir():
325
+ if not defect_type.is_dir():
326
+ continue
327
+
328
+ # Get first image from each defect type
329
+ images = list(defect_type.glob("*.png"))
330
+ if images:
331
+ img_path = str(images[0])
332
+ label = f"{category}/{defect_type.name}"
333
+ samples.append((img_path, label))
334
+
335
+ return samples
336
+
337
+
338
+ def get_category_from_sample(image_path_or_label: str) -> str:
339
+ """
340
+ Extracts category from a sample image path or gallery label.
341
+
342
+ Args:
343
+ image_path_or_label: Path to the sample image or gallery label (format: category/defect_type)
344
+
345
+ Returns:
346
+ Category name extracted from the path or label
347
+ """
348
+ if image_path_or_label is None:
349
+ return "bottle"
350
+
351
+ path_str = str(image_path_or_label)
352
+
353
+ # First try: check if it's a label format "category/defect_type"
354
+ for category in MVTEC_CATEGORIES:
355
+ if path_str.startswith(f"{category}/") or path_str == category:
356
+ return category
357
+
358
+ # Second try: check if category is in the path
359
+ for category in MVTEC_CATEGORIES:
360
+ if f"/{category}/" in path_str or f"\\{category}\\" in path_str:
361
+ return category
362
+
363
+ return "bottle"
364
+
365
+
366
+ def on_sample_select(evt: gr.SelectData, current_model: str = None):
367
+ """
368
+ Handler for when a sample image is selected from the gallery.
369
+ Returns the image and updates the category.
370
+
371
+ Args:
372
+ evt: Gradio SelectData event with image info
373
+ current_model: Currently selected model (for category validation)
374
+
375
+ Returns:
376
+ Tuple of (image, category_dropdown_update)
377
+ """
378
+ if evt is None or evt.value is None:
379
+ return None, gr.Dropdown()
380
+
381
+ # Get the image path from the event
382
+ image_data = evt.value
383
+ if isinstance(image_data, dict):
384
+ image_path = image_data.get("image", {}).get("path", "")
385
+ else:
386
+ image_path = str(image_data)
387
+
388
+ # Extract category from path
389
+ category = get_category_from_sample(image_path)
390
+
391
+ # Load the image
392
+ try:
393
+ img = np.array(Image.open(image_path).convert("RGB"))
394
+ except Exception:
395
+ return None, gr.Dropdown()
396
+
397
+ # Get available categories for current model
398
+ if current_model:
399
+ trained = get_trained_categories(current_model)
400
+ if trained and category in trained:
401
+ return img, gr.Dropdown(choices=trained, value=category)
402
+ elif trained:
403
+ return img, gr.Dropdown(choices=trained, value=trained[0])
404
+
405
+ return img, gr.Dropdown(choices=MVTEC_CATEGORIES, value=category)
gradio_ui/tabs/compare.py CHANGED
@@ -7,6 +7,7 @@ Provides the side-by-side model comparison interface.
7
  import gradio as gr
8
 
9
  from gradio_ui.content import COMPARE_MODELS_INSTRUCTIONS
 
10
 
11
 
12
  def create_compare_tab(available_models: list, initial_categories: list):
@@ -67,6 +68,19 @@ def create_compare_tab(available_models: list, initial_categories: list):
67
  )
68
 
69
  compare_summary = gr.Markdown("*Select models and upload an image to compare*")
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  return {
72
  "image_input": compare_image_input,
@@ -75,4 +89,5 @@ def create_compare_tab(available_models: list, initial_categories: list):
75
  "compare_btn": compare_btn,
76
  "result_image": compare_result_image,
77
  "summary": compare_summary,
 
78
  }
 
7
  import gradio as gr
8
 
9
  from gradio_ui.content import COMPARE_MODELS_INSTRUCTIONS
10
+ from gradio_ui.handlers import get_sample_images
11
 
12
 
13
  def create_compare_tab(available_models: list, initial_categories: list):
 
68
  )
69
 
70
  compare_summary = gr.Markdown("*Select models and upload an image to compare*")
71
+
72
+ # Sample Images Gallery
73
+ gr.Markdown("### 🖼️ Sample Images (click to select)")
74
+ compare_sample_gallery = gr.Gallery(
75
+ value=get_sample_images(),
76
+ label="Sample Images",
77
+ show_label=False,
78
+ columns=8,
79
+ rows=3,
80
+ height=350,
81
+ object_fit="cover",
82
+ allow_preview=False,
83
+ )
84
 
85
  return {
86
  "image_input": compare_image_input,
 
89
  "compare_btn": compare_btn,
90
  "result_image": compare_result_image,
91
  "summary": compare_summary,
92
+ "sample_gallery": compare_sample_gallery,
93
  }
gradio_ui/tabs/draw_defects.py CHANGED
@@ -11,6 +11,7 @@ from gradio_ui.content import (
11
  BRUSH_COLORS_INFO,
12
  HEATMAP_INTERPRETATION,
13
  )
 
14
 
15
 
16
  def create_draw_defects_tab(available_models: list, default_model: str, initial_categories: list):
@@ -82,6 +83,19 @@ def create_draw_defects_tab(available_models: list, default_model: str, initial_
82
  sketch_result_text = gr.Markdown(value="", label="Results")
83
 
84
  gr.Markdown(HEATMAP_INTERPRETATION)
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  return {
87
  "image_editor": image_editor,
@@ -91,4 +105,5 @@ def create_draw_defects_tab(available_models: list, default_model: str, initial_
91
  "result_image": sketch_result_image,
92
  "result_image": sketch_result_image,
93
  "result_text": sketch_result_text,
 
94
  }
 
11
  BRUSH_COLORS_INFO,
12
  HEATMAP_INTERPRETATION,
13
  )
14
+ from gradio_ui.handlers import get_sample_images
15
 
16
 
17
  def create_draw_defects_tab(available_models: list, default_model: str, initial_categories: list):
 
83
  sketch_result_text = gr.Markdown(value="", label="Results")
84
 
85
  gr.Markdown(HEATMAP_INTERPRETATION)
86
+
87
+ # Sample Images Gallery
88
+ gr.Markdown("### 🖼️ Sample Images (click to load into editor)")
89
+ sketch_sample_gallery = gr.Gallery(
90
+ value=get_sample_images(),
91
+ label="Sample Images",
92
+ show_label=False,
93
+ columns=8,
94
+ rows=3,
95
+ height=350,
96
+ object_fit="cover",
97
+ allow_preview=False,
98
+ )
99
 
100
  return {
101
  "image_editor": image_editor,
 
105
  "result_image": sketch_result_image,
106
  "result_image": sketch_result_image,
107
  "result_text": sketch_result_text,
108
+ "sample_gallery": sketch_sample_gallery,
109
  }
gradio_ui/tabs/upload.py CHANGED
@@ -5,6 +5,7 @@ Provides the standard image upload and analysis interface.
5
  """
6
 
7
  import gradio as gr
 
8
 
9
 
10
  def create_upload_tab(available_models: list, default_model: str, initial_categories: list):
@@ -61,7 +62,20 @@ def create_upload_tab(available_models: list, default_model: str, initial_catego
61
  height=300
62
  )
63
 
64
- result_text = gr.Markdown(value="", label="Results")
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
 
67
  return {
@@ -72,4 +86,5 @@ def create_upload_tab(available_models: list, default_model: str, initial_catego
72
  "result_image": result_image,
73
  "result_image": result_image,
74
  "result_text": result_text,
 
75
  }
 
5
  """
6
 
7
  import gradio as gr
8
+ from gradio_ui.handlers import get_sample_images
9
 
10
 
11
  def create_upload_tab(available_models: list, default_model: str, initial_categories: list):
 
62
  height=300
63
  )
64
 
65
+ result_text = gr.Markdown(value="", label="Results")
66
+
67
+ # Sample Images Gallery
68
+ gr.Markdown("### 🖼️ Sample Images (click to select)")
69
+ sample_gallery = gr.Gallery(
70
+ value=get_sample_images(),
71
+ label="Sample Images",
72
+ show_label=False,
73
+ columns=8,
74
+ rows=3,
75
+ height=350,
76
+ object_fit="cover",
77
+ allow_preview=False,
78
+ )
79
 
80
 
81
  return {
 
86
  "result_image": result_image,
87
  "result_image": result_image,
88
  "result_text": result_text,
89
+ "sample_gallery": sample_gallery,
90
  }
sample_images/bottle/broken_large/000.png ADDED

Git LFS Details

  • SHA256: 11a691a06a33dd78c5fcab6a822caa48c0d72f27f660e19f5abd9b5aa392b0eb
  • Pointer size: 131 Bytes
  • Size of remote file: 526 kB
sample_images/bottle/broken_large/001.png ADDED

Git LFS Details

  • SHA256: b5e6fd5f3f9ac5310f4fecc37f64d42eaa3326d3d3b327369d2d789752189a0f
  • Pointer size: 131 Bytes
  • Size of remote file: 526 kB
sample_images/bottle/broken_small/000.png ADDED

Git LFS Details

  • SHA256: 05b96e1102fba8cc19bf60e17d33a0830247df2bbba56cae3df100336392941e
  • Pointer size: 131 Bytes
  • Size of remote file: 542 kB
sample_images/bottle/broken_small/001.png ADDED

Git LFS Details

  • SHA256: bc60260af053f2f84f71550dda6f2d88c9c8e427109a56249f0dc60e30bc9759
  • Pointer size: 131 Bytes
  • Size of remote file: 548 kB
sample_images/bottle/contamination/000.png ADDED

Git LFS Details

  • SHA256: fe2e96a8cba624ace02985481197ee8ab112d2a2faa4b79f137ace2c452eb4ea
  • Pointer size: 131 Bytes
  • Size of remote file: 529 kB
sample_images/bottle/contamination/001.png ADDED

Git LFS Details

  • SHA256: 2ddf5d0d53b2dc3d13286af69d668e9b572a360a87309bb91a4682dde8f2311a
  • Pointer size: 131 Bytes
  • Size of remote file: 539 kB
sample_images/bottle/good/000.png ADDED

Git LFS Details

  • SHA256: 9e7bfe658efe9b6db2607a96405b4ac6880936eaf93b89c85bcd311122ceb57b
  • Pointer size: 131 Bytes
  • Size of remote file: 533 kB
sample_images/cable/bent_wire/000.png ADDED

Git LFS Details

  • SHA256: 4aa2490bd1227dce17dcccba7dcd21c1297a9a858d295f114cb72c2c0f98aa06
  • Pointer size: 132 Bytes
  • Size of remote file: 1.34 MB
sample_images/cable/bent_wire/001.png ADDED

Git LFS Details

  • SHA256: 6f906f05817d54a62532add0da5f56314a5508babd5849d5a3fa571001ad1a88
  • Pointer size: 132 Bytes
  • Size of remote file: 1.34 MB
sample_images/cable/cable_swap/000.png ADDED

Git LFS Details

  • SHA256: f1a44cb231cdc1c276367f1f85561c82c5fb47b82fd87a355d8af3e631a0e212
  • Pointer size: 132 Bytes
  • Size of remote file: 1.38 MB
sample_images/cable/cable_swap/001.png ADDED

Git LFS Details

  • SHA256: 9c5b15181f9c119a1b647123cb29c40d6d3cea8eabf51875b0f3921969b3b55e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.34 MB
sample_images/cable/combined/000.png ADDED

Git LFS Details

  • SHA256: 47ed695bc2eaee856eb30ec91aa93f06eec2213b38466a2f311ac14e9af96e52
  • Pointer size: 132 Bytes
  • Size of remote file: 1.37 MB
sample_images/cable/combined/001.png ADDED

Git LFS Details

  • SHA256: 64e892cb2f119af3702948232bf7d1fc8c6d061a8e76198ede7cd1c0c1c336ae
  • Pointer size: 132 Bytes
  • Size of remote file: 1.34 MB
sample_images/cable/cut_inner_insulation/000.png ADDED

Git LFS Details

  • SHA256: d733dea95e98ac6d1a500cfb569e2b5f76f4375030817b0aba200e26aa46572f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.38 MB
sample_images/cable/cut_inner_insulation/001.png ADDED

Git LFS Details

  • SHA256: 04a079931955582c5dbf2159863bf67b7569e53f160d1299dc9b2aee8370b168
  • Pointer size: 132 Bytes
  • Size of remote file: 1.36 MB
sample_images/cable/good/000.png ADDED

Git LFS Details

  • SHA256: 89132397ea130312c961d447deb33216f14ec133c4ef62793b4ba817696e48cb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.34 MB
sample_images/capsule/crack/000.png ADDED

Git LFS Details

  • SHA256: 6462a533da731a19e4df05fc1815719b94603aee341a2ac620add75ec2334ef4
  • Pointer size: 132 Bytes
  • Size of remote file: 1.16 MB
sample_images/capsule/crack/001.png ADDED

Git LFS Details

  • SHA256: dd07c258e465acf0dc3770da851f3671fb4721df60bc460e053a95b9b21acccb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.18 MB
sample_images/capsule/faulty_imprint/000.png ADDED

Git LFS Details

  • SHA256: e43e63a51d649a3fb162ed6dfc4fffe7e4903c1eb647d0702f63dfebb413d819
  • Pointer size: 132 Bytes
  • Size of remote file: 1.15 MB
sample_images/capsule/faulty_imprint/001.png ADDED

Git LFS Details

  • SHA256: f38f91331210d596aee8e37a91d46213ef10fe5109c34c902cce30b095a22bdf
  • Pointer size: 132 Bytes
  • Size of remote file: 1.15 MB
sample_images/capsule/good/000.png ADDED

Git LFS Details

  • SHA256: 86366d544a0182b04fdeacb62c9b23af8c72af24d35eaafeb8c210f603174728
  • Pointer size: 132 Bytes
  • Size of remote file: 1.16 MB
sample_images/capsule/poke/000.png ADDED

Git LFS Details

  • SHA256: 17250f77c17c15f653c9924933e192a4e96647ed91eceb5935156bf819629be1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.17 MB
sample_images/capsule/poke/001.png ADDED

Git LFS Details

  • SHA256: 3ced8e481d7d7cc07f5f885dc7db4b5e10e3017ad193f33194f3856975d2f5b6
  • Pointer size: 132 Bytes
  • Size of remote file: 1.16 MB
sample_images/capsule/scratch/000.png ADDED

Git LFS Details

  • SHA256: f2affe78c2d06202819520c1d74a13cd4ff2467d5c6eaa52f073c2b0644f449f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.17 MB
sample_images/capsule/scratch/001.png ADDED

Git LFS Details

  • SHA256: 873e3d60c26ebf78d3da28ebeaf98cdeb9e9cd54e9e417123cd42ada9dfda00a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.16 MB
sample_images/carpet/color/000.png ADDED

Git LFS Details

  • SHA256: 12dff41957a900a38a9def83edbea55006c9190109678fc29b0d96b546ecae28
  • Pointer size: 132 Bytes
  • Size of remote file: 1.82 MB
sample_images/carpet/color/001.png ADDED

Git LFS Details

  • SHA256: 541e2d09dbc332ed74981424fb04368f65f3c58473965785832c9416d4578452
  • Pointer size: 132 Bytes
  • Size of remote file: 1.84 MB
sample_images/carpet/cut/000.png ADDED

Git LFS Details

  • SHA256: cfc42f69f8592f8b6dd17bf7a83fa71c18a7c65455a872a2c0d113f94c5b9ad0
  • Pointer size: 132 Bytes
  • Size of remote file: 1.9 MB
sample_images/carpet/cut/001.png ADDED

Git LFS Details

  • SHA256: ff79bdb335d9380ae6ca0e298cad2f2935d157e0ad32a665c16c0cf51703f116
  • Pointer size: 132 Bytes
  • Size of remote file: 1.86 MB
sample_images/carpet/good/000.png ADDED

Git LFS Details

  • SHA256: 22c6a63be1eec01601689abb9e794b69ee0aefc1addd9233c63b7e02c70dc0b5
  • Pointer size: 132 Bytes
  • Size of remote file: 1.85 MB
sample_images/carpet/hole/000.png ADDED

Git LFS Details

  • SHA256: d2740db7d12ef923a5db4ef4c5a49a4bdb7b7d4af9f4024680988bf1cc88a6da
  • Pointer size: 132 Bytes
  • Size of remote file: 1.91 MB
sample_images/carpet/hole/001.png ADDED

Git LFS Details

  • SHA256: eeb8258f8c609285cd42e1d8570c51c6e64d9efe6e3baca0de60b05fe3075624
  • Pointer size: 132 Bytes
  • Size of remote file: 1.89 MB
sample_images/carpet/metal_contamination/000.png ADDED

Git LFS Details

  • SHA256: 163002f1ec836e20ed14ac98c5a9e5b19b6f1df1d214cb986005f48500b83d5c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.86 MB
sample_images/carpet/metal_contamination/001.png ADDED

Git LFS Details

  • SHA256: 45ba93dc86d0f769cdf12e40e512bf0f40fcdafaca967efd33819027d9669f67
  • Pointer size: 132 Bytes
  • Size of remote file: 1.86 MB
sample_images/grid/bent/000.png ADDED

Git LFS Details

  • SHA256: 20a158b8868f08156ea79cabd42b1ff174b2d69adbe08b2f46737a851847e8bc
  • Pointer size: 131 Bytes
  • Size of remote file: 506 kB
sample_images/grid/bent/001.png ADDED

Git LFS Details

  • SHA256: 8bf02c2878bf55a326560b51d69890d5ab7ec038c06a4b6b817539db4178b0dc
  • Pointer size: 131 Bytes
  • Size of remote file: 464 kB
sample_images/grid/broken/000.png ADDED

Git LFS Details

  • SHA256: 9f0f649d7120425428025badaa7373f46bd33e3d79f3138dfc23183bc54da4cd
  • Pointer size: 131 Bytes
  • Size of remote file: 502 kB
sample_images/grid/broken/001.png ADDED

Git LFS Details

  • SHA256: 4dfa36e10e1f8a239c124019a0b9632fe8d77573fdc0b823dcd2da0ac88d294f
  • Pointer size: 131 Bytes
  • Size of remote file: 485 kB
sample_images/grid/glue/000.png ADDED

Git LFS Details

  • SHA256: cf8ca000f9d176bbf3b8cddf6cc78f4b10db02e2d0ea8537378f705e322fd370
  • Pointer size: 131 Bytes
  • Size of remote file: 492 kB
sample_images/grid/glue/001.png ADDED

Git LFS Details

  • SHA256: 0d08739627606e54a18d4029a67e6c905f71b0331b13af025b094bb0e411b229
  • Pointer size: 131 Bytes
  • Size of remote file: 493 kB
sample_images/grid/good/000.png ADDED

Git LFS Details

  • SHA256: 4b5d0ff80b6b5a8444d795c4823b46d32df1900e83e107205ed7b1b3538b62ce
  • Pointer size: 131 Bytes
  • Size of remote file: 470 kB
sample_images/grid/metal_contamination/000.png ADDED

Git LFS Details

  • SHA256: e1637827bf7a6ec05e416992d1c2f89d9e57a67afbcbc32b4313a7bdeda76d49
  • Pointer size: 131 Bytes
  • Size of remote file: 459 kB
sample_images/grid/metal_contamination/001.png ADDED

Git LFS Details

  • SHA256: 99165e114bd59f9789644ee4ac2b2116bf2f971c0328e8c71bd21db2d93d864a
  • Pointer size: 131 Bytes
  • Size of remote file: 453 kB
sample_images/hazelnut/crack/000.png ADDED

Git LFS Details

  • SHA256: e26b54282b6b11286760905ca2880af594561b606dfa0643859d6ee6027cf8c2
  • Pointer size: 132 Bytes
  • Size of remote file: 1.28 MB
sample_images/hazelnut/crack/001.png ADDED

Git LFS Details

  • SHA256: 3657bc7f6776c1792dce241e76d3bd760bd780b026bf2e4f5c1d80ac102aa487
  • Pointer size: 132 Bytes
  • Size of remote file: 1.27 MB