From 1051255c1e8de148fb85189da13059ae3937360e Mon Sep 17 00:00:00 2001 From: Lorna Date: Sat, 28 Dec 2024 12:26:38 +0800 Subject: [PATCH] Reduced GroundingDataset annotation unpacking speed (#18382) Co-authored-by: Glenn Jocher Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> --- ultralytics/data/dataset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ultralytics/data/dataset.py b/ultralytics/data/dataset.py index f3be2305..5cf50304 100644 --- a/ultralytics/data/dataset.py +++ b/ultralytics/data/dataset.py @@ -323,7 +323,8 @@ class GroundingDataset(YOLODataset): if box[2] <= 0 or box[3] <= 0: continue - cat_name = " ".join([img["caption"][t[0] : t[1]] for t in ann["tokens_positive"]]) + caption = img["caption"] + cat_name = " ".join([caption[t[0] : t[1]] for t in ann["tokens_positive"]]) if cat_name not in cat2id: cat2id[cat_name] = len(cat2id) texts.append([cat_name])