| from huggingface_hub import from_pretrained_fastai |
| import gradio as gr |
| from fastai.vision.all import * |
|
|
| repo_id = "paascorb/image-detection-efficientdet" |
|
|
| learner = from_pretrained_fastai(repo_id) |
| labels = learner.dls.vocab |
|
|
| |
| def predict(img): |
| img = PIL.Image.open('mapaches/test/images/raccoon-190.jpg') |
| 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"] |
| |
| |
| gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(128, 128)), outputs=gr.outputs.Image(shape(128,128)),examples=['buildings.jpg','forest.jpg']).launch(share=False) |