MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / plot_gt

Function plot_gt

SwissArmyTransformer/examples/yolos/infer_util.py:62–77  ·  view source on GitHub ↗
(im, labels, bboxes_scaled, output_dir)

Source from the content-addressed store, hash-verified

60 raise ValueError(f'unknown {image_set}')
61
62def plot_gt(im, labels, bboxes_scaled, output_dir):
63 tl = 3
64 tf = max(tl-1, 1)
65 tempimg = copy.deepcopy(im)
66 color = [255,0,0]
67 for label, (xmin, ymin, xmax, ymax) in zip(labels.tolist(), bboxes_scaled.tolist()):
68 c1, c2 = (int(xmin), int(ymin)), (int(xmax), int(ymax))
69 cv2.rectangle(tempimg, c1, c2, color, tl, cv2.LINE_AA)
70 text = f'{CLASSES[label]}'
71 t_size = cv2.getTextSize(text, 0, fontScale=tl / 3, thickness=tf)[0]
72 c2 = c1[0] + t_size[0], c1[1] - t_size[1] - 3
73 cv2.rectangle(tempimg, c1, c2, color, -1, cv2.LINE_AA) # filled
74 cv2.putText(tempimg, text, (c1[0], c1[1] - 2), 0, tl / 3, [225, 255, 255], thickness=tf, lineType=cv2.LINE_AA)
75 fname = os.path.join(output_dir,'gt_img.png')
76 cv2.imwrite(fname, tempimg)
77 print(f"{fname} saved.")
78
79def box_cxcywh_to_xyxy(x):
80 x_c, y_c, w, h = x.unbind(1)

Callers 1

save_gt_figFunction · 0.85

Calls 1

printFunction · 0.50

Tested by

no test coverage detected