Yolov8n-cls has a background class?

Hello i’m doing transfer learning on yolov8n-cls, with this script:

from ultralytics import YOLO
model = YOLO('yolov8n-cls.pt') 



print(model.names)
results = model.train(
    data='./dataset',      
    epochs=25,               
    imgsz=224,               
    device='cpu',           
    project='progetto_gatti', 
    name='run_',
    patience=15,             
    freeze="9"
)

and this dataset:

dataset/
├── test/
│ ├── gatto/
│ └── non_gatto/
├── train/
│ ├── gatto/
│ └── non_gatto/
└── val/
├── gatto/
└── non_gatto/

and the testing of the model:

from ultralytics import YOLO



best_model = YOLO('./runs/classify/progetto_gatti/run_4/weights/best.pt')
metrics = best_model.val(data='./dataset', split='val', batch=1)
print(best_model.names)

however the confusion matrix looks like this:

and i can’t get why there is a background class even if the print(best_model.names) prints out:

{0: ‘gatto’, 1: ‘non_gatto’}

Probably a bug

1 Like

Should be fixed in next release