Spaces:
Build error
Build error
Download utils/misc.py from MohammedAH/3D-Room-Layout-Estimation_LGT-Net: direct link, hf CLI and curl.
- Browser
- Download file 434 Bytes
-
https://huggingface.co/spaces/MohammedAH/3D-Room-Layout-Estimation_LGT-Net/resolve/main/utils/misc.py
- Command line
-
hf download hf://spaces/MohammedAH/3D-Room-Layout-Estimation_LGT-Net/utils/misc.py
-
curl -L -o misc.py https://huggingface.co/spaces/MohammedAH/3D-Room-Layout-Estimation_LGT-Net/resolve/main/utils/misc.py
434 Bytes
| """ | |
| @date: 2021/8/4 | |
| @description: | |
| """ | |
| import numpy as np | |
| import torch | |
| def tensor2np(t: torch.Tensor) -> np.array: | |
| if isinstance(t, torch.Tensor): | |
| if t.device == 'cpu': | |
| return t.detach().numpy() | |
| else: | |
| return t.detach().cpu().numpy() | |
| else: | |
| return t | |
| def tensor2np_d(d: dict) -> dict: | |
| output = {} | |
| for k in d.keys(): | |
| output[k] = tensor2np(d[k]) | |
| return output | |