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)
| 34 | return feat_mean, feat_std |
| 35 | |
| 36 | def adaptive_instance_normalization(content_feat, style_feat): |
| 37 | """Adaptive instance normalization. |
| 38 | Adjust the reference features to have the similar color and illuminations |
| 39 | as those in the degradate features. |
| 40 | Args: |
| 41 | content_feat (Tensor): The reference feature. |
| 42 | style_feat (Tensor): The degradate features. |
| 43 | """ |
| 44 | size = content_feat.size() |
| 45 | style_mean, style_std = calc_mean_std(style_feat) |
| 46 | content_mean, content_std = calc_mean_std(content_feat) |
| 47 | normalized_feat = (content_feat - content_mean.expand(size)) / content_std.expand(size) |
| 48 | return normalized_feat * style_std.expand(size) + style_mean.expand(size) |
| 49 | |
| 50 | def get_timestep_embedding(timesteps, embedding_dim): |
| 51 | """ |
nothing calls this directly
no test coverage detected