Closed ma3252788 closed 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
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"),
...
Please refer to custom.py to see how to register and use coco-like datasets in detrex and d2~
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.
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~
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.
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.
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
您好,你的邮件我已经收到~
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
ERROR [09/30 16:04:15 d2.config.instantiate]: Error when instantiating detectron2.data.build.build_detection_train_loader!
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?