Spaces:
Runtime error
Runtime error
Renombrado modelo a v1 para forzar subida limpia LFS
Browse files- .gitattributes +1 -0
- app.py +5 -18
- modelo_v1.pkl +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
modelo_v1.pkl filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -1,23 +1,20 @@
|
|
| 1 |
|
| 2 |
from fastai.vision.all import *
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
-
# 1. Definiciones de placeholders para que coincidan con el export
|
| 6 |
def get_x(i): return None
|
| 7 |
def get_y(i): return None
|
| 8 |
|
| 9 |
-
# Forzar la visibilidad en el módulo principal para el unpickler
|
| 10 |
-
import __main__
|
| 11 |
__main__.get_x = get_x
|
| 12 |
__main__.get_y = get_y
|
| 13 |
|
| 14 |
-
# 2. Carga del modelo
|
| 15 |
-
# Si falla aquí, el problema es que el archivo .pkl está corrupto o mal subido con LFS
|
| 16 |
try:
|
| 17 |
-
|
|
|
|
| 18 |
labels = learn.dls.vocab
|
| 19 |
except Exception as e:
|
| 20 |
-
print(f"Error
|
| 21 |
raise e
|
| 22 |
|
| 23 |
def predict(img):
|
|
@@ -25,14 +22,4 @@ def predict(img):
|
|
| 25 |
pred, pred_idx, probs = learn.predict(img)
|
| 26 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 27 |
|
| 28 |
-
|
| 29 |
-
title = "Detector de Tipos Pokémon"
|
| 30 |
-
description = "Sube una imagen para identificar el tipo elemental del Pokémon."
|
| 31 |
-
|
| 32 |
-
gr.Interface(
|
| 33 |
-
fn=predict,
|
| 34 |
-
inputs=gr.Image(),
|
| 35 |
-
outputs=gr.Label(num_top_classes=3),
|
| 36 |
-
title=title,
|
| 37 |
-
description=description
|
| 38 |
-
).launch()
|
|
|
|
| 1 |
|
| 2 |
from fastai.vision.all import *
|
| 3 |
import gradio as gr
|
| 4 |
+
import __main__
|
| 5 |
|
|
|
|
| 6 |
def get_x(i): return None
|
| 7 |
def get_y(i): return None
|
| 8 |
|
|
|
|
|
|
|
| 9 |
__main__.get_x = get_x
|
| 10 |
__main__.get_y = get_y
|
| 11 |
|
|
|
|
|
|
|
| 12 |
try:
|
| 13 |
+
# Intentamos cargar con el nuevo nombre
|
| 14 |
+
learn = load_learner('modelo_v1.pkl')
|
| 15 |
labels = learn.dls.vocab
|
| 16 |
except Exception as e:
|
| 17 |
+
print(f"Error crítico: {e}")
|
| 18 |
raise e
|
| 19 |
|
| 20 |
def predict(img):
|
|
|
|
| 22 |
pred, pred_idx, probs = learn.predict(img)
|
| 23 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 24 |
|
| 25 |
+
gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3)).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modelo_v1.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:16c39ba669a073d6cc68df14dccf47b5dd773fd7a85dabbfa0f67291637376ec
|
| 3 |
+
size 115047525
|