Recently a new Image to Image script came out for Stable Diffusion called depthmap2mask and it allows you to automatically create 3d depth map masks from any given image. This allows way more flexibility when generating an image using the img2img option since you can now easily change any object in the foreground or the background while still keeping the same details from the base image. This is a total game-changer!