Joao Henrique commited on
Commit
b2417b8
·
1 Parent(s): 93f2b26

Initial project, with examples.

Browse files
Files changed (5) hide show
  1. app.py +21 -0
  2. avocado.png +0 -0
  3. hand.png +0 -0
  4. model.pkl +3 -0
  5. papaya.png +0 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner('model.pkl')
5
+
6
+ labels = learn.dls.vocab
7
+ examples = ['avocado.png', 'hand.png', 'papaya.png']
8
+
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred, pred_idx, probs = learn.predict(img)
13
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
+
15
+
16
+ gr.Interface(fn=predict,
17
+ inputs=gr.components.Image(shape=(512, 512)),
18
+ outputs=gr.components.Label(num_top_classes=3),
19
+ examples=examples
20
+ ).launch(share=True)
21
+
avocado.png ADDED
hand.png ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b69c9c0784463ce2720c6465b6d6a4c5fe8aea5d52fa1f2bd6edb809e7a15ed0
3
+ size 46958105
papaya.png ADDED