Location>code7788 >text

MMdetection Problem Reporting mmdet/evaluation/metrics/coco_metric.py data[‘category_id’] = self.cat_ids[label] IndexError: list index out of range

Popularity:949 ℃/2024-11-09 11:45:49

Option 1: Some people say Add to your own defined conifg file

metainfo = {
    'classes': ('class1','class2', 'class2',),
    'palette': [
        (220, 20, 60), (221, 11, 22),(221, 11, 42),
    ]
}

 

Option 2: Modify the contents of the mmdet/evaluation/metrics file. mmdet is mmdet under python/site-package.

1 modifications mmdet/evaluation/functional/class_names.py

def coco_classes() -> list:
    """Class names of COCO."""
    return [

        'clas1','class2','class3',

    ]

2 Modify mmdet/datasets/

METAINFO = {
        'classes':('class1','class2','class3',), 
        # palette is a list of color tuples, which is used for visualization.
        'palette':  [ (220, 20, 60), (221, 11, 22),(221, 11, 42),]    
    }

Option 3: I tried, it still did not work, I feel that this is a bug in MMdetection, and then print out the label self.cat_ids in the reported error, respectively.

1 After completing scenarios one and two If the label is out of the range of the number of classes you have set, you can check the config file for num_classes=3 in the original config for the model (usually under the model subfolder in the _base_ folder);

2 If it's a no-questions-asked; then it must be the self.cat_ids dimension is smaller than the number of classes you set, then you can choose to be simple and rough, directly in mmdet/evaluation/metrics/coco_metric.py in def compute_metrics(self, results: list) -> Dict[ str, float]: part, directly modify self.cat_ids = [0, 1]; the problem is definitely solved!