Skip to content

Commit 4371d05

Browse files
oscar-nutonomyAlex-nutonomy
authored andcommitted
Tex table (#91)
* added reder tex table * cleaned up tex render method * minor changes
1 parent 23dd1a8 commit 4371d05

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

python-sdk/nuscenes/eval/detection/render.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# nuScenes dev-kit.
2-
# Code written by Holger Caesar, 2019.
2+
# Code written by Holger Caesar and Alex Lang, 2019.
33
# Licensed under the Creative Commons [see licence.txt]
44

55
from typing import Dict
66

77
import numpy as np
8+
import json
89
from matplotlib import pyplot as plt
910

1011
from nuscenes.eval.detection.utils import boxes_to_sensor
@@ -254,3 +255,64 @@ def summary_plot(md_list: MetricDataList,
254255
if savepath is not None:
255256
plt.savefig(savepath)
256257
plt.close()
258+
259+
260+
def detailed_results_table_tex(metrics_path: str, output_path: str) -> None:
261+
"""
262+
Renders a detailed results table in tex.
263+
:param metrics_path: path to a serialized DetectionMetrics file.
264+
:param output_path: path to the output file.
265+
:return:
266+
"""
267+
268+
with open(metrics_path, 'r') as f:
269+
metrics = json.load(f)
270+
271+
tex = ''
272+
tex += '\\begin{table}[]\n'
273+
tex += '\\small\n'
274+
tex += '\\begin{tabular}{| c | c | c | c | c | c | c |} \\hline\n'
275+
tex += '\\textbf{Class} & \\textbf{AP} & \\textbf{ATE} & \\textbf{ASE} & \\textbf{AOE} & ' \
276+
'\\textbf{AVE} & ' \
277+
'\\textbf{AAE} \\\\ \\hline ' \
278+
'\\hline\n'
279+
for name in DETECTION_NAMES:
280+
ap = metrics['label_aps'][name]['2.0'] * 100
281+
ate = metrics['label_tp_errors'][name]['trans_err']
282+
ase = metrics['label_tp_errors'][name]['scale_err']
283+
aoe = metrics['label_tp_errors'][name]['orient_err']
284+
ave = metrics['label_tp_errors'][name]['vel_err']
285+
aae = metrics['label_tp_errors'][name]['attr_err']
286+
tex_name = PRETTY_DETECTION_NAMES[name]
287+
if name == 'traffic_cone':
288+
tex += '{} & {:.1f} & {:.2f} & {:.2f} & N/A & N/A & N/A \\\\ \\hline\n'.format(
289+
tex_name, ap, ate, ase)
290+
elif name == 'barrier':
291+
tex += '{} & {:.1f} & {:.2f} & {:.2f} & {:.2f} & N/A & N/A \\\\ \\hline\n'.format(
292+
tex_name, ap, ate, ase, aoe)
293+
else:
294+
tex += '{} & {:.1f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} \\\\ ' \
295+
'\\hline\n'.format(tex_name, ap, ate, ase, aoe, ave, aae)
296+
297+
map_ = metrics['mean_ap'] * 100
298+
mate = metrics['tp_errors']['trans_err']
299+
mase = metrics['tp_errors']['scale_err']
300+
maoe = metrics['tp_errors']['orient_err']
301+
mave = metrics['tp_errors']['vel_err']
302+
maae = metrics['tp_errors']['attr_err']
303+
tex += '\\hline {} & {:.1f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} & {:.2f} \\\\ ' \
304+
'\\hline\n'.format('\\textbf{Mean}', map_, mate, mase, maoe, mave, maae)
305+
306+
tex += '\\end{tabular}\n'
307+
tex += '\\caption{Detailed detection performance. '
308+
tex += 'AP: average precision (\%), ' \
309+
'ATE: average translation error ($m$), ' \
310+
'ASE: average scale error ($1-IOU$), ' \
311+
'AOE: average orientation error (rad.), ' \
312+
'AVE: average velocity error ($m/s$), ' \
313+
'AAE: average attribute error ($1-acc$). ' \
314+
'nuScenes Detection Score (NDS) = {:.1f} \%{}\n'.format(metrics['weighted_sum'] * 100, '}')
315+
tex += '\\end{table}\n'
316+
317+
with open(output_path, 'w') as f:
318+
f.write(tex)

0 commit comments

Comments
 (0)