(mean_ap, results, dataset=None)
Print mAP and results of each class.

    Args:
        mean_ap(float): calculated from `eval_map`
        results(list): calculated from `eval_map`
        dataset(None or str or list): dataset name or dataset classes.
Print mAP and results of each class.
Print mAP and results of each class .
def print_map_summary(mean_ap, results, dataset=None):
    """Print mAP and results of each class.

    Args:
        mean_ap(float): calculated from `eval_map`
        results(list): calculated from `eval_map`
        dataset(None or str or list): dataset name or dataset classes.
    """
    num_scales = len(results[0]['ap']) if isinstance(results[0]['ap'],
                                                     np.ndarray) else 1
    num_classes = len(results)

    recalls = np.zeros((num_scales, num_classes), dtype=np.float32)
    precisions = np.zeros((num_scales, num_classes), dtype=np.float32)
    aps = np.zeros((num_scales, num_classes), dtype=np.float32)
    num_gts = np.zeros((num_scales, num_classes), dtype=int)
    for i, cls_result in enumerate(results):
        if cls_result['recall'].size > 0:
            recalls[:, i] = np.array(cls_result['recall'], ndmin=2)[:, -1]
            precisions[:, i] = np.array(
                cls_result['precision'], ndmin=2)[:, -1]
        aps[:, i] = cls_result['ap']
        num_gts[:, i] = cls_result['num_gts']

    if dataset is None:
        label_names = [str(i) for i in range(1, num_classes + 1)]
    elif mmcv.is_str(dataset):
        label_names = get_classes(dataset)
    else:
        label_names = dataset

    if not isinstance(mean_ap, list):
        mean_ap = [mean_ap]
    header = ['class', 'gts', 'dets', 'recall', 'precision', 'ap']
    for i in range(num_scales):
        table_data = [header]
        for j in range(num_classes):
            row_data = [
                label_names[j], num_gts[i, j], results[j]['num_dets'],
                '{:.3f}'.format(recalls[i, j]), '{:.3f}'.format(
                    precisions[i, j]), '{:.3f}'.format(aps[i, j])
            ]
            table_data.append(row_data)
        table_data.append(['mAP', '', '', '', '', '{:.3f}'.format(mean_ap[i])])
        table = AsciiTable(table_data)
        table.inner_footing_row_border = True
        print(table.table)
def print_map_summary ( mean_ap , results , dataset = None ) : num_scales = len ( results [ 0 ] [ 'ap' ] ) if isinstance ( results [ 0 ] [ 'ap' ] , np . ndarray ) else 1 num_classes = len ( results ) recalls = np . zeros ( ( num_scales , num_classes ) , dtype = np . float32 ) precisions = np . zeros ( ( num_scales , num_classes ) , dtype = np . float32 ) aps = np . zeros ( ( num_scales , num_classes ) , dtype = np . float32 ) num_gts = np . zeros ( ( num_scales , num_classes ) , dtype = int ) for i , cls_result in enumerate ( results ) : if cls_result [ 'recall' ] . size > 0 : recalls [ : , i ] = np . array ( cls_result [ 'recall' ] , ndmin = 2 ) [ : , - 1 ] precisions [ : , i ] = np . array ( cls_result [ 'precision' ] , ndmin = 2 ) [ : , - 1 ] aps [ : , i ] = cls_result [ 'ap' ] num_gts [ : , i ] = cls_result [ 'num_gts' ] if dataset is None : label_names = [ str ( i ) for i in range ( 1 , num_classes + 1 ) ] elif mmcv . is_str ( dataset ) : label_names = get_classes ( dataset ) else : label_names = dataset if not isinstance ( mean_ap , list ) : mean_ap = [ mean_ap ] header = [ 'class' , 'gts' , 'dets' , 'recall' , 'precision' , 'ap' ] for i in range ( num_scales ) : table_data = [ header ] for j in range ( num_classes ) : row_data = [ label_names [ j ] , num_gts [ i , j ] , results [ j ] [ 'num_dets' ] , '{:.3f}' . format ( recalls [ i , j ] ) , '{:.3f}' . format ( precisions [ i , j ] ) , '{:.3f}' . format ( aps [ i , j ] ) ] table_data . append ( row_data ) table_data . append ( [ 'mAP' , '' , '' , '' , '' , '{:.3f}' . format ( mean_ap [ i ] ) ] ) table = AsciiTable ( table_data ) table . inner_footing_row_border = True print ( table . table )