Spaces:
Configuration error
Configuration error
Download lib/utils/snapshot_data_utils.py from pengsida/NeuralBody: direct link, hf CLI and curl.
- Browser
- Download file 532 Bytes
-
https://huggingface.co/spaces/pengsida/NeuralBody/resolve/refs%2Fpr%2F2/lib/utils/snapshot_data_utils.py
- Command line
-
hf download hf://spaces/pengsida/NeuralBody@refs/pr/2/lib/utils/snapshot_data_utils.py
-
curl -L -o snapshot_data_utils.py https://huggingface.co/spaces/pengsida/NeuralBody/resolve/refs%2Fpr%2F2/lib/utils/snapshot_data_utils.py
532 Bytes
| import pickle | |
| import numpy as np | |
| def read_pickle(pkl_path): | |
| with open(pkl_path, 'rb') as f: | |
| u = pickle._Unpickler(f) | |
| u.encoding = 'latin1' | |
| return u.load() | |
| def get_camera(camera_path): | |
| camera = read_pickle(camera_path) | |
| K = np.zeros([3, 3]) | |
| K[0, 0] = camera['camera_f'][0] | |
| K[1, 1] = camera['camera_f'][1] | |
| K[:2, 2] = camera['camera_c'] | |
| K[2, 2] = 1 | |
| R = np.eye(3) | |
| T = np.zeros([3]) | |
| D = camera['camera_k'] | |
| camera = {'K': K, 'R': R, 'T': T, 'D': D} | |
| return camera | |