(image, max_resolution=1024 * 1024, resize_short_edge=None)
| 22 | raise ValueError(f"{model_class} is not supported.") |
| 23 | |
| 24 | def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None): |
| 25 | h, w = image.shape[:2] |
| 26 | if resize_short_edge is not None: |
| 27 | k = resize_short_edge / min(h, w) |
| 28 | else: |
| 29 | k = max_resolution / (h * w) |
| 30 | k = k**0.5 |
| 31 | h = int(np.round(h * k / 64)) * 64 |
| 32 | w = int(np.round(w * k / 64)) * 64 |
| 33 | image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4) |
| 34 | return image |
no outgoing calls
no test coverage detected