Download utils/image_processing.py from nnibras/LAB4: direct link, hf CLI and curl.
- Browser
- Download file 380 Bytes
-
https://huggingface.co/spaces/nnibras/LAB4/resolve/main/utils/image_processing.py
- Command line
-
hf download hf://spaces/nnibras/LAB4/utils/image_processing.py
-
curl -L -o image_processing.py https://huggingface.co/spaces/nnibras/LAB4/resolve/main/utils/image_processing.py
380 Bytes
| import cv2 | |
| def resize_image(image, width=None, height=None): | |
| if width is None and height is None: | |
| return image | |
| (h, w) = image.shape[:2] | |
| if width is None: | |
| ratio = height / float(h) | |
| width = int(w * ratio) | |
| else: | |
| ratio = width / float(w) | |
| height = int(h * ratio) | |
| return cv2.resize(image, (width, height)) | |