ultralytics 8.3.23 fix bbox2segment when no segments generated (#17157)
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
61a45508f8
commit
b5fd7f3378
2 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
|
||||||
__version__ = "8.3.22"
|
__version__ = "8.3.23"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -632,9 +632,10 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"):
|
||||||
txt_file = save_dir / lb_name
|
txt_file = save_dir / lb_name
|
||||||
cls = label["cls"]
|
cls = label["cls"]
|
||||||
for i, s in enumerate(label["segments"]):
|
for i, s in enumerate(label["segments"]):
|
||||||
|
if len(s) == 0:
|
||||||
|
continue
|
||||||
line = (int(cls[i]), *s.reshape(-1))
|
line = (int(cls[i]), *s.reshape(-1))
|
||||||
texts.append(("%g " * len(line)).rstrip() % line)
|
texts.append(("%g " * len(line)).rstrip() % line)
|
||||||
if texts:
|
|
||||||
with open(txt_file, "a") as f:
|
with open(txt_file, "a") as f:
|
||||||
f.writelines(text + "\n" for text in texts)
|
f.writelines(text + "\n" for text in texts)
|
||||||
LOGGER.info(f"Generated segment labels saved in {save_dir}")
|
LOGGER.info(f"Generated segment labels saved in {save_dir}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue