-
Notifications
You must be signed in to change notification settings - Fork 23
/
test_depth_image_hand_fitting.py
76 lines (54 loc) · 1.61 KB
/
test_depth_image_hand_fitting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Test using depth image hand fitting."""
import numpy as np
from deodr.examples.depth_image_hand_fitting import run
import tensorflow as tf
def test_depth_image_hand_fitting_pytorch() -> None:
energies = run(
dl_library="pytorch",
plot_curves=False,
display=False,
save_images=False,
max_iter=50,
)
possible_results = [
251.32711067513003,
251.31652686512888,
251.31652686495823,
]
assert np.any(np.abs(np.array(possible_results) - energies[49]) < 1e-5)
def test_depth_image_hand_fitting_numpy() -> None:
energies = run(
dl_library="none",
plot_curves=False,
display=False,
save_images=False,
max_iter=50,
)
possible_results = [
251.32711113732933,
251.32711113730954,
251.3271111242092,
]
assert np.any(np.abs(np.array(possible_results) - energies[49]) < 1e-5)
def test_depth_image_hand_fitting_tensorflow() -> None:
tf.config.set_visible_devices(
[], "GPU"
) # Running on CPU to get determinisic results
energies = run(
dl_library="tensorflow",
plot_curves=False,
display=False,
save_images=False,
max_iter=50,
)
possible_results = [
251.31648932312913,
251.3164914350016,
251.3164891265543,
251.32711038915872,
]
assert np.any(np.abs(np.array(possible_results) - energies[49]) < 1e-5)
if __name__ == "__main__":
test_depth_image_hand_fitting_pytorch()
test_depth_image_hand_fitting_numpy()
test_depth_image_hand_fitting_tensorflow()