Download lib/utils/base_utils.py from Richard-ZZZZZ/TEAMS: direct link, hf CLI and curl.
- Browser
- Download file 512 Bytes
-
https://huggingface.co/Richard-ZZZZZ/TEAMS/resolve/main/lib/utils/base_utils.py
- Command line
-
hf download hf://Richard-ZZZZZ/TEAMS/lib/utils/base_utils.py
-
curl -L -o base_utils.py https://huggingface.co/Richard-ZZZZZ/TEAMS/resolve/main/lib/utils/base_utils.py
512 Bytes
| import pickle | |
| import os | |
| import numpy as np | |
| def read_pickle(pkl_path): | |
| with open(pkl_path, 'rb') as f: | |
| return pickle.load(f) | |
| def save_pickle(data, pkl_path): | |
| os.system('mkdir -p {}'.format(os.path.dirname(pkl_path))) | |
| with open(pkl_path, 'wb') as f: | |
| pickle.dump(data, f) | |
| def project(xyz, K, RT): | |
| """ | |
| xyz: [N, 3] | |
| K: [3, 3] | |
| RT: [3, 4] | |
| """ | |
| xyz = np.dot(xyz, RT[:, :3].T) + RT[:, 3:].T | |
| xyz = np.dot(xyz, K.T) | |
| xy = xyz[:, :2] / xyz[:, 2:] | |
| return xy | |