MCPcopy Create free account
hub / github.com/CompVis/diff2flow / per_sample_min_max_normalization

Function per_sample_min_max_normalization

diff2flow/visualizer.py:83–91  ·  view source on GitHub ↗

Normalize each sample in a batch independently with min-max normalization to [0, 1]

(x)

Source from the content-addressed store, hash-verified

81
82
83def per_sample_min_max_normalization(x):
84 """ Normalize each sample in a batch independently
85 with min-max normalization to [0, 1] """
86 bs, *shape = x.shape
87 x_ = einops.rearrange(x, "b ... -> b (...)")
88 min_val = einops.reduce(x_, "b ... -> b", "min")[..., None]
89 max_val = einops.reduce(x_, "b ... -> b", "max")[..., None]
90 x_ = (x_ - min_val) / (max_val - min_val)
91 return x_.reshape(bs, *shape)
92
93
94class ImageDepthVisualizer:

Callers 1

__call__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected