Data is taken as output of In-Context Matting Original repo
Some results| Source Image | Alpha Mask | Guidance Image | Result |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
We follow the environment setup of In-Context Matting and Blended Latent Diffusion, please refer to their repos.
For the purpose of our demo you may generate images which are the inpainting of different subjects taken in a subset of the ICM-57 dataset, you can simply usegenerate.py
python generate.py --output_dir results/This program will simply generate a set of images for each of the classes in inputs/ directory. The first image will be used as a background and the rest will be used to guide the foreground for inpainting.
If you want to generate only one sample, you can use the following command:
python image_blending.py --prompt <prompt> --init_image <init_image> --mask <mask> --guiding_image <guiding_image> For more information on the arguments, you can use the following command:
python image_blending.py --helpIf you want to use other objects samples from the ICM57 dataset, first you need to follow the instruction in In-Context Matting to download the dataset and the model weights.
-
Download the Pretrained Model:
- Download the pretrained model from this link.
-
Prepare the dataset: Ensure that your ICM-57 is ready following the dataset section.
-
Run the Evaluation: Use the following command to run the evaluation script. Replace the placeholders with the actual paths if they differ.
python eval.py --checkpoint PATH_TO_MODEL --save_path results/ --config config/eval.yaml
Now, you just need to move the results to the inputs/ directory and run the generate.py script.
ICM-57
- Download link: ICM-57 Dataset
- Installation Guide:
- After downloading, unzip the dataset into the
datasets/directory of the project. - Ensure the structure of the dataset folder is as follows:
datasets/ICM57/ ├── image └── alpha
- After downloading, unzip the dataset into the











