ChristopherMarais commited on
Commit
c36c96f
·
verified ·
1 Parent(s): 0adf70d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -197,11 +197,14 @@ def predict_beetle(img):
197
 
198
  # Sample images with labels
199
  example_images = [
200
- [os.path.join("example_images", "example1.jpg"), "Example Beetles 1"],
201
- [os.path.join("example_images", "example2.jpg"), "Example Beetles 2"],
202
- [os.path.join("example_images", "example3.jpg"), "Example Beetles 3"],
203
- [os.path.join("example_images", "mixed.jpg"), "Example Beetles Mixed"],
 
204
  ]
 
 
205
 
206
  with gr.Blocks() as demo: # css=css in the brackets
207
  gr.Markdown("<h1><center>Bark Beetle Classification<h1><center>")
@@ -215,8 +218,13 @@ with gr.Blocks() as demo: # css=css in the brackets
215
  # Set the gallery layout and height directly in the constructor
216
  gallery = gr.Gallery(label="Show images", show_label=True, elem_id="gallery", columns=8, height="auto")
217
 
218
- # Add examples for easy access
219
- demo.examples = example_images
 
 
 
 
 
220
 
221
  btn.click(predict_beetle, inputs, gallery)
222
  demo.launch(debug=True, show_error=True)
 
197
 
198
  # Sample images with labels
199
  example_images = [
200
+ [os.path.join(sample_images_dir, "example1.jpg")],
201
+ [os.path.join(sample_images_dir, "example2.jpg")],
202
+ [os.path.join(sample_images_dir, "example3.jpg")],
203
+ [os.path.join(sample_images_dir, "mixed.jpg")]
204
+
205
  ]
206
+ # Corresponding labels for the example images
207
+ example_labels = ["Example Beetle 1", "Example Beetle 2", "Example Beetle 3", "Example Beetles Mixed"]
208
 
209
  with gr.Blocks() as demo: # css=css in the brackets
210
  gr.Markdown("<h1><center>Bark Beetle Classification<h1><center>")
 
218
  # Set the gallery layout and height directly in the constructor
219
  gallery = gr.Gallery(label="Show images", show_label=True, elem_id="gallery", columns=8, height="auto")
220
 
221
+ # Add examples with labels
222
+ gr.Examples(
223
+ examples=example_images,
224
+ inputs=inputs,
225
+ examples_per_page=3,
226
+ example_labels=example_labels
227
+ )
228
 
229
  btn.click(predict_beetle, inputs, gallery)
230
  demo.launch(debug=True, show_error=True)