Spaces:
Build error
Build error
Download app.py from vncgabriel/Practica1: direct link, hf CLI and curl.
- Browser
- Download file 659 Bytes
-
https://huggingface.co/spaces/vncgabriel/Practica1/resolve/main/app.py
- Command line
-
hf download hf://spaces/vncgabriel/Practica1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/vncgabriel/Practica1/resolve/main/app.py
659 Bytes
| from huggingface_hub import from_pretrained_fastai | |
| import gradio as gr | |
| from fastai.vision.all import * | |
| # Carregar modelo do Hugging Face | |
| repo_id = "vncgabriel/viniciusdias" | |
| learner = from_pretrained_fastai(repo_id) | |
| labels = learner.dls.vocab | |
| # Função de predição | |
| def predict(img): | |
| pred, pred_idx, probs = learner.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| # Criar a interface Gradio | |
| gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(), # 🔴 Removido `shape=(128, 128)` | |
| outputs=gr.Label(num_top_classes=3), | |
| examples=['person78_bacteria_387.jpeg', 'person82_bacteria_404.jpeg'] | |
| ).launch(share=False) | |