RuntimeError: Given groups=721, expected weight to be at least 721 at dimension 0, but got weight of size [3, 1, 5, 5] instead
Here is the complete error: It is worth mentioning that the input image is of size 480 by 721.
Traceback (most recent call last):
  File &quot;/home/amir/PycharmProjects/LPTN/loadPretrainedModel.py&quot;, line 222, in &lt;module&gt;
    output = model(images)
  File &quot;/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py&quot;, line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File &quot;/home/amir/PycharmProjects/LPTN/loadPretrainedModel.py&quot;, line 180, in forward
    pyr_A = self.lap_pyramid.pyramid_decom(img=real_A_full)
  File &quot;/home/amir/PycharmProjects/LPTN/loadPretrainedModel.py&quot;, line 65, in pyramid_decom
    filtered = self.conv_gauss(current, self.kernel)
  File &quot;/home/amir/PycharmProjects/LPTN/loadPretrainedModel.py&quot;, line 58, in conv_gauss
    out = torch.nn.functional.conv2d(img, kernel, groups=img.shape[1])
RuntimeError: Given groups=721, expected weight to be at least 721 at dimension 0, but got weight of size [3, 1, 5, 5] instead

I am trying to run inference on the LPTN (Laplacian Pyramid Translation Network) model.
model = LPTN()

state_dict = torch.load('/home/amir/PycharmProjects/LPTN/experiments/pretrained_models/net_g_FiveK_numhigh3.pth',
                        map_location='cpu')

model.load_state_dict(state_dict, strict=False)
model.eval()

img = cv2.imread(&quot;/home/amir/PycharmProjects/LPTN/scripts/data_preparation/datasets/FiveK/FiveK_480p/train/A/2.jpg&quot;)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)


images = torch.from_numpy(np.asarray([img])).float()
output = model(images)
prediction = torch.argmax(output)

Here is the function where the error occurs:
def conv_gauss(self, img, kernel):
     padding = (2, 2, 2, 2)
     img = torch.nn.functional.pad(img, padding, mode='reflect')
     out = torch.nn.functional.conv2d(img, kernel, groups=img.shape[1])


Well i dont really have the code or anything but i am making a guess based what you have showed
import cv2
import torch

img = cv2.imread(&quot;/home/amir/PycharmProjects/LPTN/scripts/data_preparation/datasets/FiveK/FiveK_480p/train/A/2.jpg&quot;)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # H, W, C

img_tensor = torch.tensor(img, dtype=torch.float32) # Convert to torch tensor
img_tensor = img_tensor / 255. # Normalize [0 - 1] range (but depends on the model)
img_tensor = img_tensor.permute(2, 1, 0) # Reorder to C, H, W (torch requires this format)
img_tensor = img_tensor.unsqueeze(0) # Becomes this format B, C, H, W

# Set model to eval mode
model.eval()

# Run forward pass
with torch.no_grad(): # Dont run your gradients, speeds up inference
    predictions = model(img_tensor) # Get back predictions from model

