simplify ground-truth and --show_all

This commit is contained in:
Lorenzo 2021-03-22 14:59:48 +01:00
parent cfc9023cce
commit 5aee21743a
4 changed files with 12 additions and 20 deletions

View File

@ -66,26 +66,18 @@ def preprocess_monoloco(keypoints, kk, zero_center=False):
return kps_out
def factory_for_gt(im_size, focal_length=5.7, name=None, path_gt=None, verbose=True):
def factory_for_gt(im_size, focal_length=5.7, name=None, path_gt=None):
"""Look for ground-truth annotations file and define calibration matrix based on image size """
try:
if path_gt is not None:
assert os.path.exists(path_gt), "Ground-truth file not found"
with open(path_gt, 'r') as f:
dic_names = json.load(f)
if verbose:
logger.info('-' * 120 + "\nGround-truth file opened")
except (FileNotFoundError, TypeError):
if verbose:
logger.info('-' * 120 + "\nGround-truth file not found")
dic_names = {}
kk = dic_names[name]['K']
dic_gt = dic_names[name]
try:
kk = dic_names[name]['K']
dic_gt = dic_names[name]
if verbose:
logger.info("Matched ground-truth file!")
except KeyError:
dic_gt = None
# Without ground-truth-file
else:
if im_size[0] / im_size[1] > 2.5: # KITTI default
kk = [[718.3351, 0., 600.3891], [0., 718.3351, 181.5122], [0., 0., 1.]] # Kitti calibration
logger.info("Using KITTI calibration matrix...")

View File

@ -82,6 +82,9 @@ def factory_from_args(args):
if not args.images:
raise Exception("no image files given")
if args.path_gt is None:
args.show_all = True
# Models
dic_models = download_checkpoints(args)
args.checkpoint = dic_models['keypoints']

View File

@ -61,8 +61,7 @@ def cli():
predict_parser.add_argument('--mode', help='keypoints, mono, stereo', default='mono')
predict_parser.add_argument('--model', help='path of MonoLoco/MonStereo model to load')
predict_parser.add_argument('--net', help='only to select older MonoLoco model, otherwise use --mode')
predict_parser.add_argument('--path_gt', help='path of json file with gt 3d localization',
default='data/arrays/names-kitti-200615-1022.json')
predict_parser.add_argument('--path_gt', help='path of json file with gt 3d localization')
predict_parser.add_argument('--z_max', type=int, help='maximum meters distance for predictions', default=100)
predict_parser.add_argument('--n_dropout', type=int, help='Epistemic uncertainty evaluation', default=0)
predict_parser.add_argument('--dropout', type=float, help='dropout parameter', default=0.2)

View File

@ -60,7 +60,6 @@ class Printer:
self.output_types = args.output_types
self.z_max = args.z_max # set max distance to show instances
self.show_all = args.show_all
self.show = args.show_all
self.save = not args.no_save
# define image attributes
@ -170,8 +169,7 @@ class Printer:
# whether to include instances that don't match the ground-truth
iterator = range(len(self.zz_pred)) if self.show_all else range(len(self.zz_gt))
if not iterator:
print("-" * 110 + '\n' + "! No instances detected, be sure to include file with ground-truth values or "
"use the command --show_all" + '\n' + "-" * 110)
print("-" * 110 + '\n' + '! No instances detected' '\n' + '-' * 110)
# Draw the front figure
number = dict(flag=False, num=97)