Thanks for your kind suggestion. I have written a custom Dataset and call the above test code. But I am getting an error. Can you please tell me whether I am going right direction or something problem?
from torch.utils.data import Dataset
class bothDataset(Dataset):
     def __init__(self, csv_path, root_dir1, root_dir2, transform=None):
        self.img_names = pd.read_csv(csv_path)
        self.transform = transform
        self.root_dir1 = root_dir1
        self.root_dir2 = root_dir2

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

    def __getitem__(self, idx):
        if torch.is_tensor(idx):
            idx = idx.tolist()

        img_name1= os.path.join(self.root_dir1,
                                self.img_names.iloc[idx, 0])
                                
        image1 = Image.open(img_name1+'.bmp')
        res = transforms.Resize((224, 224))
        image1  = res(image1)
        image1torchvision.transforms.functional.to_tensor(image1)
        
        img_name2 = os.path.join(self.root_dir2,
                                  self.img_names.iloc[idx, 1])
        image2 = Image.open(img_name2+'.bmp')
        image2  = res (image2)
        image2=torchvision.transforms.functional.to_tensor(image2)
        label = self.img_names.iloc[idx, 2]            
        return image1, image2, label  
test_loader = bothDataset(csv_path='RelationBS1.csv',
                               root_dir1=test_dir1, root_dir2=test_dir2, 
                                  transform=test_transforms)                                         
print('Num test images: ', len(test_loader))

changed the test function part as
for j, (input1, input2, labels) in enumerate(test_loader):
                input1 = input1.to(device)
                input2 = input2.to(device)
                labels = labels.to(device)
                model.eval()
                outputs = model(input1, input2)