I did some conversion between PIL and openCV for images in order to use the Albumentation library. However I got the error:
return (image - mean[:, None, None]) / std[:, None, None]
RuntimeError: The size of tensor a (2) must match the size of tensor b (3) at non-singleton dimension 0
Traceback (most recent call last):
  File "train_detector.py", line 357, in <module>
    main(args)
  File "train_detector.py", line 335, in main
    engine(args.num_epochs)
  File "/home/students/s121md105_02/package-to-linux/pocket/pocket/core/engines.py", line 168, in __call__
    self._on_each_iteration()
  File "train_detector.py", line 44, in _on_each_iteration
    self._state.output = self._state.net(*self._state.inputs, targets=self._state.targets)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 168, in forward
    outputs = self.parallel_apply(replicas, inputs, kwargs)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 178, in parallel_apply
    return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
    output.reraise()
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/_utils.py", line 425, in reraise
    raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in replica 0 on device 0.
Original Traceback (most recent call last):
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
    output = module(*input, **kwargs)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torchvision/models/detection/generalized_rcnn.py", line 77, in forward
    images, targets = self.transform(images, targets)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torchvision/models/detection/transform.py", line 114, in forward
    image = self.normalize(image)
  File "/home/students/s121md105_02/anaconda3/envs/pocket/lib/python3.8/site-packages/torchvision/models/detection/transform.py", line 140, in normalize
    return (image - mean[:, None, None]) / std[:, None, None]
RuntimeError: The size of tensor a (2) must match the size of tensor b (3) at non-singleton dimension 0

I tried to print the image data passed for normalize, it looked something as this:
tensor([[[0.5804, 0.5725, 0.5686,  ..., 0.8431, 0.8471, 0.8431],
         [0.5686, 0.5686, 0.5686,  ..., 0.8392, 0.8392, 0.8392],
         [0.5686, 0.5686, 0.5686,  ..., 0.8353, 0.8353, 0.8314],
         ...,
         [0.4275, 0.4275, 0.4314,  ..., 0.2471, 0.2431, 0.2431],
         [0.4314, 0.4275, 0.4196,  ..., 0.3137, 0.2745, 0.2549],
         [0.4392, 0.4392, 0.4275,  ..., 0.3882, 0.3451, 0.3176]],

        [[0.4941, 0.4863, 0.4824,  ..., 0.2980, 0.2902, 0.2863],
         [0.4824, 0.4824, 0.4824,  ..., 0.2980, 0.2941, 0.2941],
         [0.4824, 0.4824, 0.4824,  ..., 0.3020, 0.3020, 0.2980],
         ...,
         [0.4000, 0.4000, 0.4039,  ..., 0.0118, 0.0118, 0.0235],
         [0.4039, 0.4000, 0.3922,  ..., 0.0353, 0.0157, 0.0118],
         [0.4118, 0.4118, 0.4000,  ..., 0.0745, 0.0510, 0.0392]]],
       device='cuda:0')
tensor([[[0.9216, 0.9098, 0.9020,  ..., 0.8275, 0.8353, 0.8588],
         [0.9098, 0.9098, 0.9176,  ..., 0.8549, 0.8510, 0.8588],
         [0.9059, 0.9059, 0.9098,  ..., 0.8588, 0.8510, 0.8392],
         ...,
         [0.7176, 0.7137, 0.7137,  ..., 0.5804, 0.5843, 0.5922],
         [0.7255, 0.7255, 0.7255,  ..., 0.5686, 0.5765, 0.5804],
         [0.7137, 0.7137, 0.7137,  ..., 0.5804, 0.5843, 0.5804]]],
       device='cuda:1')

Does it mean that my image input channel is 2 but my the values in my normalize is 3? But I don’t get why my image input channel is 2.