Using semantic segmentation and in-painting to remove objects based on labels. Inspired by Inpaint Anything by Tao Yu et al. Using MaskFormer for semantic segmentation to select areas to remove using LaMa for in-painting.
Install the package.
python -m pip install semremover
Use the SemanticObjectRemover
in your code.
from semremover import SemanticObjectRemover
sem_obj_remover = SemanticObjectRemover()
labels = ['car', 'minibike', 'van']
inpainted_image = sem_obj_remover.remove_objects_from_image("example.jpg", labels)
Install the Python requirements.
python -m pip install -r requirements.txt
To use the script you can call it with various options. The first positional argument is the input path, which can point to either an image or a directory of images. To remove objects from a picture add them to the labels option when running the script. The default labels can be found in ./semremover/models/config/ade20k_labels.json
.
input
python -m semremover example/paris.jpg --labels car minibike van
Output