Untitled
unknown
plain_text
2 years ago
1.0 kB
4
Indexable
Never
import numpy as np import json import numpy as np from matplotlib import pyplot as plt def hps(X): X_mean = np.mean(X, axis=0) X_centered = X - X_mean X_cov = np.cov(X_centered.T) # * 3.1. Get Eigen Values and Vectors eigen_values, eigen_vectors = np.linalg.eig(X_cov) # * 3.2. Get the top M eigen values indices top_M_idx = np.argsort(eigen_values)[::-1][-1] # return np.dot(X_mean, top_M_idx) return eigen_values[top_M_idx] if __name__ == '__main__': results = json.load(open("video-to-pose3D/outputs/alpha_pose_d05/alphapose-results.json")) hpss = [] frames = [] for i in range(0, 135): keypoints = np.array(results[i]["keypoints"]).reshape(17,3)[:,:2] hps_val = hps(keypoints) hpss.append(hps_val) frames.append(i) fig = plt.figure() ax = plt.subplot(111) der = np.gradient(hpss,frames) ax.plot(frames, der) plt.xticks(np.arange(min(frames), max(frames) + 1, 10)) plt.grid() fig.savefig('hps_d06_dif.png')