diff --git a/test.py b/test.py index 79984de..356ec8e 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 4148c64..562cfa2 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):