AssertionError: You must register a function with `DatasetCatalog.register`!
See original GitHub issuehere i have used custom dataset and i wrote a script to get the values from and return the ‘list[dict]’ Then i have used the following code to register the dataset,
from detectron2.data import DatasetCatalog, MetadataCatalog DatasetCatalog.register(‘train’, get_kitti_data_dict(dataset_root_dir, ‘train’)) MetadataCatalog.get(“train”).thing_classes = [“person”]
But i got following error
Traceback (most recent call last): File “tools/get_dataset_from_kitti.py”, line 94, in <module> DatasetCatalog.register(‘train’, get_kitti_data_dict(dataset_root_dir, ‘train’)) File “/opt/anaconda3/envs/Detectron2/lib/python3.8/site-packages/detectron2/data/catalog.py”, line 37, in register assert callable(func), “You must register a function with
DatasetCatalog.register
!” AssertionError: You must register a function withDatasetCatalog.register
!
The ‘list[dict]’ is the following
[{'file_name': '/home/samjith/0000180.jpg', 'height': 788, 'width': 1400, 'image_id': 1, 'annotations': [{'bbox': [250.0, 675.0, 23.0, 17.0], 'bbox_mode': <BoxMode.XYWH_ABS: 1>, 'area': 391.0, 'segmentation': [], 'category_id': 0}, {'bbox': [295.0, 550.0, 21.0, 20.0], 'bbox_mode': <BoxMode.XYWH_ABS: 1>, 'area': 420.0, 'segmentation': [], 'category_id': 0},..
Issue Analytics
- State:
- Created 4 years ago
- Comments:16
Top GitHub Comments
Hi, I was able to reproduce your error locally as I’m trying to work with the detectron2 also. You must provide a ’ lambda function’ to the 2nd argument like in the custom dataset use custom dataset tutorial:
for d in ['train']:
DatasetCatalog.register(d, lambda d: d = get_kitti_data_dict(dataset_root_dir, d))
MetadataCatalog.get(d).thing_classes = ["person"]
Normally it should work. But really I haven’t gone about how to do it without the loop. Hope it fixes your issueBased on the python language, the loop posted above is equivalent to