|
|
import gradio as gr |
|
|
from fastai.vision.all import * |
|
|
import os |
|
|
from huggingface_hub import hf_hub_download |
|
|
|
|
|
|
|
|
repo_id = "mohadrk/Practica1" |
|
|
model_filename = "model.pkl" |
|
|
|
|
|
|
|
|
model_path = hf_hub_download(repo_id=repo_id, filename=model_filename) |
|
|
|
|
|
|
|
|
learn = load_learner(model_path) |
|
|
|
|
|
|
|
|
def predict(image): |
|
|
pred, pred_idx, probs = learn.predict(image) |
|
|
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(learn.dls.vocab))} |
|
|
|
|
|
|
|
|
interface = gr.Interface( |
|
|
fn=predict, |
|
|
inputs=gr.Image(type="pil"), |
|
|
outputs=gr.Label(), |
|
|
title="Clasificador de Tabaco", |
|
|
description="Sube una imagen y el modelo la clasificar谩 en una categor铆a espec铆fica." |
|
|
) |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
interface.launch() |
|
|
|