乐于分享
好东西不私藏

IOPaint AI 图像修复工具

IOPaint AI 图像修复工具

IOPaint AI 图像修复工具

官网: https://www.iopaint.com


一、项目简介

IOPaint 是一款完全免费、开源、本地运行的 AI 图像修复(Inpainting)和扩展(Outpainting)工具,基于 SOTA 模型开发,完全自托管,不依赖任何在线 API 服务。

核心功能一览

功能
说明
🔫 物体擦除
去除路人、水印、瑕疵、杂物、人物等
🎨 对象替换
用 AI 生成内容替换图片指定区域
✍️ 文字绘制
在图片上生成风格一致的文字
🔄 图像扩展(Outpainting)
向图片边界外 AI 扩展填充新内容
🖼️ 抠图
RemoveBG 等插件一键抠背景
👤 人脸修复
GFPGAN / RestoreFormer 修复老照片人脸
📐 超分辨率
RealESRGAN 放大到 4K
🖌️ 交互分割
Segment Anything 精确选区
🎞️ GIF 对比
生成修复前后 GIF 对比图

二、pip 安装

环境准备

安装 Python3.10.2 、最低3.8+

关注公众号回复「Python安装包」获得

N卡驱动 最低 522.25

安装命令 # GPU 20、30系列显卡加速(CUDA 11.8) pip install torch==2.1.2 torchvision==0.16.2 -i https://pypi.tuna.tsinghua.edu.cn/simple --index-url https://download.pytorch.org/whl/cu118  # GPU 40系列显卡加速(CUDA 12.1) pip install torch==2.1.2 torchvision==0.16.2 -i https://pypi.tuna.tsinghua.edu.cn/simple --index-url https://download.pytorch.org/whl/cu121  # GPU 50系列显卡加速(CUDA 12.8) pip install torch==2.7.1 torchvision==0.22.1 -i https://pypi.tuna.tsinghua.edu.cn/simple --index-url https://download.pytorch.org/whl/cu128  # AMD GPU(仅 Linux) pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/rocm5.6 

安装 IOPaint

pip install iopaint -i https://pypi.tuna.tsinghua.edu.cn/simple 

快速启动

# CPU 模式(最简单) iopaint start --model=lama --device=cpu --port=8080  
# GPU 加速 iopaint start --model=lama --device=cuda --port=8080 

访问 http://localhost:8080,首次启动会下载模型

对比效果图

卸载卸载

pip uninstall iopaint # 模型缓存保留在 ~/.cache/ 下,需手动删除

三、国内用户特别设置

HuggingFace 在国内下载模型可能遇到网络问题,推荐使用镜像:

# Linux / macOS HF_ENDPOINT=https://hf-mirror.com iopaint start  
# Windows(PowerShell)set HF_ENDPOINT=https://hf-mirror.com iopaint start 

四、模型说明与选择

3 大类模型

IOPaint 支持的模型分为三大类:擦除模型专用扩散模型、SD模型等。

擦除模型(Erase Models)

用于去除图片中不需要的物体、人物、水印、瑕疵。不需要写提示词,直接涂抹区域即可。

选择模型替换红色框内容即可

模型
命令
推荐度
特点
LaMa--model=lama
⭐⭐⭐
使用傅里叶卷积的高分辨率鲁棒大掩码图像修复
MAT--model=mat
⭐⭐⭐
带掩码的大型孔洞图像修复变换器
MIGAN--model=migan
⭐⭐⭐
最小体积(27MB),资源占用最少,适合轻量设备
LDM--model=ldm
⭐⭐
使用潜在扩散模型进行高分辨率图像合成
ZITS--model=zits
⭐⭐
增量式变压器结构增强的图像修复与掩码位置编码
FcF--model=fcf
⭐⭐
更好的图像修复的关键:结构和纹理携手并进
Manga--model=manga
漫画风格专用

小白直接用 lama,效果稳定优秀。

专用扩散模型

模型
命令
功能
PowerPaintV2--model Sanster/PowerPaint-V2-stable-diffusion-inpainting
将任意 SD1.5 模型转为修复模型,支持文本/形状引导、物体移除、扩展
AnyText--model Sanster/AnyText
在图片上生成指定文字,文字与图像风格匹配
Paint by Example--model Fantasy-Studio/Paint-by-Example
用示例图片引导生成相似内容
InstructPix2Pix--model timbrooks/instruct-pix2pix
输入文本指令编辑图片(如"把背景换成秋天")

五、插件功能详解

启动时通过参数启用插件:

# 启用多个插件示例 iopaint start \   --enable-interactive-seg --interactive-seg-device=cuda \   --enable-rembg \   --enable-gfpgan 

⚠️ 大多数插件需要 torchvision,按 pytorch.org 安装对应版本。

插件列表

插件
命令
功能
Segment Anything--enable-interactive-seg
高精度交互式目标分割,精确选区
RemoveBG--enable-rembg
一键去背景 / 生成前景掩码
Anime Segmentation--enable-anime-seg
动漫图像专用分割
RealESRGAN--enable-realesrgan
超分辨率放大(2x / 4x / 8x)
GFPGAN--enable-gfpgan
人脸修复(轻度)
RestoreFormer--enable-restoreformer
人脸修复(高质量,但更慢)

查看完整参数:iopaint start --help


六、使用方法

Web 界面操作流程

  1. 1. 启动后打开浏览器访问 http://localhost:8080
  2. 2. 左侧选择工具:Erase(擦除)/ Replace(替换)/ Outpaint(扩展)/ Text(文字)等
  3. 3. 用画笔涂抹要处理的区域
  4. 4. 点击「生成」等待 AI 处理
  5. 5. 处理完成后点击「下载」保存

命令行单张处理

iopaint run \   --model=lama \   --image=input.png \   --mask=mask.png \   --output=output_dir/ 
  • • mask.png:白色=要修复的区域,黑色=保留的区域

命令行批处理

iopaint run \   --model=lama --device=cpu \   --image=/path/to/image_folder \   --mask=/path/to/mask_folder \   --output=output_dir/ 
  • • --mask 如果指定为单个文件,则所有图片共用该掩码

七、命令速查表

# 最简单启动(CPU + LaMa) iopaint start --model=lama --device=cpu --port=8080  # GPU 加速 iopaint start --model=lama --device=cuda --port=8080  # 启用交互分割 + 抠背景 + 人脸修复 iopaint start --enable-interactive-seg --enable-rembg --enable-gfpgan  # 指定模型和下载目录(避免中文路径问题) iopaint start --model=runwayml/stable-diffusion-inpainting --model-dir=D:/iopaint_models  # 国内镜像加速set HF_ENDPOINT=https://hf-mirror.com iopaint start --model=lama  # 16xx 显卡防黑屏 iopaint start --model=lama --no-half  # 命令行批处理 iopaint run --model=lama --image=./input --mask=./mask.png --output=./output  # 查看所有参数 iopaint start --help iopaint run --help

八、使用场景推荐配置

场景
推荐模型 + 设置
去除照片中的路人
LaMa + Erase 工具,直接涂抹
去掉背景水印/瑕疵
LaMa + 高精度掩码
AI 换脸 / 把某人 P 进图里
PowerPaintV2 + Replace + 文本提示
AI 扩图(竖图变横图)
PowerPaintV2 + Outpainting / Expander
老照片人脸修复
GFPGAN 或 RestoreFormer 插件
低分辨率图片放大 4K
RealESRGAN 插件(4x)
图片上写文字
AnyText 模型
动漫图片处理
Anime Segmentation 插件 + anything-4.0-inpainting
批量修图
命令行批处理模式

Windows 安装脚本

脚本有bug,在安装使用会出现问题,小编让AI修复,但是无法打包,感兴趣的

关注公众号回复「IOPaint AI Windows安装脚本」获得

小编只整理了一部分,lama模型最常用,去水印、瑕疵、杂物等,每个模型都有其擅长的部分,感兴趣的可以阅读官方文档。

注:

  1. 1. 资源收集于网络,仅做学习和交流使用,请于下载后24小时内删除。
  2. 2. 本站发布的内容若侵犯到您的权益,请联系删除。