That’s how the labels come to me. (And yes, n^2 is naive - lots to save be checking bbox overlaps, etc.).
The masks I get are in a hierarchy (they overlap). I can build some kind of representation for it.
But again, was kinda hoping there are already tools for this (actually the cv2 contours API talk about hierarchies … ).