Spaces:
Runtime error
Runtime error
Download cv_utils.py from limingcv/ControlNet-Plus-Plus: direct link, hf CLI and curl.
- Browser
- Download file 483 Bytes
-
https://huggingface.co/spaces/limingcv/ControlNet-Plus-Plus/resolve/main/cv_utils.py
- Command line
-
hf download hf://spaces/limingcv/ControlNet-Plus-Plus/cv_utils.py
-
curl -L -o cv_utils.py https://huggingface.co/spaces/limingcv/ControlNet-Plus-Plus/resolve/main/cv_utils.py
483 Bytes
| import cv2 | |
| import numpy as np | |
| def resize_image(input_image, resolution, interpolation=None): | |
| H, W, C = input_image.shape | |
| H = float(H) | |
| W = float(W) | |
| k = float(resolution) / max(H, W) | |
| H *= k | |
| W *= k | |
| H = int(np.round(H / 64.0)) * 64 | |
| W = int(np.round(W / 64.0)) * 64 | |
| if interpolation is None: | |
| interpolation = cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA | |
| img = cv2.resize(input_image, (W, H), interpolation=interpolation) | |
| return img | |