[Enhance]: Convert mask to bool before using it as img's index for robustness and speedup (#3870)
[Enhance]: Convert mask to bool before using it as img's index for robustness and speedup (#3870)

* Convert mask to bool before using it as img's index

* lint

* Rewrite code in more concise way
open-mmlab/mmdetection,open-mmlab/mmdetection