question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssertionError: You must register a function with `DatasetCatalog.register`!

See original GitHub issue

here 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 with DatasetCatalog.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:closed
  • Created 4 years ago
  • Comments:16

github_iconTop GitHub Comments

5reactions
iskodecommented, Feb 6, 2020

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 issue

2reactions
ppwwyyxxcommented, Feb 6, 2020

Based on the python language, the loop posted above is equivalent to

DatasetCatalog.register('train', lambda: get_kitti_data_dict(dataset_root_dir, 'train'))
MetadataCatalog.get('train').thing_classes = ["person"]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for detectron2.data.catalog
assert callable(func), "You must register a function with `DatasetCatalog.register`!" assert name not in self, "Dataset '{}' is already registered!
Read more >
Training Detectron2 on part of COCO dataset - python
This 'warning' basically says that you are trying to initialize weights from a model that was trained on a different number of classes....
Read more >
detectron2/data/catalog.py · CVPR/regionclip-demo at main
to a function which parses the dataset and returns the samples in the ... "You must register a function with `DatasetCatalog.register`!".
Read more >
how to use detectron2
To do that, we need to dig into the code where datasets are set up and register our custom dataset information. Below code...
Read more >
Wednesday, July 7, 2021
write a function that loads the dataset into detectron2's standard format def ... You must register a function with `DatasetCatalog.register`!.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found