Refactor Python code (#13448)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
6a234f3639
commit
1b26838def
22 changed files with 81 additions and 101 deletions
|
|
@ -1114,10 +1114,7 @@ class RandomLoadText:
|
|||
pos_labels = set(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 = []
|
||||
for i in range(num_classes):
|
||||
if i not in pos_labels:
|
||||
neg_labels.append(i)
|
||||
neg_labels = [i for i in range(num_classes) if i not in pos_labels]
|
||||
neg_labels = random.sample(neg_labels, k=neg_samples)
|
||||
|
||||
sampled_labels = pos_labels + neg_labels
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue