lyuwenyu / RT-DETR

[CVPR 2024] Official RT-DETR (RTDETR paddle pytorch), Real-Time DEtection TRansformer, DETRs Beat YOLOs on Real-time Object Detection. 🔥 🔥 🔥
Apache License 2.0
2.33k stars 265 forks source link

How to transfer a custom dataset use yolo to rt_detr #220

Open JacksonWang opened 7 months ago

JacksonWang commented 7 months ago

Hi, Thanks your great job. Now I am trying to train a custom dataset with yolo label format and train well in yoloV7 and V9. I am trying to train it use RT_DETR with pytorch version.

I found a transfer method from github to transfer yolo format to COCO, and I do it well. I guess it is no problem. But after I set up my RT-DETR env. well and try to start my first train, I always get the error message "ValueError: num_samples should be a positive integer value, but got num_samples=0. I do search in github and google try to solve it by myself but I fail. I don't know what's wrong with it. Can someone help me to solve it? Thanks.

Below is what my config in rtdetr `include: [ '../dataset/helmet.yaml', '../runtime.yml', './include/dataloader.yml', './include/optimizer.yml', './include/rtdetr_r50vd.yml', ]

output_dir: /mnt/proj/jcwang/models/helmet/rtdetr`

And below is what my config in dataset `task: detection

num_classes: 9 remap_mscoco_category: True

train_dataloader: type: DataLoader dataset: type: CocoDetection img_folder: /mnt/bak/dataset/helmet2324/2024_detr/train_img ann_file: /mnt/bak/dataset/helmet2324/2024_detr/detr/train_12471.json transforms: type: Compose ops: ~ shuffle: True batch_size: 4 num_workers: 1 drop_last: True

val_dataloader: type: DataLoader dataset: type: CocoDetection img_folder: /mnt/bak/dataset/helmet2324/2024_detr/valid_img ann_file: /mnt/bak/dataset/helmet2324/2024_detr/detr/valid_3240.json transforms: type: Compose ops: ~

shuffle: False batch_size: 4 num_workers: 1 drop_last: False`

lyuwenyu commented 7 months ago

custom dataset should setremap_mscoco_category: False

JacksonWang commented 7 months ago

Thanks for your reply. But I had chaged it before I summit this issue and I still get the issue.

lyuwenyu commented 7 months ago

well and try to start my first train, I always get the error message "ValueError: num_samples should be a positive integer value, but got num_samples=0.

can you check image dir correct in code?

JacksonWang commented 7 months ago

Thanks for your reply, I will check the image dir in code. But I thought, is it should get the config file what I placed?

I will check the code for image dir and let you know the result soon.

JacksonWang commented 7 months ago

When I check the code what you referenced, I noticed it is coco_dataset.py, seems for coco dataset. But what I try to do is train my custom dataset, besides, there is no image dir in the code.