Skip to content

Commit 75aee77

Browse files
committed
custom colors
1 parent 3cc2b73 commit 75aee77

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

patched_yolo_infer/functions_extra.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ def visualize_results_usual_yolo_inference(
110110

111111
if random_object_colors:
112112
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
113-
else:
113+
elif list_of_class_colors is None:
114114
# Assign color according to class
115115
random.seed(int(classes[i] + delta_colors))
116116
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
117+
else:
118+
color = list_of_class_colors[classes[i]]
117119

118120
box = boxes[i]
119121
x_min, y_min, x_max, y_max = box
@@ -339,10 +341,12 @@ def visualize_results(
339341

340342
if random_object_colors:
341343
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
342-
else:
344+
elif list_of_class_colors is None:
343345
# Assign color according to class
344346
random.seed(int(classes_ids[i] + delta_colors))
345347
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
348+
else:
349+
color = list_of_class_colors[classes_ids[i]]
346350

347351
box = boxes[i]
348352
x_min, y_min, x_max, y_max = box

0 commit comments

Comments
 (0)