JuanSv commited on
Commit
b2baf3f
·
verified ·
1 Parent(s): 93a2a0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -19
app.py CHANGED
@@ -1,24 +1,20 @@
1
  from fastai.vision.all import *
2
  import gradio as gr
3
- from pathlib import Path
4
 
5
-
6
- # drive.mount('/content/drive') # normalmente NO se monta en Hugging Face, solo local
7
-
8
- # Rutas relativas al espacio
9
- path = Path(".") # aquí se suben las carpetas de clases
10
-
11
- dls = ImageDataLoaders.from_folder(
12
- path,
13
- valid_pct=0.2,
14
- seed=42,
15
- item_tfms=Resize(224)
16
- )
17
-
18
- learn = vision_learner(dls, resnet34)
19
- learn.load("model_lab")
20
-
21
- labels = learn.dls.vocab
22
 
23
  def predict(img):
24
  img = PILImage.create(img)
@@ -32,4 +28,4 @@ demo = gr.Interface(
32
  title="Lab Utensils Classifier"
33
  )
34
 
35
- demo.launch()
 
1
  from fastai.vision.all import *
2
  import gradio as gr
 
3
 
4
+ # Definir las clases que usaste para entrenar el modelo
5
+ labels = [
6
+ "Vaso de precipitados",
7
+ "Tubos de ensayo",
8
+ "Matraz",
9
+ "Portaobjetos/Cubreobjetos",
10
+ "pipeta",
11
+ "Placa petri",
12
+ "No es un utensilio de laboratorio"
13
+ ]
14
+
15
+ # Cargar el modelo directamente (debe estar en la misma carpeta o en models/)
16
+ learn = vision_learner(dls=None, arch=resnet34) # dls=None porque no hay dataset
17
+ learn.load("model_lab") # si lo pusiste en models/, usa "models/model_lab"
 
 
 
18
 
19
  def predict(img):
20
  img = PILImage.create(img)
 
28
  title="Lab Utensils Classifier"
29
  )
30
 
31
+ demo.launch()