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)
| 82 | return feat_mean, feat_std |
| 83 | |
| 84 | def 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 | |
| 98 | def space_timesteps(num_timesteps, section_counts): |
| 99 | """ |
no test coverage detected