mycatdetector / app.py
jpablolastra's picture
Updated model
bdb2d41
raw
history blame
1.27 kB
import gradio as gr
from fastai.vision.all import *
import skimage
learn = load_learner('model_ori_gateto.pkl')
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
title = "Mi detector de gatos / My Cat Detector"
description = "Un modelo de prueba para aprender, siguiendo las instrucciones de la lección 2 del curso de fast.ai. El modelo detecta si la foto es de uno de mis dos gatos. / A test model to learn, following the instructions in lesson 2 of the fast.ai course. The model detects if the picture is one of my two cats."
article="<p style='text-align: center'><a href='https://papagame.dev/2023/09/mi-detector-de-gatos.html' target='_blank'>Artículo en PapaGameDev</a></p><p style='text-align: center'><a href='https://papagame.dev/2023/09/my-cat-detector.html' target='_blank'>PapaGameDev Blog Post</a></p>"
examples = ['ori.jpg']
interpretation='default'
enable_queue=True
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()