eightban's memo

残しておきたい記事をまとめてみました。このブログに書いてあるドキュメントやブログで配布しているファイルの使用によって発生するいかなる損害に対してもこのブログの管理者は責任を負いません。使用する場合は自己責任のもとに使用してください。

stable-diffusion

DW OpenPose[DWpose](棒人間)を作成する

更新日:

DWposeはOpenpose fullより詳細に顔や指を表現できる全身用プリプロセッサです

DWpose

ControlNet auxiliary modelsを使って作成します

pip install controlnet-aux==0.0.7
pip install mediapipe
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.1"
mim install "mmdet>=3.1.0"
mim install "mmpose>=1.1.0"

ダウンロードした後必要なファイルを抽出

https://github.com/patrickvonplaten/controlnet_aux

"controlnet_aux-master\src\controlnet_aux\dwpose\dwpose_config\dwpose-l_384x288.py"
"controlnet_aux-master\src\controlnet_aux\dwpose\yolox_config"

ライブラリーにコピー 環境に合わせてください

"D:\WinPython\python-3.10.11.amd64\Lib\site-packages\controlnet_aux\dwpose\dwpose_config\dwpose-l_384x288.py"

"D:\WinPython\python-3.10.11.amd64\Lib\site-packages\controlnet_aux\dwpose\yolox_config\yolox_l_8xb8-300e_coco.py"

# -*- coding: utf-8 -*-
import requests
from PIL import Image
from io import BytesIO

#
from controlnet_aux import DWposeDetector

# load image
url = "https://huggingface.co/lllyasviel/sd-controlnet-openpose/resolve/main/images/pose.png"

response = requests.get(url)
img = Image.open(BytesIO(response.content)).convert("RGB").resize((512, 512))

processor_id = 'dwpose'

# specify configs, ckpts and device, or it will be downloaded automatically and use cpu by default
# det_config: ./src/controlnet_aux/dwpose/yolox_config/yolox_l_8xb8-300e_coco.py
# det_ckpt: https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_l_8x8_300e_coco/yolox_l_8x8_300e_coco_20211126_140236-d3bd2b23.pth
# pose_config: ./src/controlnet_aux/dwpose/dwpose_config/dwpose-l_384x288.py
# pose_ckpt: https://huggingface.co/wanghaofan/dw-ll_ucoco_384/resolve/main/dw-ll_ucoco_384.pth
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
dwpose = DWposeDetector( device=device)
#dwpose = DWposeDetector(det_config=det_config, det_ckpt=det_ckpt, pose_config=pose_config, pose_ckpt=pose_ckpt, device=device)
processed_image = dwpose(img, to_pil=True)

processed_image.save(f"{processor_id}.png")

バッチ処理で複数のポーズを作りたい場合はこちら
http://memo.eightban.com/stable-diffusion/openposedwpose

-stable-diffusion

Copyright© eightban's memo , 2024 All Rights Reserved Powered by STINGER.