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

Normalize floating point cast #27249

Merged

Commits on Nov 10, 2023

  1. Normalize image - cast input images to float32.

    This is done if the input image isn't of floating type. Issues can occur when do_rescale=False is set in an image processor. When this happens, the image passed to the call is of type uint8 becuase of the type casting that happens in resize because of the PIL image library. As the mean and std values are cast to match the image dtype, this can cause NaNs and infs to appear in the normalized image, as the floating values being used to divide the image are now set to 0.
    
    The reason the mean and std values are cast is because previously they were set as float32 by default. However, if the input image was of type float16, the normalization would result in the image being upcast to float32 too.
    amyeroberts committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    7f07b07 View commit details
    Browse the repository at this point in the history
  2. Add tests

    amyeroberts committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    d4d1638 View commit details
    Browse the repository at this point in the history
  3. Remove float32 cast

    amyeroberts committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    eb1a1bb View commit details
    Browse the repository at this point in the history