From b5fd7f3378a7dbc551871b57b7c122f77b55193b Mon Sep 17 00:00:00 2001 From: Laughing <61612323+Laughing-q@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:58:11 +0800 Subject: [PATCH] `ultralytics 8.3.23` fix `bbox2segment` when no segments generated (#17157) Co-authored-by: Glenn Jocher --- ultralytics/__init__.py | 2 +- ultralytics/data/converter.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index b9f92151..a48d3646 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.3.22" +__version__ = "8.3.23" import os diff --git a/ultralytics/data/converter.py b/ultralytics/data/converter.py index fe1aac10..fa582141 100644 --- a/ultralytics/data/converter.py +++ b/ultralytics/data/converter.py @@ -632,9 +632,10 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"): txt_file = save_dir / lb_name cls = label["cls"] for i, s in enumerate(label["segments"]): + if len(s) == 0: + continue line = (int(cls[i]), *s.reshape(-1)) texts.append(("%g " * len(line)).rstrip() % line) - if texts: with open(txt_file, "a") as f: f.writelines(text + "\n" for text in texts) LOGGER.info(f"Generated segment labels saved in {save_dir}")