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

add custom dataset example #187

Closed zengzhaoyang closed 1 year ago

zengzhaoyang commented 1 year ago

Simple Tutorial

Training your own dataset with detrex models, all you need to do is to convert your dataset into coco format and register your dataset in config file as:

# coco_detr.py

from detectron2.data.datasets import register_coco_instances
register_coco_instances("my_dataset_train", {}, '/path/to/train.json', '/path/to/train/images')
register_coco_instances("my_dataset_test", {}, '/path/to/test.json', '/path/to/test/images')

Then modify the dataloader config:

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

dataloader.test = L(build_detection_test_loader)(
    dataset=L(get_detection_dataset_dicts)(names="my_dataset_test", filter_empty=False),
    ...