hustvl / SparseInst

[CVPR 2022] SparseInst: Sparse Instance Activation for Real-Time Instance Segmentation
MIT License
590 stars 71 forks source link

How to do a custom training?? #53

Closed caoxuefengzz closed 2 years ago

caoxuefengzz commented 2 years ago

Hello. I'm new to SparseInst, and also new to detectron2. I want to train my own datatset that fomart with coco . But I don't no how to modify your config. or I need modify some codes of detectron2? I have 2 class,when I train as issues #34. I got a error as below:

`Traceback (most recent call last): File "train_net.py", line 180, in launch( File "/home/cxf/detectron2-0.3/detectron2/engine/launch.py", line 62, in launch main_func(args) File "train_net.py", line 172, in main trainer = Trainer(cfg) File "/home/cxf/detectron2-0.3/detectron2/engine/defaults.py", line 284, in init data_loader = self.build_train_loader(cfg) File "train_net.py", line 144, in build_train_loader return build_detection_train_loader(cfg, mapper=mapper) File "/home/cxf/detectron2-0.3/detectron2/config/config.py", line 201, in wrapped explicit_args = _get_args_from_config(from_config, args, *kwargs) File "/home/cxf/detectron2-0.3/detectron2/config/config.py", line 236, in _get_args_from_config ret = from_config_func(args, **kwargs) File "/home/cxf/detectron2-0.3/detectron2/data/build.py", line 301, in _train_loader_from_config dataset = get_detection_dataset_dicts( File "/home/cxf/detectron2-0.3/detectron2/data/build.py", line 220, in get_detection_dataset_dicts dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in dataset_names] File "/home/cxf/detectron2-0.3/detectron2/data/build.py", line 220, in dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in dataset_names] File "/home/cxf/detectron2-0.3/detectron2/data/catalog.py", line 58, in get return f() File "/home/cxf/detectron2-0.3/detectron2/data/datasets/coco.py", line 469, in DatasetCatalog.register(name, lambda: load_coco_json(json_file, image_root, name)) File "/home/cxf/detectron2-0.3/detectron2/data/datasets/coco.py", line 71, in load_coco_json meta.thing_classes = thing_classes File "/home/cxf/detectron2-0.3/detectron2/data/catalog.py", line 148, in setattr assert 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'] != ['background', 'table', 'index']

Could you give a detailed document about training in README.MD? About how to set datasets, how to modify config...

wondervictor commented 2 years ago

Hi @caoxuefengzz, you should take care of the following:

  1. the dataset, converting the dataset into COCO format.
  2. the NUM_CLASSES, which determines the classes of your dataset.
  3. the NUM_MASKS, which determines the maximum instances in your dataset. (I suggest that you can leave it 100 as default.)
  4. the evaluation For more details, you can refer to the official guide for custom training.
caoxuefengzz commented 2 years ago

Thank you for your reply !
I have trained my dataset by learnning from detectron2 github. If you have time, I suggest you give a detailed train tutorial in your README.MD. because it's diffcult for a newer of detectron2 to train sparseinst.

wondervictor commented 2 years ago

Hi, @caoxuefengzz, your suggestion is good and we'll add it. This issue will be closed, you can open a new issue if you have other problems or reopen it. Thanks for your interest in SparseInst 😊 . If you find it useful in your work or research, could you give us a star 🌟 or help us recommend SparseInst to your friends.

siddagra commented 2 years ago

Changing NUM_CLASSES causes CUDA error 59: Device-side assert triggered. Due to some sort of mismatch ig. Any way to enable only two classes and avoid this mismatch?

Changing NUM_CLASSES from 80 to 2, caused this. Also, any way to load the pretrained SparseInst models and continue training for finetuning?