Normalize each sample in a batch independently with min-max normalization to [0, 1]
(x)
| 120 | |
| 121 | |
| 122 | def per_sample_min_max_normalization(x): |
| 123 | """ Normalize each sample in a batch independently |
| 124 | with min-max normalization to [0, 1] """ |
| 125 | bs, *shape = x.shape |
| 126 | x_ = einops.rearrange(x, "b ... -> b (...)") |
| 127 | min_val = einops.reduce(x_, "b ... -> b", "min")[..., None] |
| 128 | max_val = einops.reduce(x_, "b ... -> b", "max")[..., None] |
| 129 | x_ = (x_ - min_val) / (max_val - min_val) |
| 130 | return x_.reshape(bs, *shape) |
| 131 | |
| 132 | |
| 133 | def colorize_depth_map( |
no outgoing calls
no test coverage detected