Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

How to translate flash (ImageClassifier) inference code into vanilla PyTorch? #1040

Answered by davidefiocco
davidefiocco asked this question in Q&A
Discussion options

You must be logged in to vote

Well... yes, the problem was in the preprocessing/resizing :/

I get correct results with

preprocess = transforms.Compose([
    transforms.ToTensor(),
    transforms.Resize((196, 196)), # This line fixed things
    transforms.ConvertImageDtype(torch.float),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])

also upon opening, the following line should take care of channels:

input_image = Image.open(filename).convert('RGB')

Replies: 1 comment

Comment options

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