MCPcopy Create free account
hub / github.com/FireRedTeam/LayerDiffuse-Flux / pad_rgb

Function pad_rgb

lib_layerdiffuse/vae.py:211–226  ·  view source on GitHub ↗
(np_rgba_hwc_uint8)

Source from the content-addressed store, hash-verified

209
210
211def pad_rgb(np_rgba_hwc_uint8):
212 # Written by lvmin at Stanford
213 # Massive iterative Gaussian filters are mathematically consistent to pyramid.
214
215 np_rgba_hwc = np_rgba_hwc_uint8.astype(np.float32) #/ 255.0
216 pyramid = build_alpha_pyramid(color=np_rgba_hwc[..., :3], alpha=np_rgba_hwc[..., 3:])
217
218 top_c, top_a = pyramid[0]
219 fg = np.sum(top_c, axis=(0, 1), keepdims=True) / np.sum(top_a, axis=(0, 1), keepdims=True).clip(1e-8, 1e32)
220
221 for layer_c, layer_a in pyramid:
222 layer_h, layer_w, _ = layer_c.shape
223 fg = cv2.resize(fg, (layer_w, layer_h), interpolation=cv2.INTER_LINEAR)
224 fg = layer_c + fg * (1.0 - layer_a)
225
226 return fg
227
228
229def dist_sample_deterministic(dist: DiagonalGaussianDistribution, perturbation: torch.Tensor):

Callers 2

generate_imgFunction · 0.90
forwardMethod · 0.85

Calls 1

build_alpha_pyramidFunction · 0.85

Tested by

no test coverage detected