simplify ground-truth and --show_all
This commit is contained in:
parent
cfc9023cce
commit
5aee21743a
@ -66,26 +66,18 @@ def preprocess_monoloco(keypoints, kk, zero_center=False):
|
|||||||
return kps_out
|
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 """
|
"""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:
|
with open(path_gt, 'r') as f:
|
||||||
dic_names = json.load(f)
|
dic_names = json.load(f)
|
||||||
if verbose:
|
kk = dic_names[name]['K']
|
||||||
logger.info('-' * 120 + "\nGround-truth file opened")
|
dic_gt = dic_names[name]
|
||||||
except (FileNotFoundError, TypeError):
|
|
||||||
if verbose:
|
|
||||||
logger.info('-' * 120 + "\nGround-truth file not found")
|
|
||||||
dic_names = {}
|
|
||||||
|
|
||||||
try:
|
# Without ground-truth-file
|
||||||
kk = dic_names[name]['K']
|
else:
|
||||||
dic_gt = dic_names[name]
|
|
||||||
if verbose:
|
|
||||||
logger.info("Matched ground-truth file!")
|
|
||||||
except KeyError:
|
|
||||||
dic_gt = None
|
|
||||||
if im_size[0] / im_size[1] > 2.5: # KITTI default
|
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
|
kk = [[718.3351, 0., 600.3891], [0., 718.3351, 181.5122], [0., 0., 1.]] # Kitti calibration
|
||||||
logger.info("Using KITTI calibration matrix...")
|
logger.info("Using KITTI calibration matrix...")
|
||||||
|
|||||||
@ -82,6 +82,9 @@ def factory_from_args(args):
|
|||||||
if not args.images:
|
if not args.images:
|
||||||
raise Exception("no image files given")
|
raise Exception("no image files given")
|
||||||
|
|
||||||
|
if args.path_gt is None:
|
||||||
|
args.show_all = True
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
dic_models = download_checkpoints(args)
|
dic_models = download_checkpoints(args)
|
||||||
args.checkpoint = dic_models['keypoints']
|
args.checkpoint = dic_models['keypoints']
|
||||||
|
|||||||
@ -61,8 +61,7 @@ def cli():
|
|||||||
predict_parser.add_argument('--mode', help='keypoints, mono, stereo', default='mono')
|
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('--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('--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',
|
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('--z_max', type=int, help='maximum meters distance for predictions', default=100)
|
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('--n_dropout', type=int, help='Epistemic uncertainty evaluation', default=0)
|
||||||
predict_parser.add_argument('--dropout', type=float, help='dropout parameter', default=0.2)
|
predict_parser.add_argument('--dropout', type=float, help='dropout parameter', default=0.2)
|
||||||
|
|||||||
@ -60,7 +60,6 @@ class Printer:
|
|||||||
self.output_types = args.output_types
|
self.output_types = args.output_types
|
||||||
self.z_max = args.z_max # set max distance to show instances
|
self.z_max = args.z_max # set max distance to show instances
|
||||||
self.show_all = args.show_all
|
self.show_all = args.show_all
|
||||||
self.show = args.show_all
|
|
||||||
self.save = not args.no_save
|
self.save = not args.no_save
|
||||||
|
|
||||||
# define image attributes
|
# define image attributes
|
||||||
@ -170,8 +169,7 @@ class Printer:
|
|||||||
# whether to include instances that don't match the ground-truth
|
# 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))
|
iterator = range(len(self.zz_pred)) if self.show_all else range(len(self.zz_gt))
|
||||||
if not iterator:
|
if not iterator:
|
||||||
print("-" * 110 + '\n' + "! No instances detected, be sure to include file with ground-truth values or "
|
print("-" * 110 + '\n' + '! No instances detected' '\n' + '-' * 110)
|
||||||
"use the command --show_all" + '\n' + "-" * 110)
|
|
||||||
|
|
||||||
# Draw the front figure
|
# Draw the front figure
|
||||||
number = dict(flag=False, num=97)
|
number = dict(flag=False, num=97)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user