aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.42k stars 2.44k forks source link

ChangeColorTemperature crashes with numpy broadcast error #720

Open cgpadwick opened 4 years ago

cgpadwick commented 4 years ago

When trying the ChangeColorTemperature augmentation, it crashes with the following error

    454             multipliers_floored
    455             + interpolation_factors
--> 456             * (multipliers_ceiled - multipliers_floored)
    457         )
    458 

ValueError: operands could not be broadcast together with shapes (196,) (196,3) 

The interpolation_factors array is only size 196, while the multipliers_ceiled and multipliers_floored arrays are (196, 3). The fix is as follows:

        interp[:, 0] = interpolation_factors
        interp[:, 1] = interpolation_factors
        interp[:, 2] = interpolation_factors
        multipliers = (
            multipliers_floored
            + interp
            * (multipliers_ceiled - multipliers_floored)
        )

I will post a fix and submit an upstream pull request.

cgpadwick commented 4 years ago

I see now that this is fixed in master but is broken in pip install imgaug

meet-minimalist commented 4 years ago

@cgpadwick Try this manual patch.

https://github.com/aleju/imgaug/issues/646#issuecomment-604556600