- Authors: Tao Yu, Runseng Feng, Ruoyu Feng, Jinming Liu, Xin Jin, Wenjun Zeng and Zhibo Chen.
- Institutes: University of Science and Technology of China; Eastern Institute for Advanced Study.
- [Paper] [Website] [Hugging Face Homepage]
TL; DR: Users can select any object in an image by clicking on it. With powerful vision models, e.g., SAM, LaMa and Stable Diffusion (SD), Inpaint Anything is able to remove the object smoothly (i.e., Remove Anything). Further, prompted by user input text, Inpaint Anything can fill the object with any desired content (i.e., Fill Anything) or replace the background of it arbitrarily (i.e., Replace Anything).
[2023/5/02] Enabling removing numerous objects while inputing multiple bboxs, hence making it convinient to P your pictures!
Click on an object in the image, and Inpainting Anything will remove it instantly!
- Click on an object;
- Segment Anything Model (SAM) segments the object out;
- Inpainting models (e.g., LaMa) fill the "hole".
Requires python>=3.8
python -m pip install torch torchvision torchaudio
python -m pip install -e segment_anything
python -m pip install -r lama/requirements.txt
Download the model checkpoints provided in segment_anything
and lama (e.g. sam_vit_h_4b8939.pth
and big-lama), and put them into ./pretrained_models
.
Specify an image and multiple bboxes which you want to erase them, and Inpaint-Anything will remove the object in the area of pre-selected bboxes.
python remove_OAOA.py \
--input_img ./example/remove-anything/17331682166557_.pic.jpg \
--dilate_kernel_size 15 \
--output_dir ./results \
--sam_model_type "vit_h" \
--sam_ckpt ./pretrained_models/sam_vit_h_4b8939.pth \
--lama_config ./lama_init_bak/configs/prediction/default.yaml \
--lama_ckpt ./pretrained_models/big-lama \
You only need to change --input_img
to your picture's path, and input the bboxes in the format of <x1, y1, x2, y2> in line 73 of remove_OAOA.py.
If you find this work useful for your research, please cite us:
@article{yu2023inpaint,
title={Inpaint Anything: Segment Anything Meets Image Inpainting},
author={Yu, Tao and Feng, Runseng and Feng, Ruoyu and Liu, Jinming and Jin, Xin and Zeng, Wenjun and Chen, Zhibo},
journal={arXiv preprint arXiv:2304.06790},
year={2023}
}