inzenarr commited on
Commit
91dfbfa
·
verified ·
1 Parent(s): ad03401

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner("model.pkl")
5
+
6
+ categorias = learn.dls.vocab
7
+
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ pred, pred_idx, probs = learn.predict(img)
11
+ return dict(zip(categorias, map(float, probs)))
12
+
13
+ # Interfaz de Gradio
14
+ titulo = "Clasificador de Vehículos - Entregable 2"
15
+ descripcion = "Detector de vehículos (Bikes, Cars, Cabs, etc.) entrenado con FastAI."
16
+
17
+ interface = gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.Image(),
20
+ outputs=gr.Label(num_top_classes=3),
21
+ title=titulo,
22
+ description=descripcion,
23
+ examples=["Bike (104).jpg", "Car (100).jpg"]
24
+ )
25
+
26
+ interface.launch()