InstanceNorm3d

https://pytorch.org/docs/stable/generated/torch.nn.InstanceNorm3d.html

instancenorm3d_demo.py
import svetoviz_webgpu as sv

# 1. Prepare 3D MRI volume (Batch=1, Channels=1, D, H, W)
input_volume = torch.from_numpy(np.stack(slices)).unsqueeze(0).unsqueeze(0)

# 2. Define InstanceNorm3d
in3d = nn.InstanceNorm3d(num_features=1)

def terminal_callback(buffer, message, images, files):
    output = in3d(input_volume)

    buffer.send_system_message(f"Voxel Grid: {list(input_volume.shape)}")
    buffer.send_system_message("Status: 3D volumetric normalization per sample/channel.")

# 3. Start the interactive session
sv.pytorch_web(module=in3d, terminal_callback=terminal_callback)
Volumetric Instance Statistics
InstanceNorm3d activations
InstanceNorm3d normalizes across (D, H, W) for each channel and sample. In medical imaging, this helps mitigate the effects of varying scanner intensities or acquisition protocols, ensuring that the features extracted are robust to global voxel value shifts within a specific patient scan.