yolov5-face icon indicating copy to clipboard operation
yolov5-face copied to clipboard

Unnecessary Rescaling in torch2trt/main.py

Open vjsrinivas opened this issue 2 years ago • 3 comments

Hello, First off, I would like to thank you for your work and willingness to make it opensource. I was following the instructions in the README of the torch2trt folder, and the current visualization code is giving the wrong input into show_results.

Essentially, the xywh is in normalized form and incorrectly shifted, which reduce to all zeros when converted to integers for cv2.rectangle. It can be fixed by replacing this snippet in img_vis:

xywh = (xyxy2xywh(det[j, :4].view(1, 4)) / gn).view(-1).tolist()
conf = det[j, 4].cpu().numpy()
landmarks = (det[j, 5:15].view(1, 10) / gn_lks).view(-1).tolist()
class_num = det[j, 15].cpu().numpy()
orgimg = show_results(orgimg, xywh, conf, landmarks, class_num)

to

conf = det[j, 4].cpu().numpy()
landmarks = (det[j, 5:15].view(1, 10) / gn_lks).view(-1)
landmarks[[0,2,4,6,8]] *= orgimg.shape[1] # x
landmarks[[1,3,5,7,9]] *= orgimg.shape[0] # y
landmarks = landmarks.int().tolist()
class_num = det[j, 15].cpu().numpy()
xyxy = det[j, :4].int().tolist()

vjsrinivas avatar May 29 '22 03:05 vjsrinivas

@vjsrinivas hi, I found it too. Your code is work. Did you hit that one object must have three box-predict with different area , which just like as below ? image

EdisionWew avatar Jun 06 '22 08:06 EdisionWew

I'm sorry. I don't understand the question. Is the code snippet I sent causing the screenshot you posted?

vjsrinivas avatar Jun 07 '22 02:06 vjsrinivas

Thanks ! @vjsrinivas

pengfeidip avatar Jan 11 '23 09:01 pengfeidip