-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register custom dataset -AssertionError #1647
Comments
As the error says, the dataset is already registered. Registering it again is expected to cause this error |
How do you unregister the dataset. I'm creating a huge number of datasets because I can't unregister them. |
@RishiMalhotra920 |
@ghazni123 @RishiMalhotra920 I was having the same issue; after reading the code I found there is a |
@RishiMalhotra920 @rogertrullo @ppwwyyxx You could use something like this to remove and re-register:
|
❓ How to register custom dataset in detectron2
Hi guys, from Colab, I would like to learn how to register in detectron2 my custom dataset.
https://rosenfelder.ai/Instance_Image_Segmentation_for_Window_and_Building_Detection_with_detectron2/#prepare-the-data
Inputs
I used via.html to make annotations and save them in two json files (train - val)
Each image has street and hole labels.
images are located in Colab in train and val folders, inside of each folder there are images and a json file called
I found a function in beginer's tutorial for converts them into a format that is usable by detectron2.
I expect how outputs about that function converts images into a format that is usable by detectron2
Code implemented
def get_street_dicts(img_dir):
"""This function loads the JSON file created with the annotator and converts it to
the detectron2 metadata specifications.
"""
# load the JSON file
json_file = os.path.join(img_dir, "via_region_data.json")
with open(json_file) as f:
imgs_anns = json.load(f)
for d in ["train", "val"]:
DatasetCatalog.register("streets_" + d,lambda d=d: get_street_dicts("/content/potholes/"+ d))
street_metadata = MetadataCatalog.get("streets_train")
dataset_dicts = get_street_dicts("/content/potholes/train")
AssertionError
AssertionError Traceback (most recent call last)
in ()
59 from detectron2.data import DatasetCatalog, MetadataCatalog
60 for d in ["train", "val"]:
---> 61 DatasetCatalog.register("streets_" + d,lambda d=d: get_street_dicts("/content/potholes/", d))
62 street_metadata = MetadataCatalog.get("streets_train")
63 dataset_dicts = get_street_dicts("/content/potholes/train")
/content/detectron2_repo/detectron2/data/catalog.py in register(name, func)
38 assert callable(func), "You must register a function with DatasetCatalog.register!"
39 assert name not in DatasetCatalog._REGISTERED, "Dataset '{}' is already registered!".format(
---> 40 name
41 )
42 DatasetCatalog._REGISTERED[name] = func
AssertionError: Dataset 'streets_train' is already registered!
Thanks for check it.
The text was updated successfully, but these errors were encountered: