Sorry that I can’t show you the full code… But I can show you matplotlib part. It was just saving plots and I had to fix it because the output image size didn’t match.
    x_temp, y = ds_test.__getitem__(10)
    x = np.expand_dims(x_temp, axis=0)
    x = torch.from_numpy(x)
    x = x.to(device)
    y = cv2.cvtColor(y, cv2.COLOR_BGR2RGB)
    y_pred = model(x)
   
    print('++==========SHAPE==========++')
    print(f'x shape: {x.shape}, y shape: {y_pred.shape}')
    
    fig = plt.figure()
    rows = 1
    cols = 2

    x = x.view(3, 400, 400)
    x = x.cpu().detach()
    x = transforms.ToPILImage()(x)
    x = np.array(x.convert('RGB'))

    y_pred = y_pred.view(400, 400)
    y_pred = y_pred.cpu().detach()
    y_pred = transforms.ToPILImage()(y_pred)
    y_pred = np.array(y_pred.convert('L'))