open-mmlab/mmdetection

How to get validation loss using mmdetection version 2.28.2?

CarolinRue opened this issue · 1 comments

Hii, I am new to mmdetection and want to get the validation loss. I found this #505.
I added workflow = [('train', 1), ('val', 1)] but then I get this error

File "tools/train.py", line 247, in <module>
    main()
  File "tools/train.py", line 226, in main
    'pipeline', cfg.data.train.dataset.get('pipeline'))
  File "/home/mm/miniconda3/envs/mmdet/lib/python3.8/site-packages/mmcv/utils/config.py", line 52, in __getattr__
    raise ex
AttributeError: 'ConfigDict' object has no attribute 'dataset'

I am also not sure how to set this "Also you need to modify the data_loaders in this line, your need to append your valset_loader at the end of data_loaders", because in version 2.28.2 the data_loaders looks different. In version 2.28.2 there is no _dist_train function, here it looks like this:

def train_detector(model,
                   dataset,
                   cfg,
                   distributed=False,
                   validate=False,
                   timestamp=None,
                   meta=None):

    cfg = compat_cfg(cfg)
    logger = get_root_logger(log_level=cfg.log_level)

    # prepare data loaders
    dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset]

    runner_type = 'EpochBasedRunner' if 'runner' not in cfg else cfg.runner[
        'type']

    train_dataloader_default_args = dict(
        samples_per_gpu=2,
        workers_per_gpu=2,
        # `num_gpus` will be ignored if distributed
        num_gpus=len(cfg.gpu_ids),
        dist=distributed,
        seed=cfg.seed,
        runner_type=runner_type,
        persistent_workers=False)

    train_loader_cfg = {
        **train_dataloader_default_args,
        **cfg.data.get('train_dataloader', {})
    }

    data_loaders = [build_dataloader(ds, **train_loader_cfg) for ds in dataset]

Can somebody help me to get the validation loss in mmdetection version 2.28.2?