Spaces:
Runtime error
Runtime error
Download inpainter/util/tensor_util.py from VIPLab/Track-Anything: direct link, hf CLI and curl.
- Browser
- Download file 490 Bytes
-
https://huggingface.co/spaces/VIPLab/Track-Anything/resolve/main/inpainter/util/tensor_util.py
- Command line
-
hf download hf://spaces/VIPLab/Track-Anything/inpainter/util/tensor_util.py
-
curl -L -o tensor_util.py https://huggingface.co/spaces/VIPLab/Track-Anything/resolve/main/inpainter/util/tensor_util.py
490 Bytes
| import cv2 | |
| import numpy as np | |
| # resize frames | |
| def resize_frames(frames, size=None): | |
| """ | |
| size: (w, h) | |
| """ | |
| if size is not None: | |
| frames = [cv2.resize(f, size) for f in frames] | |
| frames = np.stack(frames, 0) | |
| return frames | |
| # resize frames | |
| def resize_masks(masks, size=None): | |
| """ | |
| size: (w, h) | |
| """ | |
| if size is not None: | |
| masks = [np.expand_dims(cv2.resize(m, size), 2) for m in masks] | |
| masks = np.stack(masks, 0) | |
| return masks | |