Skip to content

loaded model mismatch error #1111

Closed Answered by LuluW8071
Mudassir-A asked this question in Q&A
Discussion options

You must be logged in to vote

Looking at the error, the image is directly loaded to model without any transformation for classification. It suggests that the image you sent to the model must be of size 128*128. The image should be transformed, same as you transformation process when fitted the train image during training.

# Function to transform the image
def load_and_preprocess_image(image_path):
    """
    Load and preprocess the image from the specified path.
    """
    custom_image_uint8 = torchvision.io.read_image(str(image_path))
    custom_image = custom_image_uint8.type(torch.float32)

    # Divide the image pixel values by 255 to get them between [0, 1]
    custom_image = custom_image / 255.
    custom_imag…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mudassir-A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants