Input image dtype is bool. Interpolation is not defined with bool data type

Question:

I am facing this issue while using Mask_RCNN to train on my custom dataset with multiple classes.

This error occurs when I start training. This is what I get:

/home/parth/anaconda3/envs/compVision/lib/python3.7/site-packages/skimage/transform/_warps.py:830: FutureWarning: Input image dtype is bool. Interpolation is not defined with bool data type. Please set order to 0 or explicitely cast input image to another data type. Starting from version 0.19 a ValueError will be raised instead of this warning.
order = _validate_interpolation_order(image.dtype, order)

I keep getting this for like a hundred times and then the kernel dies.
Please Help!!

Asked By: parth.singh71

||

Answers:

Maybe you can try the skimage version 0.16.2。when I use the version 0.17.2, I faced the same issue.Good luck!Idont know why.

Answered By: user13729590

pip install -U scikit-image==0.16.2

Answered By: eson hu

I also had the same issue while training the MaskRCNN model with two classes. Then uninstalled existing (mine was 0.19.2) scikit-image by the command:

pip uninstall scikit-image

and installed 0.16.2 version of the same package by the command:

pip install scikit-image==0.16.2

Note: tensorflow and keras version used are:

tensorflow==2.2.0
keras==2.3.1

Answered By: ANJALI PC

I am assuming you are trying to transform a mask (i.e. in Mask_RCNN). If that is the case, one solution is to do as asked (explicitly cast the type to something else) and then convert it back into a boolean mask.

Changing the scikit-image version is really just a bandaid that eventually won’t work as other packages need to be updated that are incompatible with the old scikit-image version.

I have provided an example solution below that I have verified to work well:

# resize the mask cast as uint32 then convert back to bool
    img_resized = skimage.util.img_as_bool(skimage.transform.resize(
        image.astype(np.uint32), output_shape,
        order=order, mode=mode, cval=cval, clip=clip,
        preserve_range=preserve_range, anti_aliasing=anti_aliasing,
        anti_aliasing_sigma=anti_aliasing_sigma))
    return img_resized

Hope that helps. Seems like this is a common question, and downgrading scikit-image is not an ideal solution.

Answered By: thedustyengineer