I have the following code to cr

```
import torch
from PIL import Image
import torchvision.transforms as transforms
def preprocess(image_name, image_size):
image = Image.open(image_name).convert('RGB')
if type(image_size) is not tuple:
image_size = tuple([int((float(image_size) / max(image.size))*x) for x in (image.height, image.width)])
Loader = transforms.Compose([transforms.Resize(image_size), transforms.ToTensor()])
tensor = (Loader(image) * 256).unsqueeze(0)
return tensor
def deprocess(output_tensor):
output_tensor = output_tensor.squeeze(0).cpu() / 256
output_tensor.clamp_(0, 1)
Image2PIL = transforms.ToPILImage()
image = Image2PIL(output_tensor.cpu())
return image
# Blending two images ontop of each other:
test_tensor_1 = preprocess('test_image_1.jpg', (1080,1080))
test_tensor_2 = preprocess('test_image_2.jpg', (1080,1080))
lin_mask_1 = torch.linspace(0,1,1080).repeat(1080,1).repeat(3,1,1).unsqueeze(0)
lin_mask_2 = torch.linspace(1,0,1080).repeat(1080,1).repeat(3,1,1).unsqueeze(0)
faded_tensor = test_tensor_1 * lin_mask_1 + test_tensor_2 * lin_mask_2
ft = deprocess(faded_tensor)
ft.save('faded_tensor.png')
```

Blending the two images works when the blending takes place across the entire image:

However, I am having trouble getting it working for just a small overlapping portion of the image

```
# Blending overlapping parts of image
overlap = 540
lin_mask_part_1 = torch.linspace(0,1,overlap).repeat(1080,1)
mask_part_1 = torch.ones(1080, 1080-overlap)
mask_1 = torch.cat([lin_mask_part_1, mask_part_1], 1)
mask_1 = mask_1.repeat(3,1,1).unsqueeze(0)
lin_mask_part_2 = torch.linspace(1,0,overlap).repeat(1080,1)
mask_part_2 = torch.ones(1080, 1080-overlap)
mask_2 = torch.cat([lin_mask_part_2, mask_part_2], 1)
mask_2 = mask_2.repeat(3,1,1).unsqueeze(0)
base_tensor = torch.zeros(3, 1080,overlap*3).unsqueeze(0)
base_tensor[:,:, 0:1080, 0:1080] = base_tensor[:,:, 0:1080, 0:1080] + (test_tensor_1 * mask_2)
base_tensor[:,:, :, overlap:overlap*3] = base_tensor[:,:, :, overlap:overlap*3] + (test_tensor_2 * mask_1)
ft = deprocess(base_tensor)
ft.save('part_faded_tensor.png')
```