Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,8 +96,7 @@ def detect(img,model):
|
|
| 96 |
dataset = LoadImages(source, img_size=imgsz, stride=stride)
|
| 97 |
|
| 98 |
# Run inference
|
| 99 |
-
|
| 100 |
-
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
|
| 101 |
t0 = time.time()
|
| 102 |
for path, img, im0s, vid_cap in dataset:
|
| 103 |
img = torch.from_numpy(img).to(device)
|
|
@@ -153,7 +152,6 @@ def detect(img,model):
|
|
| 153 |
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
| 154 |
line = (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label format
|
| 155 |
|
| 156 |
-
|
| 157 |
if save_img : # Add bbox to image
|
| 158 |
plot_one_box(xyxy, im0, line_thickness=3)
|
| 159 |
|
|
@@ -268,4 +266,4 @@ def detect(img,model):
|
|
| 268 |
return Image.fromarray(im0[:,:,::-1])
|
| 269 |
|
| 270 |
|
| 271 |
-
gr.Interface(detect,[gr.Image(type="pil"),gr.Dropdown(choices=["
|
|
|
|
| 96 |
dataset = LoadImages(source, img_size=imgsz, stride=stride)
|
| 97 |
|
| 98 |
# Run inference
|
| 99 |
+
|
|
|
|
| 100 |
t0 = time.time()
|
| 101 |
for path, img, im0s, vid_cap in dataset:
|
| 102 |
img = torch.from_numpy(img).to(device)
|
|
|
|
| 152 |
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
| 153 |
line = (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label format
|
| 154 |
|
|
|
|
| 155 |
if save_img : # Add bbox to image
|
| 156 |
plot_one_box(xyxy, im0, line_thickness=3)
|
| 157 |
|
|
|
|
| 266 |
return Image.fromarray(im0[:,:,::-1])
|
| 267 |
|
| 268 |
|
| 269 |
+
gr.Interface(detect,[gr.Image(type="pil"),gr.Dropdown(choices=["yolop","yolopv2"])], gr.Image(type="pil"),title="Yolopv2",examples=[["example.jpeg", "yolopv2"]],description="demo for <a href='https://github.com/CAIC-AD/YOLOPv2' style='text-decoration: underline' target='_blank'>YOLOPv2</a> 🚀: Better, Faster, Stronger for Panoptic driving Perception").launch()
|