Skip to content

Tex table #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python-sdk/nuscenes/eval/detection/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DETECTION_NAMES = ['car', 'truck', 'bus', 'trailer', 'construction_vehicle', 'pedestrian', 'motorcycle', 'bicycle',
'traffic_cone', 'barrier']
PRETTY_DETECTION_NAMES = {'car': 'Car', 'truck': 'Truck', 'bus': 'Bus', 'trailer': 'Trailer',
'construction_vehicle': 'Construction Vehicle', 'pedestrian': 'Pedestrian',
'construction_vehicle': 'Constr. Veh.', 'pedestrian': 'Pedestrian',
'motorcycle': 'Motorcycle', 'bicycle': 'Bicycle', 'traffic_cone': 'Traffic Cone',
'barrier': 'Barrier'}

Expand Down
64 changes: 63 additions & 1 deletion python-sdk/nuscenes/eval/detection/render.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# nuScenes dev-kit.
# Code written by Holger Caesar, 2019.
# Code written by Holger Caesar and Alex Lang, 2019.
# Licensed under the Creative Commons [see licence.txt]

from typing import Dict

import numpy as np
import json
from matplotlib import pyplot as plt

from nuscenes.eval.detection.utils import boxes_to_sensor
Expand Down Expand Up @@ -250,3 +251,64 @@ def summary_plot(md_list: MetricDataList,
if savepath is not None:
plt.savefig(savepath)
plt.close()


def detailed_results_table_tex(metrics_path: str, output_path: str) -> None:
"""
Renders a detailed results table in tex.
:param metrics_path: path to a serialized DetectionMetrics file.
:param output_path: path to the output file.
:return:
"""

with open(metrics_path, 'r') as f:
metrics = json.load(f)

tex = ''
tex += '\\begin{table}[]\n'
tex += '\\small\n'
tex += '\\begin{tabular}{| c | c | c | c | c | c | c |} \\hline\n'
tex += '\\textbf{Class} & \\textbf{AP} & \\textbf{ATE} & \\textbf{ASE} & \\textbf{AOE} & ' \
'\\textbf{AVE} & ' \
'\\textbf{AAE} \\\\ \\hline ' \
'\\hline\n'
for name in DETECTION_NAMES:
ap = metrics['label_aps'][name]['2.0'] * 100
ate = metrics['label_tp_errors'][name]['trans_err']
ase = metrics['label_tp_errors'][name]['scale_err']
aoe = metrics['label_tp_errors'][name]['orient_err']
ave = metrics['label_tp_errors'][name]['vel_err']
aae = metrics['label_tp_errors'][name]['attr_err']
tex_name = PRETTY_DETECTION_NAMES[name]
if name == 'traffic_cone':
tex += '{} & {:.1f} & {:.2f} & {:.2f} & N/A & N/A & N/A \\\\ \\hline\n'.format(
tex_name, ap, ate, ase)
elif name == 'barrier':
tex += '{} & {:.1f} & {:.2f} & {:.2f} & {:.2f} & N/A & N/A \\\\ \\hline\n'.format(
tex_name, ap, ate, ase, aoe)
else:
tex += '{} & {:.1f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} \\\\ ' \
'\\hline\n'.format(tex_name, ap, ate, ase, aoe, ave, aae)

map_ = metrics['mean_ap'] * 100
mate = metrics['tp_errors']['trans_err']
mase = metrics['tp_errors']['scale_err']
maoe = metrics['tp_errors']['orient_err']
mave = metrics['tp_errors']['vel_err']
maae = metrics['tp_errors']['attr_err']
tex += '\\hline {} & {:.1f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} \\\\ ' \
'\\hline\n'.format('\\textbf{Mean}', map_, mate, mase, maoe, mave, maae)

tex += '\\end{tabular}\n'
tex += '\\caption{Detailed detection performance. '
tex += 'AP: average precision (\%), ' \
'ATE: average translation error ($m$), ' \
'ASE: average scale error ($1-IOU$), ' \
'AOE: average orientation error (rad.), ' \
'AVE: average velocity error ($m/s$), ' \
'AAE: average attribute error ($1-acc$). ' \
'nuScenes Detection Score (NDS) = {:.1f} \%{}\n'.format(metrics['weighted_sum'] * 100, '}')
tex += '\\end{table}\n'

with open(output_path, 'w') as f:
f.write(tex)