File size: 619 Bytes
27bfbc7
 
 
f4929d8
 
27bfbc7
 
 
 
 
f4929d8
 
 
27bfbc7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from icevision.all import *
import gradio as gr

state_dict = roch.load('fasterRCNNKangaroo.pth')
model.load_state_dict(state_dict)

labels = learn.dls.vocab

def predict(img):
   img = PILImage.create(img)
   infer_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(size),tfms.A.Normalize()])
   pred_dict = models.torchvision.faster_rcnn.end2end_detect(img, infer_tfms, model.to("cpu"), class_map=class_map, detection_threshold=0.5)
   return pred_dict
   
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(128,128)), outputs=gr.outputs.Label(num_top_classes=3),examples=['00001.jpg','00002.jpg']).launch(share=False)