Skip to content

rogergheser/In-Context-Inpainting

 
 

Repository files navigation

In-Context Inpainting

Data is taken as output of In-Context Matting Original repo

Some results
Source Image Alpha Mask Guidance Image Result
backpack original backpack alpha backpack guidance backpack result
bear plushie original bear plushie alpha bear plushie guidance bear plushie result
dog original dog alpha dog guidance dog result

Requirements

We follow the environment setup of In-Context Matting and Blended Latent Diffusion, please refer to their repos.

Usage

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.

Generating only one sample

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 --help

Using other objects

If 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.

  1. Download the Pretrained Model:

    • Download the pretrained model from this link.
  2. Prepare the dataset: Ensure that your ICM-57 is ready following the dataset section.

  3. 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.

Dataset

ICM-57

  • Download link: ICM-57 Dataset
  • Installation Guide:
    1. After downloading, unzip the dataset into the datasets/ directory of the project.
    2. Ensure the structure of the dataset folder is as follows:
      datasets/ICM57/
      ├── image
      └── alpha
      

Contributors

About

Advanced Computer Vision Project 2024/25

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 52.9%
  • Python 47.1%