Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -197,11 +197,14 @@ def predict_beetle(img):
|
|
| 197 |
|
| 198 |
# Sample images with labels
|
| 199 |
example_images = [
|
| 200 |
-
[os.path.join(
|
| 201 |
-
[os.path.join(
|
| 202 |
-
[os.path.join(
|
| 203 |
-
[os.path.join(
|
|
|
|
| 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
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|