Spaces:
Sleeping
Sleeping
Commit
·
1eafe63
1
Parent(s):
eeffac2
Autogenerate Gradio interface for Toad Frog model prediction
Browse files
app.py
CHANGED
@@ -1,7 +1,26 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
iface.launch()
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../toad_frog_testing.ipynb.
|
2 |
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['toad_frog_model', 'categories', 'image', 'label', 'examples', 'gradio_interface', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../toad_frog_testing.ipynb 2
|
7 |
+
!pip install -Uqq fastai
|
8 |
+
|
9 |
+
# %% ../toad_frog_testing.ipynb 7
|
10 |
+
toad_frog_model = load_learner("toadfrog.pkl")
|
11 |
+
|
12 |
+
# %% ../toad_frog_testing.ipynb 11
|
13 |
+
categories = ('Frog', 'Toad')
|
14 |
+
|
15 |
+
def classify_image(img_path: str):
|
16 |
+
prediction, index, probabilities = toad_frog_model.predict(img_path)
|
17 |
+
return dict(zip(categories, map(float, probabilities)))
|
18 |
+
|
19 |
+
# %% ../toad_frog_testing.ipynb 14
|
20 |
+
image = gr.inputs.Image(shape=(192,192))
|
21 |
+
label = gr.outputs.Label()
|
22 |
+
examples = ["sample_toad.jpg", "sample_frog.jpg"]
|
23 |
+
|
24 |
+
gradio_interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
25 |
+
gradio_interface.launch(inline=False)
|
26 |
|
|
|
|