mallku2000 commited on
Commit
bd8fad9
verified
1 Parent(s): 1f0a7f2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import load_learner, PILImage
3
+
4
+ # Meto el modelo
5
+ learn = load_learner('model.pkl')
6
+ labels = learn.dls.vocab
7
+
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ pred, pred_idx, probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
+
13
+ # Ponemos titulo y descripci贸n
14
+ gr.Interface(
15
+ fn=predict,
16
+ inputs=gr.Image(),
17
+ outputs=gr.Label(num_top_classes=2),
18
+ title="Classifier",
19
+ description="Human vs Monkey").launch()