mmdetection: [Bug] AttributeError: 'ConfigDict' object has no attribute 'log_level'

Prerequisite

Task

I have modified the scripts/configs, or I’m working on my own tasks/models/datasets.

Branch

master branch https://github.com/open-mmlab/mmdetection

Environment

I have installed all of the required packages that are required to run mmDetection. I have also tried reinstalling packages, setting up new Conda environments and reinstalling mmDetection. I am currently working on training mmDetection with a custom dataset using the tutorial on the official mmLab website, however something has gone wrong. I try to run the programme using the command at the bottom of the tutorial however it does not work.

Reproduces the problem - code sample

# The new config inherits a base config to highlight the necessary modification
base_ = 'configs/mask_rcnn/mask_rcnn_r50_caffe_fpn_1x_coco.py'

# We also need to change the num_classes in head to match the dataset's annotation
# dict is a python dictionary object which is used to save or load models from PyTorch

model=dict(
    roi_head=dict(
        # defining the number of classes a bounding box can go around
        bbox_head=dict(num_classes=1),
            # 
        mask_head=dict(num_classes=1)))


    # Modify dataset related settings
dataset_type = 'COCODataset'
    #Defining the classes
classes = ('Pantograph')
    #grabbing the dataset so it can read the classes and train off the dataset
data=dict(
    train=dict(
        dataset=dict(
            img_prefix='balloon/train',
            classes=classes,
            ann_file='balloon/train/Pan2_COCO.json'),
    val=dict(
        img_prefix='balloon/val',
        classes=classes,
        ann_file='balloon/val/Pan2_COCO.json'),
    test=dict(
        img_prefix='balloon/val',
        classes=classes,
        ann_file='val/Pan2_COCO.json')))

# We can use the pre-trained Mask RCNN model to obtain higher performance
load_from = 'checkpoints/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco_bbox_mAP-0.408__segm_mAP-0.37_20200504_163245-42aa3d00.pth'

Reproduces the problem - command or script

python tools/train.py configs/balloon/mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_balloon.py

Reproduces the problem - error message

Traceback (most recent call last):
  File "tools/train.py", line 244, in <module>
    main()
  File "tools/train.py", line 184, in main
    logger = get_root_logger(log_file=log_file, log_level=cfg.log_level)
  File "/home/dtl-admin/miniconda3/envs/mmdet/lib/python3.8/site-packages/mmcv/utils/config.py", line 519, in __getattr__
    return getattr(self._cfg_dict, name)
  File "/home/dtl-admin/miniconda3/envs/mmdet/lib/python3.8/site-packages/mmcv/utils/config.py", line 50, in __getattr__
    raise ex
AttributeError: 'ConfigDict' object has no attribute 'log_level'

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 35 (16 by maintainers)

Most upvoted comments

you can have a try add log_level = 'INFO' in your config and try again

@sanbuphy I’ve tried it with the file conversion you sent me and it works so what do I need to do to get it to work with my dataset as they both look extremely different?

You should try to make your data the same as that dataset. Check whether the label and coco format are correct.

you can refer this config:


_base_ = './faster_rcnn_r50_fpn_1x_voc.py'

model = dict(
    roi_head=dict(
        bbox_head=dict(num_classes=7)))

dataset_type = 'CocoDataset'
data_root = 'data/my_coco/'

classes = ('fish', 'jellyfish', 'penguin', 'puffin','shark','starfish','stingray',)
data = dict(
    train=dict( 
        ann_file=data_root + 'annotations/train.json',
        img_prefix=data_root + 'train/',
        classes=classes,
        ),
    val=dict(
        ann_file=data_root + 'annotations/val.json',
        img_prefix=data_root + 'val/',
        classes=classes,
        ),
    test=dict(
        ann_file=data_root + 'annotations/test.json',
        img_prefix=data_root + 'test/',
        classes=classes,
        ))

@sanbuphy I have managed to get the directories working however now I am getting another new error Traceback (most recent call last): File "tools/train.py", line 264, in <module> main() File "tools/train.py", line 236, in main datasets = [build_dataset(cfg.data.train)] File "/home/dtl-admin/miniconda3/envs/mmdet/lib/python3.8/site-packages/mmdet/datasets/builder.py", line 82, in build_dataset dataset = build_from_cfg(cfg, DATASETS, default_args) File "/home/dtl-admin/miniconda3/envs/mmdet/lib/python3.8/site-packages/mmcv/utils/registry.py", line 72, in build_from_cfg raise type(e)(f'{obj_cls.__name__}: {e}') TypeError: CocoDataset: __init__() got an unexpected keyword argument 'dataset'

notice that:

data=dict(
    train=dict(
        dataset=dict(
            img_prefix='balloon/train',
            classes=classes,
            ann_file='balloon/train/Pan2_COCO.json'),

it should be

data=dict(
    train=dict(
            img_prefix='balloon/train',
            classes=classes,
            ann_file='balloon/train/Pan2_COCO.json'),

or you can refer this

data = dict(
    train=dict( 
        ann_file=data_root + 'annotations/train.json',
        img_prefix=data_root + 'train/',
        classes=classes,
        ),
    val=dict(
        ann_file=data_root + 'annotations/val.json',
        img_prefix=data_root + 'val/',
        classes=classes,
        ),
    test=dict(
        ann_file=data_root + 'annotations/test.json',
        img_prefix=data_root + 'test/',
        classes=classes,
        ))