Spaces:
Runtime error
Runtime error
Download mGPT/utils/misc.py from OpenMotionLab/MotionGPT: direct link, hf CLI and curl.
- Browser
- Download file 649 Bytes
-
https://huggingface.co/spaces/OpenMotionLab/MotionGPT/resolve/4409449784b2e5a3f4acb52c19bb2beec2dcd80a/mGPT/utils/misc.py
- Command line
-
hf download hf://spaces/OpenMotionLab/MotionGPT@4409449784b2e5a3f4acb52c19bb2beec2dcd80a/mGPT/utils/misc.py
-
curl -L -o misc.py https://huggingface.co/spaces/OpenMotionLab/MotionGPT/resolve/4409449784b2e5a3f4acb52c19bb2beec2dcd80a/mGPT/utils/misc.py
649 Bytes
| import torch | |
| def to_numpy(tensor): | |
| if torch.is_tensor(tensor): | |
| return tensor.cpu().numpy() | |
| elif type(tensor).__module__ != 'numpy': | |
| raise ValueError("Cannot convert {} to numpy array".format( | |
| type(tensor))) | |
| return tensor | |
| def to_torch(ndarray): | |
| if type(ndarray).__module__ == 'numpy': | |
| return torch.from_numpy(ndarray) | |
| elif not torch.is_tensor(ndarray): | |
| raise ValueError("Cannot convert {} to torch tensor".format( | |
| type(ndarray))) | |
| return ndarray | |
| def cleanexit(): | |
| import sys | |
| import os | |
| try: | |
| sys.exit(0) | |
| except SystemExit: | |
| os._exit(0) | |