From 519de28f4e8f890de04c1d79fa1bc6ff6fbfd4d0 Mon Sep 17 00:00:00 2001 From: lorenzo Date: Mon, 8 Jul 2019 17:12:57 +0200 Subject: [PATCH] add 20% in width pifpaf boxes --- src/eval/generate_kitti.py | 21 ++++++--------------- src/utils/pifpaf.py | 4 ++-- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/eval/generate_kitti.py b/src/eval/generate_kitti.py index 400f662..f77702b 100644 --- a/src/eval/generate_kitti.py +++ b/src/eval/generate_kitti.py @@ -43,19 +43,17 @@ def generate_kitti(model, dir_ann, p_dropout=0.2, n_dropout=0): list_basename = factory_basename(dir_ann) for basename in list_basename: path_calib = os.path.join(dir_kk, basename + '.txt') - annotations, kk, tt, _ = factory_file(path_calib, dir_ann, basename) + annotations, kk, tt = factory_file(path_calib, dir_ann, basename) boxes, keypoints = preprocess_pif(annotations, im_size=(1242, 374)) if not keypoints: cnt_no_file += 1 + continue else: # Run the network and the geometric baseline outputs, varss = monoloco.forward(keypoints, kk) dds_geom = eval_geometric(keypoints, kk, average_y=0.48) - if basename == '001782': - aa = 5 - # Save the file all_outputs = [outputs.detach().cpu(), varss.detach().cpu(), dds_geom] all_inputs = [boxes, keypoints] @@ -115,28 +113,21 @@ def factory_basename(dir_ann): return list_basename -def factory_file(path_calib, dir_ann, basename, ite=0): +def factory_file(path_calib, dir_ann, basename): """Choose the annotation and the calibration files. Stereo option with ite = 1""" - stereo_file = True p_left, p_right = get_calibration(path_calib) - if ite == 0: - kk, tt = p_left[:] - path_ann = os.path.join(dir_ann, basename + '.png.pifpaf.json') - else: - kk, tt = p_right[:] - path_ann = os.path.join(dir_ann + '_right', basename + '.png.pifpaf.json') + kk, tt = p_left[:] + path_ann = os.path.join(dir_ann, basename + '.png.pifpaf.json') try: with open(path_ann, 'r') as f: annotations = json.load(f) except FileNotFoundError: annotations = None - if ite == 1: - stereo_file = False - return annotations, kk, tt, stereo_file + return annotations, kk, tt def eval_geometric(keypoints, kk, average_y=0.48): diff --git a/src/utils/pifpaf.py b/src/utils/pifpaf.py index 9169a4e..5e0d166 100644 --- a/src/utils/pifpaf.py +++ b/src/utils/pifpaf.py @@ -21,9 +21,9 @@ def preprocess_pif(annotations, im_size=None): kps = prepare_pif_kps(dic['keypoints']) conf = float(np.mean(np.array(kps[2]))) - # Add 10% for y + # Add 10% for y and 20% for x delta_h = (box[3] - box[1]) / 10 - delta_w = (box[2] - box[0]) / 10 + delta_w = (box[2] - box[0]) / 5 assert delta_h > -5 and delta_w > -5, "Bounding box <=0" box[0] -= delta_w box[1] -= delta_h