MCPcopy Create free account
hub / github.com/AdaptiveMotorControlLab/FMPose3D / test_multi_hypothesis

Function test_multi_hypothesis

scripts/FMPose3D_main.py:50–159  ·  view source on GitHub ↗
(
    args,
    actions,
    dataLoader,
    model,
    optimizer=None,
    epoch=None,
    hypothesis_num=None,
    steps=None,
)

Source from the content-addressed store, hash-verified

48
49
50def test_multi_hypothesis(
51 args,
52 actions,
53 dataLoader,
54 model,
55 optimizer=None,
56 epoch=None,
57 hypothesis_num=None,
58 steps=None,
59):
60
61 model_3d = model["CFM"]
62 model_3d.eval()
63 split = "test"
64
65 # determine which steps to evaluate (extracted from function; can be provided by caller)
66 if steps is None:
67 eval_steps = sorted(
68 {
69 int(s)
70 for s in getattr(args, "eval_sample_steps", "3").split(",")
71 if str(s).strip()
72 }
73 )
74 else:
75 if isinstance(steps, (list, tuple, set)):
76 eval_steps = sorted({int(s) for s in steps})
77 else:
78 eval_steps = [int(steps)]
79 action_error_sum_multi = {s: define_error_list(actions) for s in eval_steps}
80
81 for i, data in enumerate(tqdm(dataLoader, 0)):
82 batch_cam, gt_3D, input_2D, action, subject, scale, bb_box, cam_ind = data
83 [input_2D, gt_3D, batch_cam, scale, bb_box] = get_variable(
84 split, [input_2D, gt_3D, batch_cam, scale, bb_box]
85 )
86
87 # When test_augmentation=True, input_2D has an extra aug dimension: (B,2,F,J,2)
88 # When test_augmentation=False, input_2D has shape: (B,F,J,2)
89 if args.test_augmentation:
90 input_2D_nonflip = input_2D[:, 0]
91 input_2D_flip = input_2D[:, 1]
92 else:
93 input_2D_nonflip = input_2D
94 input_2D_flip = None
95 out_target = gt_3D.clone()
96 out_target[:, :, 0] = 0
97
98 # Simple Euler sampler for CFM at test time
99 def euler_sample(x2d, y_local, steps):
100 dt = 1.0 / steps
101 for s in range(steps):
102 t_s = torch.full(
103 (gt_3D.size(0), 1, 1, 1),
104 s * dt,
105 device=gt_3D.device,
106 dtype=gt_3D.dtype,
107 )

Callers 1

FMPose3D_main.pyFile · 0.85

Calls 6

euler_sampleFunction · 0.70
print_errorFunction · 0.70
define_error_listFunction · 0.50
get_variableFunction · 0.50
test_calculationFunction · 0.50

Tested by

no test coverage detected