IOPaint(旧 lama-cleaner) 使ってみた。 LaMaやZTISなどの Erase系のモデルは ぼかすみたいに消える。 RealisticVisionやPowerPaintなどの Stable Diffusion系のモデルは 新たに不思議なものを生成して 扱いが むずかしかった(写真の解像度や 空きメモリ容量 プロンプトによって かなり違う)。
PowerPaint-V1(text-guided)で使ったプロンプトは こんなの(プロンプトって たいてい生成するものを表すから 「消す」みたい指示 無理なのかも)。
Remove the selected object and seamlessly fill in the missing area with a realistic and natural background.


(上:合成 下:オリジナル/ZTIS/PowerPaint-V1)


(上:合成 下:オリジナル/ZTIS/PowerPaint-V1)


(上:合成 下:オリジナル/ZTIS)


(上:合成 下:オリジナル/ZTIS)



(上:RealisticVisionV51 中:オリジナル/ZTIS 下:/cv2/PowerPaint-V1)

(オリジナル/ZTIS)


(上:PowerPaint-V1(text-guided) 下:オリジナル/PowerPaint-V1(objet-remove)/RealisticVisionV51)


(上:PowerPaint-V1(objet-remove) 下:オリジナル/ZTIS/PowerPaint-V1(text-guided))
Dockerfileは こんなかんじ? GPUサポートありのpytorchのイメージが ベースとして使いやすかった。 マンガの吹き出しを消すならmangaモデルみたいに 適切なモデルを選んで追加する(モデル説明)。
FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
libsm6 libxext6 ffmpeg libfontconfig1 libxrender1 libgl1-mesa-glx \
curl python3-pip
RUN pip3 install --upgrade pip
RUN pip3 install xformers==0.0.22.post4 --index-url https://download.pytorch.org/whl/cu118
RUN pip3 install iopaint
RUN iopaint install-plugins-packages
RUN iopaint download --model=lama
RUN iopaint download --model=ldm
RUN iopaint download --model=zits
# RUN iopaint download --model=mat
# RUN iopaint download --model=fcf
# RUN iopaint download --model=manga
# RUN iopaint download --model=cv2
RUN iopaint download --model=migan
RUN iopaint download --model=runwayml/stable-diffusion-inpainting
RUN iopaint download --model=Uminosachi/realisticVisionV51_v51VAE-inpainting
# RUN iopaint download --model=redstonehero/dreamshaper-inpainting
# RUN iopaint download --model=Sanster/anything-4.0-inpainting
# RUN iopaint download --model=diffusers/stable-diffusion-xl-1.0-inpainting-0.1
# RUN iopaint download --model=Fantasy-Studio/Paint-by-Example
RUN iopaint download --model=Sanster/PowerPaint-V1-stable-diffusion-inpainting
# RUN iopaint download --model=Sanster/AnyText
EXPOSE 8080
CMD ["bash"]
これをIOPaint_GPU_Dockerfile.txtみたいな名前で保存して イメージをビルド(たくさんダウンロードするので 時間がかかる..zZ)
docker build -t iopaint-gpu -f IOPaint_GPU_Dockerfile.txt .
インタラクティブなシェルで コンテナを起動(IOPaintサーバーの起動オプションの調整や モデルの追加など いろいろ試すため)
docker run -it --gpus all --name iopaint -p 8080:8080 iopaint-gpu /bin/bash
コンテナにシェル接続して
docker exec -it iopaint /bin/bash
IOPaintサーバーを起動する
iopaint start --model=lama --device=cuda --remove-bg-device=cuda --low-mem --disable-nsfw-checker --cpu-textencoder --enable-interactive-seg --interactive-seg-model=sam2_base --interactive-seg-device=cuda --enable-remove-bg --port=8080 --host=0.0.0.0
自動領域選択の--enable-interactive-segは すごい便利。 RTX 3060 12GBで 広い範囲を生成するとメモリ不足になったから --low-memを付けてるけど(--cpu-offloadというオプションもある)。 --disable-nsfw-checkerと --cpu-textencodeがあると 省メモリになる。