This is due to Numpy version. Works fine with me, mine is
np.__version__  
Out[13]: '1.17.4'

So, seems np.where will not subscript bool types in the future (or even now as happening with you).
Now, you don’t need to play with numpy package. Just replace
masks = mask == obj_ids[:, None, None] 
with
masks = (mask == obj_ids[:, None, None]).astype(int)
and you’ll be good to go.
I’ve tried it, and I got the same result.