MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / _adain

Function _adain

diffsynth/pipelines/flashvsr_tiny.py:34–40  ·  view source on GitHub ↗
(content_feat: torch.Tensor, style_feat: torch.Tensor)

Source from the content-addressed store, hash-verified

32
33
34def _adain(content_feat: torch.Tensor, style_feat: torch.Tensor) -> torch.Tensor:
35 assert content_feat.shape[:2] == style_feat.shape[:2], "ADAIN: N、C 必须匹配"
36 size = content_feat.size()
37 style_mean, style_std = _calc_mean_std(style_feat)
38 content_mean, content_std = _calc_mean_std(content_feat)
39 normalized = (content_feat - content_mean.expand(size)) / content_std.expand(size)
40 return normalized * style_std.expand(size) + style_mean.expand(size)
41
42
43# -----------------------------

Callers 1

forwardMethod · 0.70

Calls 1

_calc_mean_stdFunction · 0.70

Tested by

no test coverage detected