Merged images UNET

Hello, I was trying to do an image segmentation and after testing saved the three images ( as an example).
The problem is that 3 images are merged, while I want to save each one separately.
def save_test(loader, model, folder=’/kaggle/working/saved_test/’,device=‘cuda’):
for idx, x in enumerate(loader):
x =
with torch.no_grad():
preds = torch.sigmoid(model(x))
preds = (preds > 0.5).float()
preds, f"{folder}/test_{idx}.png"
#torchvision.utils.save_image(y.unsqueeze(1), f"{folder}{idx}.png")


Could you check, please?
Does anyone know what is the problem?

torchvision.utils.save_image creates a grid if a batch of images is passed to it.
Call this method on each images separately to create separate images.