MCPcopy Create free account
hub / github.com/IceClear/StableSR / adaptive_instance_normalization

Function adaptive_instance_normalization

ldm/models/diffusion/ddpm.py:84–96  ·  view source on GitHub ↗

Adaptive instance normalization. Adjust the reference features to have the similar color and illuminations as those in the degradate features. Args: content_feat (Tensor): The reference feature. style_feat (Tensor): The degradate features.

(content_feat, style_feat)

Source from the content-addressed store, hash-verified

82 return feat_mean, feat_std
83
84def adaptive_instance_normalization(content_feat, style_feat):
85 """Adaptive instance normalization.
86 Adjust the reference features to have the similar color and illuminations
87 as those in the degradate features.
88 Args:
89 content_feat (Tensor): The reference feature.
90 style_feat (Tensor): The degradate features.
91 """
92 size = content_feat.size()
93 style_mean, style_std = calc_mean_std(style_feat)
94 content_mean, content_std = calc_mean_std(content_feat)
95 normalized_feat = (content_feat - content_mean.expand(size)) / content_std.expand(size)
96 return normalized_feat * style_std.expand(size) + style_mean.expand(size)
97
98def space_timesteps(num_timesteps, section_counts):
99 """

Callers 2

p_sample_loopMethod · 0.70
p_sample_loop_canvasMethod · 0.70

Calls 1

calc_mean_stdFunction · 0.70

Tested by

no test coverage detected