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
1.97k stars 206 forks source link

How can I use a custom dataset for training? #186

Closed ma3252788 closed 1 year ago

ma3252788 commented 1 year ago

How can I use a custom dataset for training?

I have made the data in COCO2017 format, but the number of classes and class names are different from COCO, which file should I change?

rentainhe commented 1 year ago

How can I use a custom dataset for training?

I have made the data in COCO2017 format, but the number of classes and class names are different from COCO, which file should I change?

You can use this functions: register_coco_instances to register your dataset in config file, and then update the dataset name

rentainhe commented 1 year ago

Here is an example:

# dataset config
from detectron2.data.datasets import register_coco_instances

register_coco_instances("my_dataset", {}, "path/to/json", "path/to/image_root") 

dataloader.train = L(build_detection_train_loader)(
    dataset=L(get_detection_dataset_dicts)(names="my_dataset"),
    ...
rentainhe commented 1 year ago

Please refer to custom.py to see how to register and use coco-like datasets in detrex and d2~

ma3252788 commented 1 year ago

Here is an example:

# dataset config
from detectron2.data.datasets import register_coco_instances

register_coco_instances("my_dataset", {}, "path/to/json", "path/to/image_root") 

dataloader.train = L(build_detection_train_loader)(
    dataset=L(get_detection_dataset_dicts)(names="my_dataset"),
    ...

I see. Thank you very much for your reply.

rentainhe commented 1 year ago

Here is an example:

# dataset config
from detectron2.data.datasets import register_coco_instances

register_coco_instances("my_dataset", {}, "path/to/json", "path/to/image_root") 

dataloader.train = L(build_detection_train_loader)(
    dataset=L(get_detection_dataset_dicts)(names="my_dataset"),
    ...

I see. Thank you very much for your reply.

You're welcome~

sjtu-cz commented 1 year ago

File "/workspace/detrex/detectron2/detectron2/evaluation/coco_evaluation.py", line 240, in _eval_predictions assert category_id < num_classes, ( AssertionError: A prediction has class=14, but the dataset only has 11 classes and predicted class id should be in [0, 10].

I use a custom dataset for training, but meet the error.

FrostbiteLee commented 1 year ago

File "/workspace/detrex/detectron2/detectron2/evaluation/coco_evaluation.py", line 240, in _eval_predictions assert category_id < num_classes, ( AssertionError: A prediction has class=14, but the dataset only has 11 classes and predicted class id should be in [0, 10].

I use a custom dataset for training, but meet the error.

I had the same problem. I need help.

xiaolizai commented 1 year ago

File "/workspace/detrex/detectron2/detectron2/evaluation/coco_evaluation.py", line 240, in _eval_predictions assert category_id < num_classes, ( AssertionError: A prediction has class=14, but the dataset only has 11 classes and predicted class id should be in [0, 10].

I use a custom dataset for training, but meet the error.

Maybe can help you. https://github.com/IDEA-Research/detrex/issues/267#issuecomment-1637273202

sjtu-cz commented 1 year ago

您好,你的邮件我已经收到~

wwzstudy commented 11 months ago

After modifying the custom.py file, run python tools/train_net.py --config-file projects/dab_detr/configs/models/dab_detr_r50.py, A Missing key train error occurred full_key: train object_type=dict

wwzstudy commented 11 months ago

ERROR [09/30 16:04:15 d2.config.instantiate]: Error when instantiating detectron2.data.build.build_detection_train_loader!