Beispiel #1
0
def cal_fde(pred_traj_gt, pred_traj_fake, linear_ped, non_linear_ped):
    fde = final_displacement_error(pred_traj_fake[-1], pred_traj_gt[-1])
    fde_l = final_displacement_error(pred_traj_fake[-1], pred_traj_gt[-1],
                                     linear_ped)
    fde_nl = final_displacement_error(pred_traj_fake[-1], pred_traj_gt[-1],
                                      non_linear_ped)
    return fde, fde_l, fde_nl
Beispiel #2
0
def evaluate(args, loader, generator, num_samples):
    ade_outer, fde_outer = [], []
    total_traj = 0
    with torch.no_grad():
        for batch in loader:
            batch = [tensor.cuda() for tensor in batch]
            (obs_traj, pred_traj_gt, obs_traj_rel, pred_traj_gt_rel,
             non_linear_ped, loss_mask, seq_start_end) = batch

            ade, fde = [], []
            total_traj += pred_traj_gt.size(1)

            for _ in range(num_samples):
                pred_traj_fake_rel = generator(
                    obs_traj, obs_traj_rel, seq_start_end
                )
                pred_traj_fake = relative_to_abs(
                    pred_traj_fake_rel, obs_traj[-1]
                )
                ade.append(displacement_error(
                    pred_traj_fake, pred_traj_gt, mode='raw'
                ))
                fde.append(final_displacement_error(
                    pred_traj_fake[-1], pred_traj_gt[-1], mode='raw'
                ))

            ade_sum = evaluate_helper(ade, seq_start_end)
            fde_sum = evaluate_helper(fde, seq_start_end)

            ade_outer.append(ade_sum)
            fde_outer.append(fde_sum)
        ade = sum(ade_outer) / (total_traj * args.pred_len)
        fde = sum(fde_outer) / (total_traj)
        return ade, fde
Beispiel #3
0
def evaluate(args, loader, generator, num_samples):
    ade_outer, fde_outer = [], []
    total_traj = 0
    trajs = []
    with torch.no_grad():
        for batch in loader:
            # batch = [tensor.cuda() for tensor in batch]
            (obs_traj, pred_traj_gt, obs_traj_rel, pred_traj_gt_rel,
             non_linear_ped, loss_mask, seq_start_end) = batch
            obs_traj = obs_traj.float()
            obs_traj_rel = obs_traj_rel.float()

            pred_traj_gt = pred_traj_gt.double()
            ade, fde = [], []
            total_traj += pred_traj_gt.size(1)

            for _ in range(num_samples):
                pred_traj_fake_rel = generator(obs_traj, obs_traj_rel,
                                               seq_start_end)
                pred_traj_fake = relative_to_abs(pred_traj_fake_rel,
                                                 obs_traj[-1])
                pred_traj_fake = pred_traj_fake.double()
                trajs.append([
                    obs_traj.cpu().numpy(),
                    pred_traj_fake.cpu().numpy(),
                    pred_traj_gt.cpu().numpy(),
                    seq_start_end.cpu().numpy()
                ])

                ade_traj = displacement_error(pred_traj_fake,
                                              pred_traj_gt,
                                              mode='sum')
                fde_traj = final_displacement_error(pred_traj_fake[-1],
                                                    pred_traj_gt[-1],
                                                    mode='sum')

                # ade.append(displacement_error(
                #     pred_traj_fake, pred_traj_gt, mode='sum'
                # ))
                # fde.append(final_displacement_error(
                #     pred_traj_fake[-1], pred_traj_gt[-1], mode='sum'
                # ))

                # ade_sum = evaluate_helper(ade, seq_start_end)
                # fde_sum = evaluate_helper(fde, seq_start_end)

                # ade_outer.append(ade_sum)
                # fde_outer.append(fde_sum)
                ade_outer.append(ade_traj)
                fde_outer.append(fde_traj)
        ade = sum(ade_outer) / (total_traj * args.pred_len)
        fde = sum(fde_outer) / (total_traj)
        return ade, fde, trajs
Beispiel #4
0
def cal_fde(pred_traj_gt, pred_traj_fake):
    fde = final_displacement_error(pred_traj_fake[-1], pred_traj_gt[-1])
    return fde