This error is raised by PIL, which gets unexpected images and cannot blend them.
Is the error raised in the forward pass of self.net?
If so, it seems you are using PIL methods inside the model, while you are also passing tensors to its forward. Could you explain the use case a bit?