File size: 3,654 Bytes
56bd2b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright (c) Meta Platforms, Inc. and affiliates
from termcolor import colored
import itertools
from tabulate import tabulate
import logging

logger = logging.getLogger(__name__)

def print_ap_category_histogram(dataset, results):
    """
    Prints AP performance for each category.
    Args:
        results: dictionary; each entry contains information for a dataset
    """
    num_classes = len(results)
    N_COLS = 9
    data = list(
        itertools.chain(
            *[
                [
                    cat,
                    out["AP2D"],
                    out["AP3D"],
                ]
                for cat, out in results.items()
            ]
        )
    )
    data.extend([None] * (N_COLS - (len(data) % N_COLS)))
    data = itertools.zip_longest(*[data[i::N_COLS] for i in range(N_COLS)])
    table = tabulate(
        data,
        headers=["category", "AP2D", "AP3D"] * (N_COLS // 2),
        tablefmt="pipe",
        numalign="left",
        stralign="center",
    )
    logger.info(
        "Performance for each of {} categories on {}:\n".format(num_classes, dataset)
        + colored(table, "cyan")
    )


def print_ap_analysis_histogram(results):
    """
    Prints AP performance for various IoU thresholds and (near, medium, far) objects.
    Args:
        results: dictionary. Each entry in results contains outputs for a dataset
    """
    metric_names = ["AP2D", "AP3D", "AP3D@15", "AP3D@25", "AP3D@50", "AP3D-N", "AP3D-M", "AP3D-F"]
    N_COLS = 10
    data = []
    for name, metrics in results.items():
        data_item = [name, metrics["iters"], metrics["AP2D"], metrics["AP3D"], metrics["AP3D@15"], metrics["AP3D@25"], metrics["AP3D@50"], metrics["AP3D-N"], metrics["AP3D-M"], metrics["AP3D-F"]]
        data.append(data_item)
    table = tabulate(
        data,
        headers=["Dataset", "#iters", "AP2D", "AP3D", "AP3D@15", "AP3D@25", "AP3D@50", "AP3D-N", "AP3D-M", "AP3D-F"],
        tablefmt="grid",
        numalign="left",
        stralign="center",
    )
    logger.info(
        "Per-dataset performance analysis on test set:\n"
        + colored(table, "cyan")
    )


def print_ap_dataset_histogram(results):
    """
    Prints AP performance for each dataset.
    Args:
        results: list of dicts. Each entry in results contains outputs for a dataset
    """
    metric_names = ["AP2D", "AP3D"]
    N_COLS = 4
    data = []
    for name, metrics in results.items():
        data_item = [name, metrics["iters"], metrics["AP2D"], metrics["AP3D"]]
        data.append(data_item)
    table = tabulate(
        data,
        headers=["Dataset", "#iters", "AP2D", "AP3D"],
        tablefmt="grid",
        numalign="left",
        stralign="center",
    )
    logger.info(
        "Per-dataset performance on test set:\n"
        + colored(table, "cyan")
    )


def print_ap_omni_histogram(results):
    """
    Prints AP performance for Omni3D dataset.
    Args:
        results: list of dicts. Each entry in results contains outputs for a dataset
    """
    metric_names = ["AP2D", "AP3D"]
    N_COLS = 4
    data = []
    for name, metrics in results.items():
        data_item = [name, metrics["iters"], metrics["AP2D"], metrics["AP3D"]]
        data.append(data_item)
    table = tabulate(
        data,
        headers=["Dataset", "#iters", "AP2D", "AP3D"],
        tablefmt="grid",
        numalign="left",
        stralign="center",
    )
    logger.info("Omni3D performance on test set. The numbers below should be used to compare to others approaches on Omni3D, such as Cube R-CNN")
    logger.info(
        "Performance on Omni3D:\n"
        + colored(table, "magenta")
    )