This repository contains the tinygrad-ported version of the U2-Net model.
pip3 install -r requirements.txtThe repo contains the small models' weights in weights folder. The large (176 mb) weights can be downloaded from the following links:
python3 u2net_run.py -i /path/to/image_or_folder -m selected_modelWhere selected_model is one of:
fg: human segmentation (large variant, 176 mb)
fg_small: human segmentation (small variant, 4.7 mb)
sky_small: sky segmentation (small variant, 4.7 mb)
portrait: converts photo to pencil drawing (only large variant available, 176 mb)
By providing one photo that contains a visible sky and another photo showing only a sky, you can replace the sky in the original photo with the new one:
python3 u2net_run.py -i /path/to/image_with_sky -m sky_small -sky /path/to/new_skyForeground segmentation
Sky segmentation
Sky replacement
Apache-2.0 license




