mandaaarina commited on
Commit
2c1fca2
verified
1 Parent(s): fb7c9e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -1,7 +1,29 @@
1
- import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import load_learner, PILImage
2
+
3
+ # Cargar el modelo utilizando load_learner
4
 
5
+ learn = load_learner('model.pkl')
 
6
 
7
+ labels = learn.dls.vocab
8
+
9
+ def predict(img):
10
+
11
+ img = PILImage.create(img)
12
+
13
+ pred, pred_idx, probs = learn.predict(img)
14
+
15
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
16
+
17
+ # Crear la interfaz con t铆tulo y descripci贸n
18
+
19
+ gr.Interface(
20
+
21
+ fn=predict,
22
+
23
+ inputs=gr.Image(),
24
+
25
+ outputs=gr.Label(num_top_classes=3),
26
+
27
+ title="Brain and fruits classifier"",
28
+
29
+ description="This model identifies between real brains, prunes and walnuts in images.".launch()