Eliminate set() to avoid set() + list() op (#14745)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Kevin 2024-07-30 07:16:22 +08:00 committed by GitHub
parent 91218583d3
commit 82c4bdad10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2221,7 +2221,7 @@ class RandomLoadText:
pos_labels = np.unique(cls).tolist()
if len(pos_labels) > self.max_samples:
pos_labels = set(random.sample(pos_labels, k=self.max_samples))
pos_labels = random.sample(pos_labels, k=self.max_samples)
neg_samples = min(min(num_classes, self.max_samples) - len(pos_labels), random.randint(*self.neg_samples))
neg_labels = [i for i in range(num_classes) if i not in pos_labels]