Reduced GroundingDataset annotation unpacking speed (#18382)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Laughing-q <1185102784@qq.com>
Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
This commit is contained in:
Lorna 2024-12-28 12:26:38 +08:00 committed by GitHub
parent 2aac80d980
commit 1051255c1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -323,7 +323,8 @@ class GroundingDataset(YOLODataset):
if box[2] <= 0 or box[3] <= 0: if box[2] <= 0 or box[3] <= 0:
continue 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: if cat_name not in cat2id:
cat2id[cat_name] = len(cat2id) cat2id[cat_name] = len(cat2id)
texts.append([cat_name]) texts.append([cat_name])