Floating-point image arrays in my machine have dtype np.float32, not float. This fails the dtype checks in function ocropus/utils.py, line 194 function autoinvert. I'm using numpy version 1.20.3 (more package info below) and adding a type check of image.dtype == np.float32 for the first case seems to yield the proper results. I'm using a Mac, Python 3.8.8, and am otherwise using the packages as specified in ./run venv and pip install -r requirements.txt.
Suggested solution
I don't have an ideal solution here--I'm sure that image.dtype == float might be sufficient in other systems, so we might not want to remove it. if (image.dtype == float) or (image.dtype == np.float32): is clunky but a potentially easy patch. Pinning the package versions for which float is always the expected dtype is a more robust solution.
Anyway, if I'm using this code wrong (always a possibility) I'm fine for this issue to be closed.
Issue
Floating-point image arrays in my machine have dtype
np.float32
, notfloat
. This fails the dtype checks in functionocropus/utils.py
, line 194 functionautoinvert
. I'm using numpy version1.20.3
(more package info below) and adding a type check ofimage.dtype == np.float32
for the first case seems to yield the proper results. I'm using a Mac, Python 3.8.8, and am otherwise using the packages as specified in./run venv
andpip install -r requirements.txt
.Suggested solution
I don't have an ideal solution here--I'm sure that
image.dtype == float
might be sufficient in other systems, so we might not want to remove it.if (image.dtype == float) or (image.dtype == np.float32):
is clunky but a potentially easy patch. Pinning the package versions for whichfloat
is always the expected dtype is a more robust solution.Anyway, if I'm using this code wrong (always a possibility) I'm fine for this issue to be closed.
My package versions: