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

4

14

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!!

Hamper answered 11/6, 2020 at 17:43 Comment(2)
On a conceptual level, how would you want interpolation for boolean data to work?Megrim
TL;DR - In Mask RCNN library, they are passing order=1, due to which this problem is popping up.<hr>Refer this issue. I have explained why it's happening. github.com/scikit-image/scikit-image/issues/6286Dannie
M
21

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.

Monarchist answered 11/6, 2020 at 18:3 Comment(4)
thnks! this works for meDwayne
Yeah ... which runs so well on Apple Silicon (not!)Smithery
It fixed my problem, I love you.Lamanna
@Smithery I installed it through conda, and it runs pretty fine on Apple Silicon. conda install scikit-image=0.16.2Flutist
B
9

pip install -U scikit-image==0.16.2

Bobine answered 24/6, 2020 at 17:5 Comment(0)
S
6

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

Sorrel answered 8/3, 2022 at 17:38 Comment(0)
S
4

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.

Skipp answered 18/9, 2022 at 2:41 Comment(1)
I couldn't downgrade to and older scikit-image because of C issues and then this finally resolved my issue. For the ones interested I had to change the resize function at the bottom of utils.py because that wasn't clear from the postFivefinger

© 2022 - 2024 — McMap. All rights reserved.