josedolot commited on
Commit
17107d7
·
1 Parent(s): 9c64bf0

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -48
app.py DELETED
@@ -1,48 +0,0 @@
1
- import os
2
- from PIL import Image
3
- import torch
4
- from torchvision import transforms
5
- import gradio as gr
6
-
7
-
8
- # load model
9
- model = torch.hub.load('datvuthanh/hybridnets', 'hybridnets', pretrained=True)
10
-
11
-
12
- normalize = transforms.Normalize(
13
- mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]
14
- )
15
-
16
- transform=transforms.Compose([
17
- transforms.ToTensor(),
18
- # normalize
19
- ])
20
-
21
-
22
- def inference(img):
23
-
24
- # print(img.size)
25
- img = img.resize((640, 384))
26
-
27
- img = torch.unsqueeze(transform(img), dim=0)
28
-
29
- # img = transform(img)
30
-
31
- features, regression, classification, anchors, segmentation = model(img)
32
-
33
- features_out = features[0][0, :, :].detach().numpy()
34
- regression_out = regression[0][0, :, :].detach().numpy()
35
- classification_out = classification[0][0, :, :].detach().numpy()
36
- anchors_out = anchors[0][0, :, :].detach().numpy()
37
- segmentation_out = segmentation[0][0, :, :].detach().numpy()
38
-
39
- return features_out, regression_out, classification_out, anchors_out, segmentation_out
40
-
41
- title="HybridNets Demo"
42
- description="Gradio demo for HybridNets: End2End Perception Network pretrained on BDD100k Dataset. To use it, simply upload your image or click on one of the examples to load them. Read more at the links below"
43
-
44
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2203.09035' target='_blank'>ybridNets: End2End Perception Network</a> | <a href='https://github.com/datvuthanh/HybridNets' target='_blank'>Github Repo</a></p>"
45
-
46
- examples=[['frame_00_delay-0.13s.jpg']]
47
-
48
- gr.Interface(inference,gr.inputs.Image(type="pil"),[gr.outputs.Image(label='Features'),gr.outputs.Image(label='Regression'),gr.outputs.Image(label='Classification'),gr.outputs.Image(label='Anchors'),gr.outputs.Image(label='Segmentation ')],article=article,description=description,title=title,examples=examples).launch()