Spaces:
Runtime error
Runtime error
Subiendo modelo y app de Pokémon
Browse files
app.py
CHANGED
|
@@ -2,9 +2,14 @@
|
|
| 2 |
from fastai.vision.all import *
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
defaults.silent = True
|
| 7 |
|
|
|
|
| 8 |
learn = load_learner('modelo_pokemon.pkl')
|
| 9 |
categories = learn.dls.vocab
|
| 10 |
|
|
@@ -13,6 +18,7 @@ def predict(img):
|
|
| 13 |
pred, pred_idx, probs = learn.predict(img)
|
| 14 |
return {categories[i]: float(probs[i]) for i in range(len(categories))}
|
| 15 |
|
|
|
|
| 16 |
interface = gr.Interface(
|
| 17 |
fn=predict,
|
| 18 |
inputs=gr.Image(),
|
|
|
|
| 2 |
from fastai.vision.all import *
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
# 1. Definir funciones que el modelo necesita (obligatorio para load_learner)
|
| 6 |
+
def get_x(i): return None # Solo necesitamos que existan
|
| 7 |
+
def get_y(i): return None
|
| 8 |
+
|
| 9 |
+
# 2. Configuración de entorno
|
| 10 |
defaults.silent = True
|
| 11 |
|
| 12 |
+
# 3. Cargar el modelo (ahora encontrará get_x y get_y)
|
| 13 |
learn = load_learner('modelo_pokemon.pkl')
|
| 14 |
categories = learn.dls.vocab
|
| 15 |
|
|
|
|
| 18 |
pred, pred_idx, probs = learn.predict(img)
|
| 19 |
return {categories[i]: float(probs[i]) for i in range(len(categories))}
|
| 20 |
|
| 21 |
+
# 4. Interfaz
|
| 22 |
interface = gr.Interface(
|
| 23 |
fn=predict,
|
| 24 |
inputs=gr.Image(),
|