[Fix] Fix format error in `test.py` when metric returns `np.ndarray` (#441)
* Update test.py Fix the output format error when metric-options is specified * Update tools/test.py Co-authored-by: Ma Zerun <mzr1996@163.com> * Update test.py delete "," after round(out, 2) * Update test.py delete else * Update tools/test.py Co-authored-by: Ma Zerun <mzr1996@163.com> Co-authored-by: Ma Zerun <mzr1996@163.com>pull/471/head
parent
90496b4687
commit
e166ee7c0c
|
@ -2,6 +2,7 @@
|
|||
import argparse
|
||||
import os
|
||||
import warnings
|
||||
from numbers import Number
|
||||
|
||||
import mmcv
|
||||
import numpy as np
|
||||
|
@ -186,7 +187,13 @@ def main():
|
|||
args.metric_options)
|
||||
results.update(eval_results)
|
||||
for k, v in eval_results.items():
|
||||
print(f'\n{k} : {v:.2f}')
|
||||
if isinstance(v, np.ndarray):
|
||||
v = [round(out, 2) for out in v.tolist()]
|
||||
elif isinstance(v, Number):
|
||||
v = round(v, 2)
|
||||
else:
|
||||
raise ValueError(f'Unsupport metric type: {type(v)}')
|
||||
print(f'\n{k} : {v}')
|
||||
if args.out:
|
||||
if 'none' not in args.out_items:
|
||||
scores = np.vstack(outputs)
|
||||
|
|
Loading…
Reference in New Issue