Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom Data Normalization and consider it in Post-processing #512

Closed
simon376 opened this issue Aug 24, 2022 · 2 comments · Fixed by #570
Closed

Allow custom Data Normalization and consider it in Post-processing #512

simon376 opened this issue Aug 24, 2022 · 2 comments · Fixed by #570
Assignees

Comments

@simon376
Copy link

Is your feature request related to a problem? Please describe.

By default (without warning the user!), if no transform_config_{train,val} is supplied to the datamodule, the code uses ImageNet statistics to normalize the images, which may be a good default for the included datasets, but should print some warning to the developer on custom data.

At the Post-Processing step, e.g. when visualizing the images using the ImageVisualizerCallback, Denormalize()(batch["image"][i].cpu()) is applied in Visualizer.visualize_batch (anomalib/anomalib/post_processing/visualizer.py:89), which again defaults to the ImageNet statistics. But unlike the input datamodule, the visualizer cannot be configured to use the normalization-configuration as configured in the input-dataset, which leads to the images being "denormalized" to different ranges so that $denorm(norm(image)) \ne image$

Describe the solution you'd like

  • Add parameter to Visualizer to configure Normalization
  • Or: automatically set parameters on callback when transform_config_{train,test} != None is discovered in datamodule
  • Warn user (at least for custom datasets), that by default, ImageNet Normalization is applied, when transform_config_{train,val} is None

Describe alternatives you've considered

  • ImageNet normalization may be great to reproduce paper results, but when used in other projects, custom input data normalization is common.

Additional context

@alexriedel1
Copy link
Contributor

alexriedel1 commented Aug 25, 2022

My suggestion to solving this issue is to save the (validation) preprocessing pipeline to the model so it can be loaded from the model file for inferencing.
This can be done, if the config always contains the default transformations at least. They will be saved as hyperparameters in the model file.

@djdameln
Copy link
Contributor

Thanks for pointing this out, I do agree with your observations. We will discuss internally what would be the best way to address these points and then assign someone from our team to work on it.

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 a pull request may close this issue.

4 participants