MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / calc_mean_std

Function calc_mean_std

diffusers/examples/community/fresco_v2v.py:153–162  ·  view source on GitHub ↗
(feat, eps=1e-5, chunk=1)

Source from the content-addressed store, hash-verified

151
152
153def calc_mean_std(feat, eps=1e-5, chunk=1):
154 size = feat.size()
155 assert len(size) == 4
156 if chunk == 2:
157 feat = torch.cat(feat.chunk(2), dim=3)
158 N, C = size[:2]
159 feat_var = feat.view(N // chunk, C, -1).var(dim=2) + eps
160 feat_std = feat_var.sqrt().view(N, C, 1, 1)
161 feat_mean = feat.view(N // chunk, C, -1).mean(dim=2).view(N // chunk, C, 1, 1)
162 return feat_mean.repeat(chunk, 1, 1, 1), feat_std.repeat(chunk, 1, 1, 1)
163
164
165def adaptive_instance_normalization(content_feat, style_feat, chunk=1):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected