Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
from huggingface_hub import from_pretrained_fastai
|
| 4 |
+
modelo = from_pretrained_fastai("pagaliv/futurama-character-classifier")
|
| 5 |
|
| 6 |
+
def clasificar_imagen(img):
|
| 7 |
+
pred, _, prob = modelo.predict(img)
|
| 8 |
+
return {modelo.dls.vocab[i]: float(prob[i]) for i in range(len(prob))}
|
| 9 |
|
| 10 |
+
# Interfaz
|
| 11 |
+
iface = gr.Interface(
|
| 12 |
+
fn=clasificar_imagen,
|
| 13 |
+
inputs=gr.Image(type="pil"),
|
| 14 |
+
outputs=gr.Label(num_top_classes=3),
|
| 15 |
+
examples=["BENDER.jpg","BENDER2.jpg", "FRY.jpg","FRY2.jpg","LEELA.jpg","LEELA2.jpg"], # Aseg煤rate de subir estos archivos
|
| 16 |
+
title="Clasificador de Futurama"
|
| 17 |
+
)
|
| 18 |
|
| 19 |
+
iface.launch()
|