The TS, MRSeg and MIND models, re-exported from their published weights. forward takes an optional norms, one [2, C] mean and variance per normalisation in the order they run (MIND: its variance mean); norm_input returns the input of the next normalisation, which a pass over the regions of an image sums for its statistics; norm_count says how many the first layers go through. A region normalised by the whole image's statistics then gives the whole image's layers there. Without norms, every layer is identical, bit for bit, to the previous export.
Floor the MIND variance so a constant batch yields a flat descriptor
The variance MIND divides by was clamped between 0.001 and 1000 times its mean over the
batch. A batch of constant patches, as the online mode of the ITK metric sends over air,
has a mean of 0, so both bounds were 0 and the division gave NaN. A floor of 1e-6 is the
lower bound a whole image of mean variance 1e-3 already imposes on its flat patches; such
a batch now yields exp(0) = 1 on every channel. Textured batches are bit-identical to the
previous export, the floor never binds there.
The C++ wrapper inspects the TorchScript forward() schema and builds the
argument list accordingly, ensuring backward compatibility with legacy models
(forward(input) or forward(input, layers)) while supporting the new extended
signature:
forward(input, layersCount, imageStats, imageDirection)