Based on the error message it seems you are not transforming the PIL.Image to a tensor, so I guess in your code the transform argument might not be set properly. Note that your posted code snippet uses root_dir instead of img_dir, soI assume your real code is not using the same posted code.
To further isolate the issue, check the type(image) in __getitem__ before returning it and make sure it’s a tensor.
Multiple inputs and outputs can be implemented directly in the forward via:
def forward(self, input1, input2):
    ...
    out1 = self.layers(input1)
    ...
    out2 = self.layers(input2)
    return out1, out2

I’m unsure, if you need to iterate all folders, as it seems you are already using a mapping where the image paths and the corresponding label is given. In this case, I would just reuse the provided mapping.