File size: 839 Bytes
a2b702a 5cdd622 f71bd31 d9238a9 a2b702a 7cdd8e4 a2b702a f71bd31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.vision.all import *
from icevision.all import *
import PIL
repo_id = "paascorb/image-detection-efficientdet"
learner = from_pretrained_fastai(repo_id)
# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(img):
img = PIL.Image.open(img)
infer_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(size),tfms.A.Normalize()])
pred_dict = models.ross.efficientdet.end2end_detect(img, infer_tfms, model.to("cpu"), class_map=class_map, detection_threshold=0.5)
return pred_dict["img"]
# Creamos la interfaz y la lanzamos.
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(128, 128)), outputs=gr.outputs.Image(shape(128,128)),
examples=['raccoon-161.jpg','raccoon-162.jpg']).launch(share=False) |