I’ve been working on a tool called RemBack for removing backgrounds from face images (more specifically for profile pics), and I wanted to share it here.
Why I made this?
I made RemBack because I wanted a tool that could remove backgrounds from face images—like profile pictures—more accurately and cleanly than existing options. I noticed that general-purpose tools like RemBG, while great for broad use, sometimes struggled with the fine details around faces. Also partly because I have quite a bit of free time LOL
About
For face detection: It uses MTCNN to detect the face and create a bounding box around it Segmentation: We now fine-tune a SAM (Segment Anything Model) which takes that box as a prompt to generate a mask for the face Mask Cleanup: The mask will then be refined Background Removal
Why It’s Better for Faces
Specialized for Faces: Unlike RemBG, which uses a general-purpose model (U2Net) for any image, RemBack focuses purely on faces. We combined MTCNN’s face detection with a SAM model fine-tuned on face data (CelebAMaskHQDataset). This should technically make it more accurate for face-specific details (You guys can take a look at the images below) Beyond Detection: MTCNN alone just detects faces—it doesn’t remove backgrounds. RemBack segments and removes the background. Fine-Tuned Precision: The SAM model is fine-tuned with box prompts, positive/negative points, and a mix of BCE, Dice, and boundary losses to sharpen edge accuracy—something general tools like RemBG don’t specialize in for faces.
Use
remback –image_path /path/to/input.jpg –output_path /path/to/output.jpg –checkpoint /path/to/checkpoint.pth
When you run remback –image_path /path/to/input.jpg –output_path /path/to/output.jpg for the first time, the checkpoint will be downloaded automatically.
Requirements
Python 3.9-3.11
Target audience
Everyone!
Comparison/Pictures will be shown in the github link below.
You can read more about it here. https://github.com/duriantaco/remback
Any feedback is welcome. Thanks and please leave a star or bash me here if you want 🙂
submitted by /u/papersashimi to r/Python
[link] [comments]
Laisser un commentaire