Instead of writing
comp_output_depth_filename = "depth0000.png"
you need to write something like that:
"depth" + f"{bpy.context.scene.frame_current}".zfill(4) + ".png"
Otherwise, if timeline's frame != 0 (it happened to me, when I set pose for character from animation), then you will get error that depth/seg image not found.
Instead of writing
comp_output_depth_filename = "depth0000.png"
you need to write something like that:"depth" + f"{bpy.context.scene.frame_current}".zfill(4) + ".png"
Otherwise, if timeline's frame != 0 (it happened to me, when I set pose for character from animation), then you will get error that depth/seg image not found.