@@ -80,7 +80,7 @@ def visualize_results_usual_yolo_inference(
8080 class_names = model .names
8181
8282 # Map class IDs to indices in the color list
83- all_classes = sorted ( set (cls for pred in predictions for cls in pred .boxes .cls .cpu ().int ().tolist () ))
83+ all_classes = set (cls for pred in predictions for cls in pred .boxes .cls .cpu ().int ().tolist ())
8484 class_to_color_index = {cls_id : idx for idx , cls_id in enumerate (all_classes )}
8585
8686 # Process each prediction
@@ -120,7 +120,7 @@ def visualize_results_usual_yolo_inference(
120120 random .seed (int (classes [i ] + delta_colors ))
121121 color = (random .randint (0 , 255 ), random .randint (0 , 255 ), random .randint (0 , 255 ))
122122 else :
123- color = list_of_class_colors [classes [ i ]]
123+ color = list_of_class_colors [class_to_color_index [ class_index ]]
124124
125125 box = boxes [i ]
126126 x_min , y_min , x_max , y_max = box
@@ -340,7 +340,7 @@ def visualize_results(
340340 random .seed (int (delta_colors ))
341341
342342 # Map class IDs to indices in the color list
343- unique_classes = sorted ( set (classes_ids ) )
343+ unique_classes = set (classes_ids )
344344 class_to_color_index = {cls_id : idx for idx , cls_id in enumerate (unique_classes )}
345345
346346 # Process each prediction
@@ -361,7 +361,7 @@ def visualize_results(
361361 random .seed (int (classes_ids [i ] + delta_colors ))
362362 color = (random .randint (0 , 255 ), random .randint (0 , 255 ), random .randint (0 , 255 ))
363363 else :
364- color = list_of_class_colors [classes_ids [i ]]
364+ color = list_of_class_colors [class_to_color_index [ classes_ids [i ] ]]
365365
366366 box = boxes [i ]
367367 x_min , y_min , x_max , y_max = box
0 commit comments