Blender is also an option, it can be scripted and it's possible to get pixel-perfect segmentation masks that way. The downside is obviously that you have to have a suitable number of 3-D scenes pre-built. But I think typically pasting foreground objects into scenes randomly is basically how these things are trained.