JuanSv commited on
Commit
047e603
·
verified ·
1 Parent(s): b75e6ad

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -44
app.py DELETED
@@ -1,44 +0,0 @@
1
- from fastai.vision.all import *
2
- import gradio as gr
3
- from pathlib import Path
4
- import zipfile
5
- import os
6
-
7
- # Extraer zip
8
- with zipfile.ZipFile("dataset.zip", 'r') as zip_ref:
9
- zip_ref.extractall(".") # crea dataset/
10
-
11
- # Asegurarse de que existe la carpeta correcta
12
- dataset_path = Path("dataset")
13
- if not dataset_path.exists():
14
- raise FileNotFoundError("La carpeta 'dataset' no existe después de descomprimir el zip. Revisa la estructura del zip.")
15
-
16
- # Crear DataLoaders
17
- dls = ImageDataLoaders.from_folder(
18
- dataset_path,
19
- valid_pct=0.2,
20
- seed=42,
21
- item_tfms=Resize(224)
22
- )
23
-
24
- # Cargar modelo
25
- learn = vision_learner(dls, resnet34)
26
- learn.load("model_lab")
27
-
28
- labels = learn.dls.vocab
29
-
30
- def predict(img):
31
- img = PILImage.create(img)
32
- _, _, probs = learn.predict(img)
33
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
34
-
35
- demo = gr.Interface(
36
- fn=predict,
37
- inputs=gr.Image(type="filepath"),
38
- outputs=gr.Label(num_top_classes=3),
39
- title="Lab Utensils Classifier"
40
- )
41
-
42
- demo.launch()
43
-
44
-