6.6 KiB
Note
本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
English · 原始项目 · 上游 README
原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
IOPaint
一款由 SOTA AI 模型驱动的免费开源 inpainting(图像修复)与 outpainting(图像扩展)工具。
|擦除(LaMa)|Replace|对象(PowerPaint)| |-----|----| |
| 绘制文字(AnyText) | Out-painting(PowerPaint) |
|---|---|
功能特性
-
完全免费且开源,可完全自托管,支持 CPU、GPU 与 Apple Silicon
-
OptiClean: 适用于 macOS 与 iOS 的对象擦除 App
-
支持多种 AI models 以执行擦除、inpainting 或 outpainting 任务。
- Erase models: 这些模型可用于从图像中移除不需要的对象、瑕疵、水印或人物。
- Diffusion models:这些模型可用于替换对象或执行 outpainting。一些常用的模型包括:
-
- Segment Anything: 精准且快速的交互式对象分割
- RemoveBG: 移除图像背景或为前景对象生成遮罩
- Anime Segmentation: 与 RemoveBG 类似,该模型专门针对动漫图像训练。
- RealESRGAN: 超分辨率
- GFPGAN: 人脸修复
- RestoreFormer: 人脸修复
-
FileManager: 便捷浏览图片,并直接保存到输出目录。
快速开始
启动 webui
IOPaint 提供便捷的 webui,可使用最新 AI 模型编辑图像。 运行以下命令即可轻松安装并启动 IOPaint:
# In order to use GPU, install cuda version of pytorch first.
# pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118
# AMD GPU users, please utilize the following command, only works on linux, as pytorch is not yet supported on Windows with ROCm.
# pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/rocm5.6
pip3 install iopaint
iopaint start --model=lama --device=cpu --port=8080
就这么简单,在浏览器中访问 http://localhost:8080 即可开始使用 IOPaint。
所有模型将在启动时自动下载。如需更改下载目录,可添加 --model-dir。更多文档见此处
其他支持的模型见此处,本地 sd ckpt/safetensors 文件用法见此处.
插件
启动服务时可指定要使用的插件,使用 iopaint start --help 可查看启用插件的命令。
更多插件演示见此处
iopaint start --enable-interactive-seg --interactive-seg-device=cuda
批量处理
也可在命令行中使用 IOPaint 批量处理图像:
iopaint run --model=lama --device=cpu \
--image=/path/to/image_folder \
--mask=/path/to/mask_folder \
--output=output_dir
--image 为包含输入图像的文件夹,--mask 为包含对应遮罩图像的文件夹。
当 --mask 为遮罩文件路径时,所有图像都将使用该遮罩进行处理。
下方可查看 IOPaint 支持的可用模型与插件的更多信息。
开发
安装 nodejs, 后安装前端依赖。
git clone https://github.com/Sanster/IOPaint.git
cd IOPaint/web_app
npm install
npm run build
cp -r dist/ ../iopaint/web_app
在 web_app 中创建 .env.local 文件,并填写后端 IP 与端口。
VITE_BACKEND=http://127.0.0.1:8080
启动前端开发环境
npm run dev
安装后端依赖并启动后端服务
pip install -r requirements.txt
python3 main.py start --model lama --port 8080
然后可访问 http://localhost:5173/ 进行开发。
修改前端代码后会自动更新,
但修改 Python 代码后需要重启后端服务。