Spaces:
Runtime error
Runtime error
Commit
·
85c68e5
1
Parent(s):
34c6949
updated examples loading
Browse files
app.py
CHANGED
@@ -1,21 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
from utils.predict import predict, predict_batch
|
3 |
import os
|
4 |
-
|
5 |
inputs_list = []
|
6 |
|
7 |
|
8 |
demo = gr.Blocks()
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
# sample_image = gr.Image(type='filepath')
|
13 |
-
# examples = gr.components.Dataset(components=[sample_image], samples=[sample_1, sample_2], type='values')
|
14 |
-
# with gr.Column():
|
15 |
-
# examples.render()
|
16 |
-
# examples.click(load_example, examples, input_images)
|
17 |
-
# def load_example(image):
|
18 |
-
# return image[0]
|
19 |
|
20 |
with demo:
|
21 |
|
@@ -58,8 +55,12 @@ with demo:
|
|
58 |
gr.Markdown("**Examples:**")
|
59 |
gr.Markdown("The model is trained to classify images belonging to the following classes:")
|
60 |
|
|
|
|
|
|
|
61 |
with gr.Column():
|
62 |
-
|
|
|
63 |
|
64 |
|
65 |
compute_button.click(predict_batch, inputs=input_image, outputs=[output_plot,output_df])
|
|
|
1 |
import gradio as gr
|
2 |
from utils.predict import predict, predict_batch
|
3 |
import os
|
4 |
+
import glob
|
5 |
inputs_list = []
|
6 |
|
7 |
|
8 |
demo = gr.Blocks()
|
9 |
+
example_list = glob.glob("examples/set2/*")
|
10 |
+
example_list = list(map(lambda el:[el], example_list))
|
11 |
+
sample_image = gr.Image(type='filepath')
|
12 |
+
examples = gr.components.Dataset(components=[sample_image], samples=example_list, type='values')
|
13 |
|
14 |
+
def load_example(image):
|
15 |
+
return image[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
with demo:
|
18 |
|
|
|
55 |
gr.Markdown("**Examples:**")
|
56 |
gr.Markdown("The model is trained to classify images belonging to the following classes:")
|
57 |
|
58 |
+
# with gr.Column():
|
59 |
+
# gr.Examples("examples/set2", [input_image], output_label, predict, cache_examples=True)
|
60 |
+
|
61 |
with gr.Column():
|
62 |
+
examples.render()
|
63 |
+
examples.click(load_example, examples, input_image)
|
64 |
|
65 |
|
66 |
compute_button.click(predict_batch, inputs=input_image, outputs=[output_plot,output_df])
|