From f991f2f4d5da786efe159f731b143f17cc1948dd Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 20 Jul 2019 17:14:07 +0200 Subject: [PATCH] updates --- test.py | 4 ++-- utils/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test.py b/test.py index 79984de2..356ec8e4 100644 --- a/test.py +++ b/test.py @@ -102,8 +102,8 @@ def test(cfg, for di, d in enumerate(pred): jdict.append({'image_id': image_id, 'category_id': coco91class[int(d[6])], - 'bbox': [float3(x) for x in box[di]], - 'score': float(format('.5f', d[4]))}) + 'bbox': [floatn(x, 3) for x in box[di]], + 'score': floatn(d[4], 5)}) # Clip boxes to image bounds clip_coords(pred, (height, width)) diff --git a/utils/utils.py b/utils/utils.py index 4148c645..562cfa27 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -23,8 +23,8 @@ np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format}) cv2.setNumThreads(0) -def float3(x): # format floats to 3 decimals - return float(format(x, '.3f')) +def floatn(x, n=3): # format floats to n decimals + return float(format(x, '.%gf' % n)) def init_seeds(seed=0):