circular_pad3d_demo.py
import svetoviz_webgpu as sv
# 1. Prepare 3D volume
input_volume = torch.from_numpy(np.stack(slices)).unsqueeze(0).unsqueeze(0)
# 2. Define CircularPad3d
# Pads 2 voxels across depth, height, and width with wrap-around
pad3d = nn.CircularPad3d(padding=2)
def terminal_callback(buffer, message, images, files):
output = pad3d(input_volume)
buffer.send_system_message(f"Input Voxel Grid: {input_volume.shape[2:]}")
buffer.send_system_message(f"Circularly Padded Grid: {output.shape[2:]}")
buffer.send_system_message("Top wraps to bottom, left to right, and front to back.")
# 3. Start the interactive session
sv.pytorch_web(module=pad3d, terminal_callback=terminal_callback)