Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,13 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
-
import torch
|
| 4 |
-
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
def predict(img: Image.Image):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
outputs = model(**inputs)
|
| 13 |
-
probs = torch.nn.functional.softmax(outputs.logits, dim=1)[0]
|
| 14 |
-
labels = model.config.id2label
|
| 15 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 16 |
|
| 17 |
demo = gr.Interface(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
from PIL import Image
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# Cargar modelo exportado desde Hugging Face
|
| 6 |
+
learn = load_learner("https://huggingface.co/AdrianRevi/Practica1Blindness/model.pkl")
|
| 7 |
|
| 8 |
def predict(img: Image.Image):
|
| 9 |
+
pred_class, pred_idx, probs = learn.predict(img)
|
| 10 |
+
labels = learn.dls.vocab
|
|
|
|
|
|
|
|
|
|
| 11 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
|
| 13 |
demo = gr.Interface(
|