IOPaint: Free Open-Source Image Inpainting and Object Removal

5月4日 Published inImage Tools

IOPaint is a free, open-source image inpainting tool designed to remove unwanted objects, fix blemishes, erase people, replace specific items, or expand image boundaries.

The software is self-hosted and runs on CPUs, NVIDIA GPUs, and Apple Silicon. IOPaint leverages several specialized AI models for erasing, inpainting, and outpainting:

  • Erase Models: Optimized for removing objects, defects, watermarks, or people from a scene.
  • Diffusion Models: Capable of replacing objects or extending image boundaries (outpainting).

Built-in utility models include:

  • RemoveBG: Used for erasing backgrounds or generating masks for foreground objects.
  • Anime Segmentation: A specialized version of RemoveBG tailored for anime-style artwork.

IOPaint features a web-based interface that allows you to edit images using the latest AI models. Installation and setup are straightforward.

1. Install PyTorch (for GPU Support)

If you are using an NVIDIA GPU:

pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118

For AMD GPU (Linux only):

pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/rocm5.6

2. Install IOPaint

pip3 install iopaint

3. Start the Application

iopaint start --model=lama --device=cpu --port=8080

All necessary models will download automatically upon the first launch. To specify a different download directory, use the --model-dir flag.

Plugin System

IOPaint includes a robust plugin system. You can view all available plugins by running iopaint start --help.

Batch Processing

In addition to the web UI, you can process multiple images directly from the command line:

iopaint run --model=lama --device=cpu \
--image=/path/to/image_folder \
--mask=/path/to/mask_folder \
--output=output_dir
  • --image: The directory containing your input images.
  • --mask: The directory containing mask images. If you point this parameter to a single file, that specific mask will be applied to every image in the input folder.

Setting Up a Development Environment

  1. Install Node.js on your system.

  2. Clone the repository and build the frontend:

git clone https://github.com/Sanster/IOPaint.git
cd IOPaint/web_app
npm install
npm run build
cp -r dist/ ../iopaint/web_app
  1. Create a .env.local file inside the web_app directory and set your backend IP and port:
VITE_BACKEND=http://127.0.0.1:8080
  1. Launch the frontend development server:
npm run dev
  1. Install the backend dependencies and start the service:
pip install -r requirements.txt
python3 main.py start --model lama --port 8080

Once the setup is complete, navigate to http://localhost:5173/. The frontend will automatically update when code changes are detected, though Python backend changes will require a manual restart.