open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.02k stars 2.58k forks source link

ShelterDataset #2013

Closed Manith2000 closed 2 years ago

Manith2000 commented 2 years ago

Trying to train a mask_rcnn_r50_fpn_1x model by running the command python tools/train.py configs/mask_rcnn_r50_fpn_1x.py --gpus 1 --work_dir work_dirs/output.

However I get the following key error saying not in the dataset registry:

Traceback (most recent call last):
  File "tools/train.py", line 143, in <module>
    main()
  File "tools/train.py", line 118, in main
    datasets = [build_dataset(cfg.data.train)]
  File "/eos/home-i03/m/madikari/Documents/CERN_Project_Repo/UNOSAT-ShelterAI/DetectoRS-master-UNOSAT/mmdetection/mmdet/datasets/builder.py", line 89, in build_dataset
    dataset = build_from_cfg(cfg, DATASETS, default_args)
  File "/eos/home-i03/m/madikari/Documents/CERN_Project_Repo/UNOSAT-ShelterAI/DetectoRS-master-UNOSAT/mmdetection/mmdet/utils/registry.py", line 69, in build_from_cfg
    raise KeyError('{} is not in the {} registry'.format(
KeyError: 'ShelterDataset is not in the dataset registry'

I have already tried implementing some of the suggestions on previous issues with the same error, but none of them worked for me. Already tried: https://github.com/open-mmlab/mmdetection/issues/6792 , https://github.com/open-mmlab/mmdetection/issues/1324#issuecomment-958694654 , https://github.com/open-mmlab/mmdetection/issues/8458 ,

These are the dataset settings on my config file :

dataset_type = 'ShelterDataset'
data_root = 'data/UNOSAT_BF/'
img_norm_cfg = dict(
    mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
    dict(type='Resize', img_scale=[(256,256),(1024,1024)],multiscale_mode='range',keep_ratio=True),
    dict(type='RandomFlip', flip_ratio=0.5),
    dict(type='Normalize', **img_norm_cfg),
    dict(type='Pad', size_divisor=32),
    dict(type='DefaultFormatBundle'),
    dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']),
]
test_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(
        type='MultiScaleFlipAug',
        img_scale=[(256, 256),(512, 512),(1024,1024)],
        flip=True,
        transforms=[
            dict(type='Resize', keep_ratio=True),
            dict(type='RandomFlip'),
            dict(type='Normalize', **img_norm_cfg),
            dict(type='Pad', size_divisor=32),
            dict(type='ImageToTensor', keys=['img']),
            dict(type='Collect', keys=['img']),
        ])
]
data = dict(
    # imgs_per_gpu=1,
    samples_per_gpu=1,
    workers_per_gpu=1,
    train=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/tiles_img_train.json',
        img_prefix=data_root + 'train/',
        pipeline=train_pipeline),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/tiles_img_eval.json',
        img_prefix=data_root + 'eval/',
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/tiles_img_eval.json',
        img_prefix=data_root + 'eval/',
        pipeline=test_pipeline))
evaluation = dict(interval=1, metric=['bbox', 'segm'])

My init.py file:


from .cityscapes import CityscapesDataset
from .coco import CocoDataset
from .coco import ShelterDataset
from .coco_panoptic import CocoPanopticDataset
from .custom import CustomDataset
from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset,
                               MultiImageMixDataset, RepeatDataset)
from .deepfashion import DeepFashionDataset
from .openimages import OpenImagesChallengeDataset, OpenImagesDataset
from .samplers import DistributedGroupSampler, DistributedSampler, GroupSampler
from .utils import (NumClassCheckHook, get_loading_pipeline,
                    replace_ImageToTensor)
from .voc import VOCDataset
from .wider_face import WIDERFaceDataset
from .xml_style import XMLDataset

__all__ = [
    'CustomDataset', 'XMLDataset', 'CocoDataset', 'DeepFashionDataset',
    'VOCDataset', 'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler',
    'DistributedSampler', 'build_dataloader', 'ConcatDataset', 'RepeatDataset',
    'ClassBalancedDataset', 'WIDERFaceDataset', 'DATASETS','PIPELINES',
    'build_dataset', 'replace_ImageToTensor', 'get_loading_pipeline',
    'NumClassCheckHook', 'CocoPanopticDataset', 'MultiImageMixDataset',
    'OpenImagesDataset', 'OpenImagesChallengeDataset','DATASETS', 'build_dataset', 'dataset',
    'ShelterDataset',
]
MengzhangLI commented 2 years ago

Hi, the log shows registry mechanism searching under your MMDetection codebase rather than path of MMSegmentation, if you use MMDet you can raise an issue at MMDetction and if you use MMSegmentation I suggest you check your current working directory.

Best,