does anyone know, how to train the rembg model with our own images and save it into Pickel file This is rembg model: https://github.com/danielgatis/rembg please help me, How to train the above model.
2 Answers
The model provided simply uses a U^2-Net Model to predict a mask of pixels indicating whether a pixel is the background or foreground. The github readme links to an existing python implementation in pytorch, which is from the original authors of the paper. This also contains the training script they used called u2net_train.py
. If you want to train this model yourself you need to make sure that you have pairs of images with one image being the original/input image and the other being a mask indicating which pixels are the foreground and background. You can then either use the existing implementation (by making some adjustments to the script) or write a training loop yourself.

- 7,472
- 2
- 8
- 23
I'm digging up this post because I (finally) stumbled upon what would make a good base for a proper howto train your own rembg model.
It's a post by endh1337in Daniel Gatis's rembg Github.
https://github.com/danielgatis/rembg/issues/193#issuecomment-1055534289
As per Internet Rule #35, I'd be glad to make a proper howto as soon as I have this procedure personally reviewed and tested.
Meanwhile, I hope it helps at least someone!

- 11
- 3
-
1While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – redhqs Aug 16 '22 at 23:45