MCPcopy Index your code
hub / github.com/TencentARC/T2I-Adapter / resize_numpy_image

Function resize_numpy_image

Adapter/utils.py:24–34  ·  view source on GitHub ↗
(image, max_resolution=1024 * 1024, resize_short_edge=None)

Source from the content-addressed store, hash-verified

22 raise ValueError(f"{model_class} is not supported.")
23
24def 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

Callers 9

get_cond_sketchFunction · 0.90
get_cond_segFunction · 0.90
get_cond_keyposeFunction · 0.90
get_cond_depthFunction · 0.90
get_cond_zoedepthFunction · 0.90
get_cond_cannyFunction · 0.90
get_cond_colorFunction · 0.90
get_cond_openposeFunction · 0.90
get_cond_edgeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected