Conv2d(): argument 'input' (position 1) must be Tensor, not dict

type or paste code here
model = MyModel()
    model_path='/home/pracheta2/semi-supervised/model_best_covid_original_500.pth.tar'
    model.load_state_dict(torch.load(model_path)['state_dict'])
    # load input images and prepare data
    datum_l_cc = utils.load_images(parameters['image_path'], 'L-CC')
    datum_r_cc = utils.load_images(parameters['image_path'], 'R-CC')
    datum_l_mlo = utils.load_images(parameters['image_path'], 'L-MLO')
    datum_r_mlo = utils.load_images(parameters['image_path'], 'R-MLO')
    x = {
        "L-CC": torch.Tensor(datum_l_cc).permute(0, 3, 1, 2).to(device),
        "L-MLO": torch.Tensor(datum_l_mlo).permute(0, 3, 1, 2).to(device),
        "R-CC": torch.Tensor(datum_r_cc).permute(0, 3, 1, 2).to(device),
        "R-MLO": torch.Tensor(datum_r_mlo).permute(0, 3, 1, 2).to(device),
    }
    transform = transforms.Compose([transforms.Resize(32),
                                      transforms.ToTensor(),
                                      transforms.Normalize(
                                          (.485, .456, .406), (.229, .224, .225))
                                      ])
    # run prediction:
    
    features, prediction_birads = model(x)
    print(prediction_birads)

Traceback (most recent call last):
File “birads.py”, line 103, in
inference(parameters_)
File “birads.py”, line 80, in inference
features, prediction_birads = model(x)
File “/home/pracheta2/anaconda3/envs/oldpy/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “birads.py”, line 20, in forward
x_feature = self.model_resnet(x)
File “/home/pracheta2/anaconda3/envs/oldpy/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “/home/pracheta2/anaconda3/envs/oldpy/lib/python3.6/site-packages/torchvision/models/resnet.py”, line 192, in forward
x = self.conv1(x)
File “/home/pracheta2/anaconda3/envs/oldpy/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “/home/pracheta2/anaconda3/envs/oldpy/lib/python3.6/site-packages/torch/nn/modules/conv.py”, line 338, in forward
self.padding, self.dilation, self.groups)

Hi,

The problem here is that the input x is a dictionary. It should be a tensor.

Thanks