Views
No views yet
1import torch
2import numpy as np
3import matplotlib.pyplot as plt
4from PIL import Image
5from UNET.model import UNet
6
7# 1. Load model
8model = UNet()
9model.load_state_dict(torch.load("unet_weights.pth", map_location="cpu"))
10model.eval()
11
12# 2. Load an image (.npy format)
13arr = np.load("example.npy") # replace with your image path
14image = Image.fromarray(arr).resize((256, 256), resample=Image.BICUBIC)
15x = torch.from_numpy(np.asarray(image)).unsqueeze(0).float()
16
17# 3. Run inference
18with torch.no_grad():
19 logits = model(x)
20
21# 4. Postprocess → predicted mask
22pred_mask = torch.argmax(logits, dim=1).squeeze(0).numpy()
23
24# 5. Plot input and predicted mask
25fig, axs = plt.subplots(1, 2, figsize=(8, 4))
26axs[0].imshow(arr, cmap="gray")
27axs[0].set_title("Input Image")
28axs[0].axis("off")
29axs[1].imshow(pred_mask, cmap="gray")
30axs[1].set_title("Predicted Mask")
31axs[1].axis("off")
32plt.show()1@misc{challier2025cmunetselfsupervisedlearningbasedmodel,
2 title={CM-UNet: A Self-Supervised Learning-Based Model for Coronary Artery Segmentation in X-Ray Angiography},
3 author={Camille Challier and Xiaowu Sun and Thabo Mahendiran and Ortal Senouf and Bernard De Bruyne and Denise Auberson and Olivier Müller and Stephane Fournier and Pascal Frossard and Emmanuel Abbé and Dorina Thanou},
4 year={2025},
5 eprint={2507.17779},
6 archivePrefix={arXiv},
7 primaryClass={q-bio.QM},
8 url={https://arxiv.org/abs/2507.17779},
9}