145 lines
6.6 KiB
Markdown
145 lines
6.6 KiB
Markdown
<!-- WEHUB_ZH_README -->
|
|
> [!NOTE]
|
|
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
|
|
> [English](./README.en.md) · [原始项目](https://github.com/Sanster/IOPaint) · [上游 README](https://github.com/Sanster/IOPaint/blob/HEAD/README.md)
|
|
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
|
|
|
|
<h1 align="center">IOPaint</h1>
|
|
<p align="center">一款由 SOTA AI 模型驱动的免费开源 inpainting(图像修复)与 outpainting(图像扩展)工具。</p>
|
|
|
|
<p align="center">
|
|
<a href="https://github.com/Sanster/IOPaint">
|
|
<img alt="总下载量" src="https://pepy.tech/badge/iopaint" />
|
|
</a>
|
|
<a href="https://pypi.org/project/iopaint">
|
|
<img alt="版本" src="https://img.shields.io/pypi/v/iopaint" />
|
|
</a>
|
|
<a href="">
|
|
<img alt="Python 版本" src="https://img.shields.io/pypi/pyversions/iopaint" />
|
|
</a>
|
|
<a href="https://huggingface.co/spaces/Sanster/iopaint-lama">
|
|
<img alt="HuggingFace Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace-Spaces-blue" />
|
|
</a>
|
|
<a href="https://colab.research.google.com/drive/1TKVlDZiE3MIZnAUMpv2t_S4hLr6TUY1d?usp=sharing">
|
|
<img alt="在 Colab 中打开" src="https://colab.research.google.com/assets/colab-badge.svg" />
|
|
</a>
|
|
</p>
|
|
|
|
|擦除([LaMa](https://www.iopaint.com/models/erase/lama))|Replace|对象([PowerPaint](https://www.iopaint.com/models/diffusion/powerpaint))|
|
|
|-----|----|
|
|
|<video src="https://github.com/Sanster/IOPaint/assets/3998421/264bc27c-0abd-4d8b-bb1e-0078ab264c4a"> | <video src="https://github.com/Sanster/IOPaint/assets/3998421/1de5c288-e0e1-4f32-926d-796df0655846">|
|
|
|
|
|绘制文字([AnyText](https://www.iopaint.com/models/diffusion/anytext))|Out-painting([PowerPaint](https://www.iopaint.com/models/diffusion/powerpaint))|
|
|
|---------|-----------|
|
|
|<video src="https://github.com/Sanster/IOPaint/assets/3998421/ffd4eda4-f7d4-4693-93d8-d2cd5aa7c6d6">|<video src="https://github.com/Sanster/IOPaint/assets/3998421/c4af8aef-8c29-49e0-96eb-0aae2f768da2">|
|
|
|
|
|
|
## 功能特性
|
|
|
|
- 完全免费且开源,可完全自托管,支持 CPU、GPU 与 Apple Silicon
|
|
- [Windows 一键安装程序](https://www.iopaint.com/install/windows_1click_installer)
|
|
- [OptiClean](https://apps.apple.com/ca/app/opticlean/id6452387177): 适用于 macOS 与 iOS 的对象擦除 App
|
|
- 支持多种 AI [models](https://www.iopaint.com/models) 以执行擦除、inpainting 或 outpainting 任务。
|
|
- [Erase models](https://www.iopaint.com/models#erase-models): 这些模型可用于从图像中移除不需要的对象、瑕疵、水印或人物。
|
|
- Diffusion models:这些模型可用于替换对象或执行 outpainting。一些常用的模型包括:
|
|
- [runwayml/stable-diffusion-inpainting](https://huggingface.co/runwayml/stable-diffusion-inpainting)
|
|
- [diffusers/stable-diffusion-xl-1.0-inpainting-0.1](https://huggingface.co/diffusers/stable-diffusion-xl-1.0-inpainting-0.1)
|
|
- [andregn/Realistic_Vision_V3.0-inpainting](https://huggingface.co/andregn/Realistic_Vision_V3.0-inpainting)
|
|
- [Lykon/dreamshaper-8-inpainting](https://huggingface.co/Lykon/dreamshaper-8-inpainting)
|
|
- [Sanster/anything-4.0-inpainting](https://huggingface.co/Sanster/anything-4.0-inpainting)
|
|
- [BrushNet](https://www.iopaint.com/models/diffusion/brushnet)
|
|
- [PowerPaintV2](https://www.iopaint.com/models/diffusion/powerpaint_v2)
|
|
- [Sanster/AnyText](https://huggingface.co/Sanster/AnyText)
|
|
- [Fantasy-Studio/Paint-by-Example](https://huggingface.co/Fantasy-Studio/Paint-by-Example)
|
|
|
|
- [Plugins](https://www.iopaint.com/plugins):
|
|
- [Segment Anything](https://iopaint.com/plugins/interactive_seg): 精准且快速的交互式对象分割
|
|
- [RemoveBG](https://iopaint.com/plugins/rembg): 移除图像背景或为前景对象生成遮罩
|
|
- [Anime Segmentation](https://iopaint.com/plugins/anime_seg): 与 RemoveBG 类似,该模型专门针对动漫图像训练。
|
|
- [RealESRGAN](https://iopaint.com/plugins/RealESRGAN): 超分辨率
|
|
- [GFPGAN](https://iopaint.com/plugins/GFPGAN): 人脸修复
|
|
- [RestoreFormer](https://iopaint.com/plugins/RestoreFormer): 人脸修复
|
|
- [FileManager](https://iopaint.com/file_manager): 便捷浏览图片,并直接保存到输出目录。
|
|
|
|
|
|
## 快速开始
|
|
|
|
### 启动 webui
|
|
|
|
IOPaint 提供便捷的 webui,可使用最新 AI 模型编辑图像。
|
|
运行以下命令即可轻松安装并启动 IOPaint:
|
|
|
|
```bash
|
|
# 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`。更多文档见[此处](https://www.iopaint.com/install/download_model)
|
|
|
|
其他支持的模型见[此处](https://www.iopaint.com/models),本地 sd ckpt/safetensors 文件用法见[此处](https://www.iopaint.com/models#load-ckptsafetensors).
|
|
|
|
### 插件
|
|
|
|
启动服务时可指定要使用的插件,使用 `iopaint start --help` 可查看启用插件的命令。
|
|
|
|
更多插件演示见[此处](https://www.iopaint.com/plugins)
|
|
|
|
```bash
|
|
iopaint start --enable-interactive-seg --interactive-seg-device=cuda
|
|
```
|
|
|
|
### 批量处理
|
|
|
|
也可在命令行中使用 IOPaint 批量处理图像:
|
|
|
|
```bash
|
|
iopaint run --model=lama --device=cpu \
|
|
--image=/path/to/image_folder \
|
|
--mask=/path/to/mask_folder \
|
|
--output=output_dir
|
|
```
|
|
|
|
`--image` 为包含输入图像的文件夹,`--mask` 为包含对应遮罩图像的文件夹。
|
|
当 `--mask` 为遮罩文件路径时,所有图像都将使用该遮罩进行处理。
|
|
|
|
下方可查看 IOPaint 支持的可用模型与插件的更多信息。
|
|
|
|
## 开发
|
|
|
|
安装 [nodejs](https://nodejs.org/en), 后安装前端依赖。
|
|
|
|
```bash
|
|
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
|
|
```
|
|
|
|
启动前端开发环境
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
安装后端依赖并启动后端服务
|
|
```bash
|
|
pip install -r requirements.txt
|
|
python3 main.py start --model lama --port 8080
|
|
```
|
|
|
|
然后可访问 `http://localhost:5173/` 进行开发。
|
|
修改前端代码后会自动更新,
|
|
但修改 Python 代码后需要重启后端服务。
|