Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
from icevision.all import *
|
| 2 |
-
from fastai.vision.all import *
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
labels = learn.dls.vocab
|
| 8 |
|
| 9 |
def predict(img):
|
| 10 |
img = PILImage.create(img)
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
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)
|
|
|
|
| 1 |
from icevision.all import *
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
state_dict = roch.load('fasterRCNNKangaroo.pth')
|
| 5 |
+
model.load_state_dict(state_dict)
|
| 6 |
|
| 7 |
labels = learn.dls.vocab
|
| 8 |
|
| 9 |
def predict(img):
|
| 10 |
img = PILImage.create(img)
|
| 11 |
+
infer_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(size),tfms.A.Normalize()])
|
| 12 |
+
pred_dict = models.torchvision.faster_rcnn.end2end_detect(img, infer_tfms, model.to("cpu"), class_map=class_map, detection_threshold=0.5)
|
| 13 |
+
return pred_dict
|
| 14 |
|
| 15 |
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)
|