IDEA-Research / detrex

detrex is a research platform for DETR-based object detection, segmentation, pose estimation and other visual recognition tasks.
https://detrex.readthedocs.io/en/latest/
Apache License 2.0
2k stars 206 forks source link

Single Class detection #267

Open CloudRider-pixel opened 1 year ago

CloudRider-pixel commented 1 year ago

Hi,

I successfully train detr_50 on my custom dataset. Nevertheless, it's a single-class one. What I have to change in order to train this model on a single class problem ? For example in projects/detr_r50 I saw that the number of classes is harcoded to 80 (coco), also loss is CE which normally is not suited.

In advance thanks,

Max.

rentainhe commented 1 year ago

You can train your own custom dataset with one class as follows:

  1. Convert your dataset annotation to COCO format
  2. Register your own dataset follow: custom.py
  3. Modify the model config to model.num_classes=1
  4. Modify the criterion config to num_classes=1
wwhhh2000 commented 1 year ago

how can I modify model.num_classes and num_classes? I have not found them. In advance thanks.

rentainhe commented 1 year ago

how can I modify model.num_classes and num_classes? I have not found them. In advance thanks.

They have been defined in the model config, you can find them here: https://github.com/IDEA-Research/detrex/blob/f34380d3652c0dbc8f9de911626117943a8208c4/projects/dino_eva/configs/models/dino_r50.py#L76

@wwhhh2000

wwhhh2000 commented 1 year ago

how can I modify model.num_classes and num_classes? I have not found them. In advance thanks.

They have been defined in the model config, you can find them here:

https://github.com/IDEA-Research/detrex/blob/f34380d3652c0dbc8f9de911626117943a8208c4/projects/dino_eva/configs/models/dino_r50.py#L76

@wwhhh2000

Thank you so much!