Multi image input model with dataloader

Hi everyone.

I want to make a model that uses 4 image input and 1 image output.

Since I’m very new with pytorch, I only know that I should use Dataloader,

and failed to make my own source code

can anybody give me some hints and refereneces ?

Hi Dear,

You should code your own custom dataset and model.

Custom dataset will be like this.

class MyDataset(Dataset):
    def __init__(self, image_paths):
        self.image_paths = image_paths

    def __getitem__(self, index)
        #read input images and output image
        return iImg1, iImg2, iImg3, iImg4, oImg

    def __len__(self):
        return len(self.image_paths)

Your custom model will be like this.

class CustomModel(torch.nn.Module):
    def __init__(self, D_in, H, D_out):
        In the constructor we instantiate two nn.Linear modules and assign them as
        member variables.
        #your model arch

    def forward(self, iImg1, iImg2, iImg3, iImg4):
        # 4 image input for model
        #operations regarding model
        return oImg #output a image

You must check in docs writing custom model and dataset.

1 Like

You are my best. Thank you so much.