hustvl/YOLOP

How to view image result in opencv

bb6698 opened this issue · 1 comments

bb6698 commented

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!!

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

def show_seg_result(img, result, index, epoch, save_dir=None, is_ll=False,palette=None,is_demo=False,is_gt=False):