Skip to content

Missing Normalization in inference.py #22

@pradyumnaym

Description

@pradyumnaym

Hi, I noticed that I was getting inaccurate results for my images when running inference through the inference.py script. I realized that the normalization performed during training (in the dataloader) is missing in the inference code. Just sharing the two-line change in case anyone comes across this issue

from torchvision.transforms import Normalize

normalize_img = Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
img = cv2.resize(image_crop, (256, 256), cv2.INTER_CUBIC)
img = img.transpose(2, 0, 1)/255.0
img = img[np.newaxis, ...]
img = torch.tensor(img, dtype=torch.float32).to('cuda')
img = normalize_img(img)
cont, _, _ = deco_model(img)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions