import matplotlib.pyplot as plt import numpy as np import torch from model import EchoMAE3D model = EchoMAE3D() model.load_state_dict(torch.load("model.pt", weights_only=True)) model.eval() volume = torch.from_numpy(np.load("sample.npy")).float()[None, None] / 255 # 1 x 1 x 256 x 64 x 64 torch.manual_seed(0) with torch.no_grad(): reconstruction, mask = model(volume) # hides 75% of the 16 x 8 x 8 voxel patches panels = {"Input": volume, "Masked": volume * (1 - mask), "Reconstruction": reconstruction} figure, axes = plt.subplots(1, 3, figsize=(6, 4.4)) for axis, (title, image) in zip(axes, panels.items()): axis.imshow(image[0, 0, :, :, 32], cmap="gray", vmin=0, vmax=1, aspect=0.5) # central elevation slice axis.set_title(title) axis.axis("off") figure.tight_layout() figure.savefig("reconstruction.png", dpi=150)