JuanSv commited on
Commit
cf62a42
·
verified ·
1 Parent(s): 9b8c003

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +23 -0
  2. model.pkl +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import load_learner, PILImage
2
+ import gradio as gr
3
+
4
+ # Cargar el modelo
5
+ learn = load_learner("model.pkl")
6
+ labels = learn.dls.vocab
7
+
8
+ # Función de predicción
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ # Crear la interfaz Gradio
15
+ demo = gr.Interface(
16
+ fn=predict,
17
+ inputs=gr.Image(type="filepath"),
18
+ outputs=gr.Label(num_top_classes=3),
19
+ title="Lab Utensils Classifier",
20
+ description="Clasificador de utensilios de laboratorio"
21
+ )
22
+
23
+ demo.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:238bfcac0da7d963859f72f83cbc2791b0e5a7f8ae8bcec8a3dbf53da3f70ecc
3
+ size 14547195
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastai
2
+ gradio
3
+ torch
4
+ timm