IOPaint 从零跑通:3 条命令上手 AI 图像修复实战指南与显存避坑清单 IOPaint 从零跑通3 条命令上手 AI 图像修复实战指南与显存避坑清单【免费下载链接】IOPaintImage inpainting tool powered by SOTA AI Model. Remove any unwanted object, defect, people from your pictures or erase and replace(powered by stable diffusion) any thing on your pictures.项目地址: https://gitcode.com/GitHub_Trending/io/IOPaint上次帮朋友处理一批照片要批量去掉水印和路人在同事机器上装 IOPaint 卡在依赖那一步折腾了半下午。IOPaint 是个开源的 AI 图像修复工具圈选一块区域就能用擦除模型填平或用扩散模型替换内容。下面按 3 步把完整流程走一遍最后补几个显存调优技巧。IOPaint 安装前准备 Python 虚拟环境先给项目单独开一个虚拟环境。它相当于给依赖单独开一间房二十多个包不会弄脏系统 Python。python3 -m venv iopaint-env source iopaint-env/bin/activateWindows 用户把第二行换成iopaint-env\Scripts\activate。IOPaint 安装和 PyTorch 版本怎么配对有 NVIDIA 显卡的话先装 CUDA 版 PyTorch再装主程序。这一步是翻车率最高的环节纯 CPU 用户直接装主程序即可。# GPUCUDA 11.8先装 GPU 版 PyTorch pip3 install torch2.1.2 torchvision0.16.2 --index-url https://download.pytorch.org/whl/cu118 # 主程序会自动带上 CPU 版 torchCPU 用户跳过上一行 pip3 install iopaintIOPaint 首次启动LaMa 模型先修一张图默认用 LaMa 模型起步体积小、速度快去水印去杂物够用。模型会在启动时自动下载首次会慢一点。启动后打开http://localhost:8080。iopaint start --modellama --devicecuda --port8080网页里的操作顺序很直接上传图片圈选要删掉的部分点修复出结果。这种压在照片上的半透明水印就是 LaMa 的主场圈一圈就能抹掉。IOPaint 扩散模型切换与显存怎么调LaMa 只会填平不会画新东西。想替换物体或者往外扩图outpainting就换扩散模型比如 PowerPaint。代价是显存占用高紧张就加两个开关。# 物体替换 / 扩图换扩散模型 iopaint start --modelSanster/PowerPaint-V1-stable-diffusion-inpainting --devicecuda # 显存不够就再加两个参数--low-mem 开启切片与分块--cpu-offload 把权重挪进内存 iopaint start --modelSanster/PowerPaint-V1-stable-diffusion-inpainting --devicecuda --low-mem --cpu-offload 另外两个常用模型manga专治漫画扫描版的网点噪点AnyText 能往图里写文字。IOPaint 命令行批量处理图片网页界面适合一张张修。几十张图用同一套掩码时走命令行更快。iopaint run接三个路径图片、掩码、输出。iopaint run --modellama --devicecpu \ --image/path/to/images --mask/path/to/masks --output./out--mask传文件夹时掩码要和原图同名传单张掩码图片则所有原图都用它。常见问题与提速技巧IOPaint 安装卡住或 torch 装不上现象pip3 install iopaint半天没动静最后报错。原因pip 默认拉 CPU 版 torch体积好几 GB网络一抖就断。解法先按上面的--index-url单独装好对应显卡的 torch再装主程序剩余包走国内镜像提速pip install iopaint -i https://pypi.tuna.tsinghua.edu.cn/simple。IOPaint 扩散模型出图全黑或全绿现象每次生成都是纯黑或纯绿。原因fp16 半精度推理在你的显卡上不稳定。解法其实改一行就过了加--no-half用全精度跑。IOPaint 显存不够怎么配现象SDXL 或 PowerPaint 直接报 CUDA out of memory。原因大模型权重本身就吃满显存。解法三档开关逐级叠--cpu-textencoder把文本编码器挪进内存--low-mem开注意力切片和 VAE 分块--cpu-offload把权重整体挪进内存逐个加到能跑为止。模型下载慢或想挪缓存目录现象首次启动卡在下载或默认缓存把系统盘占满。原因模型默认存到~/.cache。解法用--model-dir指定下载位置用iopaint list查看已下载的模型换机器时把整个模型文件夹拷过去就行。开头那半下午的折腾现在 3 条命令就够了。下一步可以试试iopaint start --enable-interactive-segSegment Anything 点一下就能把人物圈成掩码修复效率再高一截。【免费下载链接】IOPaintImage inpainting tool powered by SOTA AI Model. Remove any unwanted object, defect, people from your pictures or erase and replace(powered by stable diffusion) any thing on your pictures.项目地址: https://gitcode.com/GitHub_Trending/io/IOPaint创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考