Fix bbox2segment converter (#7814)

This commit is contained in:
Laughing 2024-01-26 01:57:00 +08:00 committed by GitHub
parent 62742c21d2
commit 0c4f035728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -515,6 +515,8 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"):
for l in tqdm(dataset.labels, total=len(dataset.labels), desc="Generating segment labels"): for l in tqdm(dataset.labels, total=len(dataset.labels), desc="Generating segment labels"):
h, w = l["shape"] h, w = l["shape"]
boxes = l["bboxes"] boxes = l["bboxes"]
if len(boxes) == 0: # skip empty labels
continue
boxes[:, [0, 2]] *= w boxes[:, [0, 2]] *= w
boxes[:, [1, 3]] *= h boxes[:, [1, 3]] *= h
im = cv2.imread(l["im_file"]) im = cv2.imread(l["im_file"])