SwinTransformer / Swin-Transformer-Object-Detection

This is an official implementation for "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" on Object Detection and Instance Segmentation.
https://arxiv.org/abs/2103.14030
Apache License 2.0
1.82k stars 379 forks source link

i have problem when using my own dataset with cascade_mask_rcnn_swin_tiny for detection #20

Open di-dii opened 3 years ago

di-dii commented 3 years ago

thank you for your great work, but there is a problem when i train with my own data i can't figure out why this happen i've changed all num_class to my num this is traceback:

Traceback (most recent call last): File "./tools/train.py", line 187, in main() File "./tools/train.py", line 183, in main meta=meta) File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/apis/train.py", line 185, in train_detector runner.run(data_loaders, cfg.workflow) File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 125, in run epoch_runner(data_loaders[i], **kwargs) File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 47, in train for i, data_batch in enumerate(self.data_loader): File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 435, in next data = self._next_data() File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data return self._process_data(data) File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data data.reraise() File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/_utils.py", line 428, in reraise raise self.exc_type(msg) cv2.error: Caught error in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop data = fetcher.fetch(index) File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/datasets/custom.py", line 193, in getitem data = self.prepare_train_img(idx) File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/datasets/custom.py", line 216, in prepare_train_img return self.pipeline(results) File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/datasets/pipelines/compose.py", line 40, in call data = t(data) File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/datasets/pipelines/transforms.py", line 534, in call self._pad_masks(results) File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/datasets/pipelines/transforms.py", line 515, in _pad_masks results[key] = results[key].pad(pad_shape, pad_val=self.pad_val) File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/core/mask/structures.py", line 305, in pad for mask in self.masks File "/home/ding/chenTY/Swin-Transformer-Object-Detection/mmdet/core/mask/structures.py", line 305, in for mask in self.masks File "/home/ding/miniconda3/envs/mmlab/lib/python3.7/site-packages/mmcv/image/geometric.py", line 450, in impad value=pad_val) cv2.error: OpenCV(4.5.1) /tmp/pip-req-build-7m_g9lbm/opencv/modules/core/src/copy.cpp:1445: error: (-215:Assertion failed) top >= 0 && bottom >= 0 && left >= 0 && right >= 0 && _src.dims() <= 2 in function 'copyMakeBorder'

AnhMinhTran commented 3 years ago

Hitching your question, can I ask how did you use your own dataset since there's no train_dir args and does it use the coco dataset format?

giorgiozannini commented 3 years ago

I also can't use it for detection! tried removing anything mask-related from the configs but can't make it work.

javierztl commented 3 years ago

You should comment out all 'mask' related in

  1. cascade_mask_rcnn_swin_small_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x.py(your used config)
  2. config/base/model/cascade_mask_rcnn_swin_fpn.py
  3. config/base/coco_instance.py(or modify to coco_detection.py from 1)
sure7018 commented 3 years ago

What specific settings of mask do I need to comment out

bfialkoff commented 3 years ago

25