How to apply this on images in two seperate folders? I want this to work like crappify...apply n save in a seperate folder. Please help!

def preprocess(image_name, image_size,image_name2,image_size2):
    image1 ='RGB')
    if type(image_size) is not tuple:
        image_size = tuple([int((float(image_size) / max(image.size))*x) for x in (image.height, 
    Loader = transforms.Compose([transforms.Resize(image_size), transforms.ToTensor()])
    tensor1 = (Loader(image1) * 256).unsqueeze(0)  
    image2 ='RGB')
    if type(image_size2) is not tuple:
        image_size2 = tuple([int((float(image_size2) / max(image.size2))*x) for x in (image.height, 
    Loader = transforms.Compose([transforms.Resize(image_size2), transforms.ToTensor()])
    tensor2 = (Loader(image2) * 256).unsqueeze(0)    
    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)
    output_tensor= tensor1 * lin_mask_1 + tensor2 * lin_mask_2
    output_tensor = output_tensor.squeeze(0).cpu() / 256
    output_tensor.clamp_(0, 1)
    Image2PIL = transforms.ToPILImage()
    image = Image2PIL(output_tensor.cpu())
    return image