xingyizhou / CenterNet2

Two-stage CenterNet
Apache License 2.0
1.2k stars 188 forks source link

Custom dataset classes #36

Closed salmanhiro closed 3 years ago

salmanhiro commented 3 years ago

📚 Documentation

Hi, I wonder how to register custom dataset classes, since I already tried to train with custom dataset and getting this error.

Traceback (most recent call last):
  File "train_net.py", line 228, in <module>
    args=(args,),
  File "/usr/local/lib/python3.7/dist-packages/detectron2/engine/launch.py", line 62, in launch
    main_func(*args)
  File "train_net.py", line 208, in main
    do_train(cfg, model, resume=args.resume)
  File "train_net.py", line 108, in do_train
    data_loader = build_detection_train_loader(cfg, mapper=mapper)
  File "/usr/local/lib/python3.7/dist-packages/detectron2/config/config.py", line 201, in wrapped
    explicit_args = _get_args_from_config(from_config, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/detectron2/config/config.py", line 238, in _get_args_from_config
    ret = from_config_func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/build.py", line 314, in _train_loader_from_config
    proposal_files=cfg.DATASETS.PROPOSAL_FILES_TRAIN if cfg.MODEL.LOAD_PROPOSALS else None,
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/build.py", line 227, in get_detection_dataset_dicts
    dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in names]
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/build.py", line 227, in <listcomp>
    dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in names]
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/catalog.py", line 58, in get
    return f()
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/datasets/coco.py", line 489, in <lambda>
    DatasetCatalog.register(name, lambda: load_coco_json(json_file, image_root, name))
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/datasets/coco.py", line 80, in load_coco_json
    meta.thing_classes = thing_classes
  File "/usr/local/lib/python3.7/dist-packages/detectron2/data/catalog.py", line 150, in __setattr__
    "to a different value!\n{} != {}".format(key, self.name, oldval, val)
AssertionError: Attribute 'thing_classes' in the metadata of 'coco_2017_train' cannot be set to a different value!
['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] != ['class1', 'class2', 'class3']
admin221 commented 3 years ago

Excuse me, has it been solved?

salmanhiro commented 3 years ago

not yet

xingyizhou commented 3 years ago

Hi, You can refer to this file for custom datasets.

engrjav commented 2 years ago

@xingyizhou the link for custom dataset is broken. Can you resend it please