MCPcopy
hub / github.com/lllyasviel/sd-forge-layerdiffuse / pad_rgb

Function pad_rgb

lib_layerdiffusion/models.py:205–217  ·  view source on GitHub ↗
(np_rgba_hwc_uint8)

Source from the content-addressed store, hash-verified

203
204
205def pad_rgb(np_rgba_hwc_uint8):
206 np_rgba_hwc = np_rgba_hwc_uint8.astype(np.float32) / 255.0
207 pyramid = build_alpha_pyramid(color=np_rgba_hwc[..., :3], alpha=np_rgba_hwc[..., 3:])
208
209 top_c, top_a = pyramid[0]
210 fg = np.sum(top_c, axis=(0, 1), keepdims=True) / np.sum(top_a, axis=(0, 1), keepdims=True).clip(1e-8, 1e32)
211
212 for layer_c, layer_a in pyramid:
213 layer_h, layer_w, _ = layer_c.shape
214 fg = cv2.resize(fg, (layer_w, layer_h), interpolation=cv2.INTER_LINEAR)
215 fg = layer_c + fg * (1.0 - layer_a)
216
217 return fg
218
219
220class TransparentVAEDecoder:

Callers 1

encodeMethod · 0.85

Calls 1

build_alpha_pyramidFunction · 0.85

Tested by

no test coverage detected