Spaces:
Sleeping
Sleeping
Navarro Mart铆nez
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
# Carga tu modelo
|
5 |
+
learn = load_learner("clasificar_enemigos_BOTW.pkl") # Reemplaza con la ruta a tu modelo
|
6 |
+
|
7 |
+
# Define la funci贸n de predicci贸n
|
8 |
+
def predict(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred, pred_idx, probs = learn.predict(img)
|
11 |
+
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(learn.dls.vocab))}
|
12 |
+
|
13 |
+
# Crea la interfaz de Gradio
|
14 |
+
gr.Interface(
|
15 |
+
fn=predict,
|
16 |
+
inputs=gr.Image(),
|
17 |
+
outputs=gr.Label(num_top_classes=2),
|
18 |
+
title="Clasificador de Enemigos de BOTW",
|
19 |
+
description="Sube una imagen de un enemigo de BOTW para clasificarlo."
|
20 |
+
).launch()
|