Spaces:
Sleeping
Sleeping
valentinrack
commited on
Commit
•
0370b84
1
Parent(s):
7263635
Upload 3 files
Browse files- app.py.py +37 -0
- requirements.txt.txt +1 -0
- snail_learner_1_2.pkl +3 -0
app.py.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1h6riFrXG5PjYEq3Lj4OM0z3NPXmroaWI
|
8 |
+
"""
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
from fastai.vision.all import *
|
12 |
+
|
13 |
+
snail_learner = load_learner('snail_learner_1_2.pkl')
|
14 |
+
|
15 |
+
labels = snail_learner.dls.vocab
|
16 |
+
def predict(img):
|
17 |
+
img = PILImage.create(img)
|
18 |
+
pred,pred_idx,probs = snail_learner .predict(img)
|
19 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
20 |
+
|
21 |
+
title = "Snail or Garden?"
|
22 |
+
description = "A snail classifier trained on internet images with fastai and validated in local garden snails pictures."
|
23 |
+
article="<p style='text-align: center'><a href='https://valentinrac.com' target='_blank'>Valentin website</a></p>"
|
24 |
+
examples = ['snail1.jpg', 'snail2.jpg','slug.jpg','snail93.jpg','snail4.jpg','snail91.jpg','snail_slug2.jpg']
|
25 |
+
|
26 |
+
iface = gr.Interface(
|
27 |
+
fn=predict,
|
28 |
+
inputs=gr.Image(),
|
29 |
+
outputs=gr.Label(),
|
30 |
+
live=True,
|
31 |
+
title=title,
|
32 |
+
description=description,
|
33 |
+
article=article,
|
34 |
+
examples=examples,
|
35 |
+
)
|
36 |
+
|
37 |
+
iface.launch(share=True)
|
requirements.txt.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|
snail_learner_1_2.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66e4a1138d5485b598d62a887e1aae7eb4a45dc5b8a80907924e9f0834fa3639
|
3 |
+
size 46972362
|