hustvl / YOLOP

You Only Look Once for Panopitic Driving Perception.(MIR2022)
MIT License
1.9k stars 411 forks source link

How to view image result in opencv #198

Open bb6698 opened 11 months ago

bb6698 commented 11 months ago

Hi!! I'm using Yolop with my images but I want to visualisate the result. How to could do it?

My code is:

`import torch import torchvision.transforms as transforms import cv2

normalize = transforms.Normalize( mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225] )

transform=transforms.Compose([ transforms.ToTensor(), normalize, ])

IMAGE = "/home/oem/images/image1.jpg"

image = cv2.imread(IMAGE)

resized = cv2.resize(image, (640,640), interpolation = cv2.INTER_AREA)

model = torch.hub.load('hustvl/yolop', 'yolop', pretrained=True)

img = torch.unsqueeze(transform(resized), dim=0)

det_out, da_seg_out,ll_seg_out = model(img)`

Thanks!!

sachinkum0009 commented 10 months ago

You might want to check the tools/demo.py file which uses the show_seg_result function to show the result.

https://github.com/hustvl/YOLOP/blob/8d8f68df318c71f01d6f813c024df646c7d1978f/lib/utils/plot.py#L24