Skip to content

fix: use ImageNet normalization in latent_feature.ipynb (#53) - #56

Open
parallelArchitect wants to merge 1 commit into
rmaphoh:mainfrom
parallelArchitect:fix-imagenet-normalization-latent-notebook
Open

fix: use ImageNet normalization in latent_feature.ipynb (#53)#56
parallelArchitect wants to merge 1 commit into
rmaphoh:mainfrom
parallelArchitect:fix-imagenet-normalization-latent-notebook

Conversation

@parallelArchitect

Copy link
Copy Markdown

Fixes #53

latent_feature.ipynb was normalizing each image channel by its own per-image mean and std:

img[...,0] = (img[...,0] - img[...,0].mean())/img[...,0].std()

This is inconsistent with the training pipeline in util/datasets.py which uses fixed ImageNet statistics:

from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
transforms.Normalize(mean, std)

Fixed by replacing per-image normalization with the same ImageNet constants used during training:

imagenet_mean = np.array([0.485, 0.456, 0.406])
imagenet_std  = np.array([0.229, 0.224, 0.225])
img = (img - imagenet_mean) / imagenet_std

numpy is already imported in the notebook so no new dependencies are required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inconsistency in image normalization

1 participant