An (old) photo of my son, before processing (left) and after automatic clipping (right) by the Rembg tool A libre and multi-platform command line tool to remove the background of images automatically, via a pattern recognition system. It can be used from the command line or from a library, and can process a local image or from a url, or a folder of images. It uses several pattern recognition models (U2Net, Silueta) and it is possible to modify them for specific needs (but not necessary in most cases).
https://cdn.masto.host/floss/media_attachments/files/109/534/268/981/792/028/original/ccba46ac04c03819.png