(np_rgba_hwc_uint8)
| 209 | |
| 210 | |
| 211 | def 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 | |
| 229 | def dist_sample_deterministic(dist: DiagonalGaussianDistribution, perturbation: torch.Tensor): |
no test coverage detected