qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.77k stars 1.03k forks source link

How to apply inferred mask to image #581

Open simonmelouah opened 11 months ago

simonmelouah commented 11 months ago

Following along with the multiclass segmentation example, the model performs fairly well on a custom dataset however when I try to use the mask on the original image using OpenCV's bitwise_and function I get

error: OpenCV(4.8.0) [/Users/runner/work/opencv-python/opencv-python/opencv/modules/core/src/arithm.cpp:230](https://file+.vscode-resource.vscode-cdn.net/Users/runner/work/opencv-python/opencv-python/opencv/modules/core/src/arithm.cpp:230): error: (-215:Assertion failed) (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1) in function 'binary_op'

Is there some post processing required to be able to use the inferred masks output by the trained model (apologies for the noise, have exhausted all possible other resources to try and figure it out)?