[error] SyntaxError: keyword argument repeated

펭귄은 mmdetection을 사용해서 object detection model을 학습하던 중 아래와 같은 에러를 만났다.

SyntaxError: keyword argument repeated

 

위 에러가 발생한 원인은 아래와 같다.

  • config 파일 내에 동일한 키워드가 중복되어 있다.

펭귄은 Convnext 모델을 backbone으로 하는 Cascade-RCNN 모델을 학습하기 위해서 config 파일을 작성했다.

 

config 파일을 확인해보니, 아래와 같이 같은 키워드가 중복되어 있었다.

 

image
mmdetection config

 

펭귄의 경우 drop_path_rate 키워드가 중복되어 있었다.

 

이 경우 drop_path_rate를 0.6으로 설정해야 할지, 0.7로 설정해야 할지 모호하기 때문에 에러를 발생시킨다.

 

위 에러는 아래와 같은 방법으로 해결할 수 있다.

  • 중복된 키워드를 삭제한다

펭귄은 drop_path_rate를 0.6으로 지정할 생각이므로, 중복된 구문을 삭제했다.

 

backbone=dict(
    type='mmpretrain.ConvNeXt',
    arch='small',
    out_indices=[0, 1, 2, 3],
    drop_path_rate=0.6,
    layer_scale_init_value=1.0,
    gap_before_final_norm=False,
    init_cfg=dict(
        type='Pretrained', checkpoint=checkpoint_file, prefix='backbone.')),

 

 

mmdetection은 config 파일만 관리하면 되어서 사용이 편리하지만, mmdetection 자체의 사용법을 익히는 과정이 번거로운 것 같다.

 


출처

  • Penguin by Ruby from "https://thenounproject.com/browse/icons/term/penguin/" Noun Project (CC BY 3.0)