Using .pth file to predict

Hey, I am new to image processing using PyTorch and have been trying to run a model to deblur images. However, I am not able to test with my own image.


Relevant Code:

class DeblurCNN(nn.Module):
    def __init__(self):
        super(DeblurCNN, self).__init__()
        self.conv1 = nn.Conv2d(3, 64, kernel_size=9, padding=2)
        self.conv2 = nn.Conv2d(64, 32, kernel_size=1, padding=2)
        self.conv3 = nn.Conv2d(32, 3, kernel_size=5, padding=2)
    def forward(self, x):
        x = F.relu(self.conv1(x))
        x = F.relu(self.conv2(x))
        x = self.conv3(x)
        return x

NOTE: I have given the correct model and image paths.

The model expects an input tensor while you are passing an image path as a str to it.
Load the image first, process it, and transform to a tensor before feeding it to the model.
Also, don’t use model.forward explicitly, but call the model directly via output = model(input_tensor).