Skip to content

Commit 6b84c4f

Browse files
committed
Moved smoothing to the gesture space
(from the encoding space)
1 parent daffa18 commit 6b84c4f

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

motion_repr_learning/ae/decode.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414

1515
import sys
1616

17+
from scipy.signal import savgol_filter
18+
19+
20+
def smoothing(motion):
21+
22+
smoothed = [savgol_filter(motion[:,i], 9, 3) for i in range(motion.shape[1])]
23+
24+
new_motion = np.array(smoothed).transpose()
25+
26+
return new_motion
27+
28+
1729
if __name__ == '__main__':
1830
# Make sure that the two mandatory arguments are provided
1931
if args.input_file is None or args.output_file is None:
@@ -39,6 +51,9 @@
3951
# Decode it
4052
decoding = tr.decode(nn, encoding)
4153

54+
# Smoothing
55+
decoding = smoothing(decoding)
56+
4257
print(decoding.shape)
4358

4459
np.save(args.output_file, decoding)

predict.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@
77
import sys
88
from keras.models import load_model
99
import numpy as np
10-
from scipy.signal import savgol_filter
11-
12-
13-
def smoothing(motion):
14-
15-
smoothed = [savgol_filter(motion[:,i], 9, 3) for i in range(motion.shape[1])]
16-
17-
new_motion = np.array(smoothed).transpose()
18-
19-
return new_motion
20-
2110

2211
def predict(model_name, input_file, output_file):
2312
""" Predict human gesture based on the speech
@@ -35,10 +24,8 @@ def predict(model_name, input_file, output_file):
3524

3625
predicted = np.array(model.predict(audio))
3726

38-
smoothed = smoothing(predicted)
39-
4027
print("Encoding shape is: ", predicted.shape)
41-
np.savetxt(output_file, smoothed)
28+
np.savetxt(output_file, predicted)
4229

4330

4431
if __name__ == "__main__":

0 commit comments

Comments
 (0)