DEIM icon indicating copy to clipboard operation
DEIM copied to clipboard

config for num_classes

Open LemonWei111 opened this issue 11 months ago • 7 comments

I am confused that do we need to set the background as a class. Cause most models for object detection like YOLO and DETR set num_classes to the original number of classes plus 1. Does DEIM also need plus 1? Moreover, the question is, why is the num_classes configuration for COCO 80? Shouldn't it be 90 (+1)?

LemonWei111 avatar Jan 24 '25 01:01 LemonWei111

Of course when I fintune it, I set num_classes as right the num of classes. And all is right.

LemonWei111 avatar Jan 24 '25 01:01 LemonWei111

When I set num_classes = num of classes plus 1, so many boxes are predicted to be background, but AP and Recall increases while FNR decreases, which means the model is like to find the minority class better in my example.

LemonWei111 avatar Jan 24 '25 03:01 LemonWei111

当我设置 num_classes = 类数加 1 时,预测许多框是背景,但 AP 和 Recall 增加,而 FNR 减少,这意味着在我的示例中,模型似乎能更好地找到少数类。

According to the logic of the code, it should be set to plus 1, but it is strange to have a complete lack of focus on most classes

LemonWei111 avatar Jan 24 '25 03:01 LemonWei111

I found what happened! 80 object categories for coco. But I haven't find the document of them to check whether the category id is begin with 0 or 1.

我很困惑,我们是否需要将背景设置为一个类。导致大多数对象检测模型(如 YOLO 和 DETR)num_classes设置为原始类数加 1。DEIM 也需要加 1 吗?而且,问题是,为什么 COCO 80 的 num_classes 配置呢?不应该是 90 (+1) 吗?

LemonWei111 avatar Jan 24 '25 04:01 LemonWei111

I found it! The id of the object the author used is from 0 to 79, not 1 to 90 as I thought before. So just set num_classes as the num of your dataset, but check your annotation.

LemonWei111 avatar Jan 24 '25 04:01 LemonWei111

Did you find why it does do +1? I have a dataset that has 1 class but it doesn't work when I set cum_classes to 1. It only works when I set it to 2

Jobiis avatar Feb 03 '25 09:02 Jobiis

您是否发现它为什么会 +1?我有一个包含 1 个类的数据集,但当我将 cum_classes 设置为 1 时它不起作用。只有当我将其设置为 2 时它才有效

Did you figure it out? I met the same problem. I have a dataset that has 6 classes but it doesn't work(CUDA error: device-side assert triggered) when I set cum_classes to 6. It only works when I set it to 7.

Mugen-chen avatar Mar 21 '25 06:03 Mugen-chen