Spaces:
Runtime error
Runtime error
Commit
·
be551bc
1
Parent(s):
6b08fd9
use Examples helper component to load examples
Browse files
app.py
CHANGED
|
@@ -3,13 +3,10 @@ from utils.predict import predict, predict_batch
|
|
| 3 |
import os
|
| 4 |
import glob
|
| 5 |
|
| 6 |
-
##Create
|
| 7 |
example_list = glob.glob("examples/set2/*")
|
| 8 |
example_list = list(map(lambda el:[el], example_list))
|
| 9 |
|
| 10 |
-
def load_example(image):
|
| 11 |
-
return image[0]
|
| 12 |
-
|
| 13 |
demo = gr.Blocks()
|
| 14 |
|
| 15 |
with demo:
|
|
@@ -53,12 +50,8 @@ with demo:
|
|
| 53 |
gr.Markdown("**Examples:**")
|
| 54 |
gr.Markdown("The model is trained to classify images belonging to the following classes:")
|
| 55 |
|
| 56 |
-
# with gr.Column():
|
| 57 |
-
# gr.Examples("examples/set2", [input_image], output_label, predict, cache_examples=True)
|
| 58 |
-
|
| 59 |
with gr.Column():
|
| 60 |
-
|
| 61 |
-
examples.click(load_example, examples, input_image)
|
| 62 |
|
| 63 |
|
| 64 |
compute_button.click(predict_batch, inputs=input_image, outputs=[output_plot,output_df])
|
|
|
|
| 3 |
import os
|
| 4 |
import glob
|
| 5 |
|
| 6 |
+
##Create list of examples to be loaded
|
| 7 |
example_list = glob.glob("examples/set2/*")
|
| 8 |
example_list = list(map(lambda el:[el], example_list))
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
demo = gr.Blocks()
|
| 11 |
|
| 12 |
with demo:
|
|
|
|
| 50 |
gr.Markdown("**Examples:**")
|
| 51 |
gr.Markdown("The model is trained to classify images belonging to the following classes:")
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
with gr.Column():
|
| 54 |
+
gr.Examples(examples_list, [input_image], output_label, predict, cache_examples=True)
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
compute_button.click(predict_batch, inputs=input_image, outputs=[output_plot,output_df])
|