evaluation on bottom center
This commit is contained in:
parent
712bdf9dc6
commit
f0150da571
@ -53,6 +53,9 @@ def generate_kitti(model, dir_ann, p_dropout=0.2, n_dropout=0):
|
||||
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]
|
||||
@ -75,7 +78,7 @@ def save_txts(path_txt, all_inputs, all_outputs, all_params):
|
||||
uv_boxes, keypoints = all_inputs[:]
|
||||
kk, tt = all_params[:]
|
||||
|
||||
uv_centers = get_keypoints(keypoints, mode='center')
|
||||
uv_centers = get_keypoints(keypoints, mode='bottom') # Kitti uses the bottom center to calculate depth
|
||||
xy_centers = pixel_to_camera(uv_centers, kk, 1)
|
||||
zzs = xyz_from_distance(outputs[:, 0:1], xy_centers)[:, 2].tolist()
|
||||
|
||||
|
||||
@ -216,7 +216,6 @@ class Trainer:
|
||||
|
||||
# To load a model instead of using the trained one
|
||||
if load:
|
||||
# self.path_out = os.path.join(self.dir_out, 'best_model_paper.pickle')
|
||||
self.model.load_state_dict(torch.load(model, map_location=lambda storage, loc: storage))
|
||||
|
||||
# Average distance on training and test set after unnormalizing
|
||||
|
||||
@ -76,7 +76,7 @@ def get_keypoints(keypoints, mode):
|
||||
keypoints = keypoints.unsqueeze(0)
|
||||
|
||||
assert len(keypoints.size()) == 3 and keypoints.size()[1] == 3, "tensor dimensions not recognized"
|
||||
assert mode in ['center', 'head', 'shoulder', 'hip' , 'ankle']
|
||||
assert mode in ['center', 'bottom', 'head', 'shoulder', 'hip', 'ankle']
|
||||
|
||||
kps_in = keypoints[:, 0:2, :] # (m, 2, 17)
|
||||
if mode == 'center':
|
||||
@ -84,6 +84,13 @@ def get_keypoints(keypoints, mode):
|
||||
kps_min, _ = kps_in.min(2)
|
||||
kps_out = (kps_max - kps_min) / 2 + kps_min # (m, 2) as keepdims is False
|
||||
|
||||
elif mode == 'bottom': # bottom center for kitti evaluation
|
||||
kps_max, _ = kps_in.max(2)
|
||||
kps_min, _ = kps_in.min(2)
|
||||
kps_out_x = (kps_max[:, 0:1] - kps_min[:, 0:1]) / 2 + kps_min[:, 0:1]
|
||||
kps_out_y = kps_max[:, 1:2]
|
||||
kps_out = torch.cat((kps_out_x, kps_out_y), -1)
|
||||
|
||||
elif mode == 'head':
|
||||
kps_out = kps_in[:, :, 0:5].mean(2)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user