Stable Diffusionで、ControlNetのOpenposeを利用して画像を生成する上で必要な棒人間データですが
「Openpose Editor」というツールでできるということで早速利用してみたいと思います。
目次
Colaboratoryを起動し、stable-diffusion-webuiを取得する
!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
%cd /content/stable-diffusion-webui
Stable Diffusionを起動する
!python launch.py --share --xformers --enable-insecure-extension-access
![棒人間を作ってみる](https://res.cloudinary.com/dz7ruywxa/images/w_1024,h_590,c_scale/f_auto,q_auto/v1684560674/8961ea9d436b0c9cb18954f52de5c8f0/8961ea9d436b0c9cb18954f52de5c8f0.png?_i=AA 1024w, https://res.cloudinary.com/dz7ruywxa/images/w_300,h_173,c_scale/f_auto,q_auto/v1684560674/8961ea9d436b0c9cb18954f52de5c8f0/8961ea9d436b0c9cb18954f52de5c8f0.png?_i=AA 300w, https://res.cloudinary.com/dz7ruywxa/images/w_768,h_443,c_scale/f_auto,q_auto/v1684560674/8961ea9d436b0c9cb18954f52de5c8f0/8961ea9d436b0c9cb18954f52de5c8f0.png?_i=AA 768w, https://res.cloudinary.com/dz7ruywxa/images/f_auto,q_auto/v1684560674/8961ea9d436b0c9cb18954f52de5c8f0/8961ea9d436b0c9cb18954f52de5c8f0.png?_i=AA 1232w)
起動時に、以下のエラーが出ました。
RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA versions. PyTorch has CUDA Version=11.7 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.
以下を実行しランタイムを再起動します。
pip install torchvision==0.12.0
ディレクトリが変わっているので、以下で元の場所に移動します。
cd stable-diffusion-webui/
起動します。
!python launch.py --share --xformers --enable-insecure-extension-access
Extensionsタブから、Openpose Editorをインストールする
ExtensionsタブのInstall from URLに、「https://github.com/fkunn1326/openpose-editor.git」を入力し、Installボタンを押下します。
![棒人間を作ってみる](https://res.cloudinary.com/dz7ruywxa/images/w_1024,h_483,c_scale/f_auto,q_auto/v1684561827/b9f7192aee7da29736ca3740cffa90ad/b9f7192aee7da29736ca3740cffa90ad.png?_i=AA 1024w, https://res.cloudinary.com/dz7ruywxa/images/w_300,h_142,c_scale/f_auto,q_auto/v1684561827/b9f7192aee7da29736ca3740cffa90ad/b9f7192aee7da29736ca3740cffa90ad.png?_i=AA 300w, https://res.cloudinary.com/dz7ruywxa/images/w_768,h_362,c_scale/f_auto,q_auto/v1684561827/b9f7192aee7da29736ca3740cffa90ad/b9f7192aee7da29736ca3740cffa90ad.png?_i=AA 768w, https://res.cloudinary.com/dz7ruywxa/images/f_auto,q_auto/v1684561827/b9f7192aee7da29736ca3740cffa90ad/b9f7192aee7da29736ca3740cffa90ad.png?_i=AA 1530w)
インストールが完了すると以下のメッセージがでます。
![棒人間を作ってみる](https://res.cloudinary.com/dz7ruywxa/images/w_1024,h_147,c_scale/f_auto,q_auto/v1684561918/3f46972c4d2f4ba837659b6feb8c6f58/3f46972c4d2f4ba837659b6feb8c6f58.png?_i=AA 1024w, https://res.cloudinary.com/dz7ruywxa/images/w_300,h_43,c_scale/f_auto,q_auto/v1684561918/3f46972c4d2f4ba837659b6feb8c6f58/3f46972c4d2f4ba837659b6feb8c6f58.png?_i=AA 300w, https://res.cloudinary.com/dz7ruywxa/images/w_768,h_110,c_scale/f_auto,q_auto/v1684561918/3f46972c4d2f4ba837659b6feb8c6f58/3f46972c4d2f4ba837659b6feb8c6f58.png?_i=AA 768w, https://res.cloudinary.com/dz7ruywxa/images/f_auto,q_auto/v1684561918/3f46972c4d2f4ba837659b6feb8c6f58/3f46972c4d2f4ba837659b6feb8c6f58.png?_i=AA 1226w)
Installedに切り替えて、適用して再起動します。
![棒人間を作ってみる](https://res.cloudinary.com/dz7ruywxa/images/w_1024,h_425,c_scale/f_auto,q_auto/v1684561981/904af0100726951b6b600b87b25bd14a/904af0100726951b6b600b87b25bd14a.png?_i=AA 1024w, https://res.cloudinary.com/dz7ruywxa/images/w_300,h_124,c_scale/f_auto,q_auto/v1684561981/904af0100726951b6b600b87b25bd14a/904af0100726951b6b600b87b25bd14a.png?_i=AA 300w, https://res.cloudinary.com/dz7ruywxa/images/w_768,h_319,c_scale/f_auto,q_auto/v1684561981/904af0100726951b6b600b87b25bd14a/904af0100726951b6b600b87b25bd14a.png?_i=AA 768w, https://res.cloudinary.com/dz7ruywxa/images/w_1536,h_637,c_scale/f_auto,q_auto/v1684561981/904af0100726951b6b600b87b25bd14a/904af0100726951b6b600b87b25bd14a.png?_i=AA 1536w, https://res.cloudinary.com/dz7ruywxa/images/f_auto,q_auto/v1684561981/904af0100726951b6b600b87b25bd14a/904af0100726951b6b600b87b25bd14a.png?_i=AA 1658w)
再起動で、OpenPose Editorのタブが出来上がっていれば完了です。
![棒人間を作ってみる](https://res.cloudinary.com/dz7ruywxa/images/f_auto,q_auto/v1684562093/f64953b801121e0787d3c6cd3c899d14/f64953b801121e0787d3c6cd3c899d14.jpg?_i=AA 1000w, https://res.cloudinary.com/dz7ruywxa/images/w_300,h_149,c_scale/f_auto,q_auto/v1684562093/f64953b801121e0787d3c6cd3c899d14/f64953b801121e0787d3c6cd3c899d14.jpg?_i=AA 300w, https://res.cloudinary.com/dz7ruywxa/images/w_768,h_382,c_scale/f_auto,q_auto/v1684562093/f64953b801121e0787d3c6cd3c899d14/f64953b801121e0787d3c6cd3c899d14.jpg?_i=AA 768w)
実際に使ってみる
支点の部分をドラグ&ドロップすれば簡単に変更できます。
今回は、ControlNetを入れずに実行したため、Send to txt2imgではtxt2imgタブが表示されただけですが
Controlnetの所に、画像が反映されるようです。
一旦、画像としてローカルに保存しておけば、再利用可能なためその方がよいかもしれません。
![棒人間を作ってみる](https://res.cloudinary.com/dz7ruywxa/images/f_auto,q_auto/v1684562699/6c767c04cbef7c80dc29d183418c8ce4/6c767c04cbef7c80dc29d183418c8ce4.jpg?_i=AA 1000w, https://res.cloudinary.com/dz7ruywxa/images/w_300,h_150,c_scale/f_auto,q_auto/v1684562699/6c767c04cbef7c80dc29d183418c8ce4/6c767c04cbef7c80dc29d183418c8ce4.jpg?_i=AA 300w, https://res.cloudinary.com/dz7ruywxa/images/w_768,h_384,c_scale/f_auto,q_auto/v1684562699/6c767c04cbef7c80dc29d183418c8ce4/6c767c04cbef7c80dc29d183418c8ce4.jpg?_i=AA 768w)