![](https://digitallife.tokyo/wp/wp-content/uploads/2023/02/mikurun.gif)
画像生成AIに思った通りの姿勢の画像を出力させるのに、プロンプトで指示するのはとても難しかったのですが、画像で簡単に指示できるようになりました。img2imgを使う手もあったのですが、近い感じの画像を出力するので姿勢だけを指示するというのは難しかったので良いですね。
Stable Diffusion web UIにControlNetをインストール
![screencapture-127-0-0-1-30000-2023-02-17-21_17_41](https://live.staticflickr.com/65535/52694774228_c8e8783aef_c.jpg)
Stable Diffusion web UIのExtensionsタブで”Install from URL”を選んで”URL for extension’s git repository”に下記URLを入力して”Install”ボタンを押します。
https://github.com/Mikubill/sd-webui-controlnet.git
![screencapture-127-0-0-1-30000-2023-02-17-21_18_43](https://live.staticflickr.com/65535/52694774458_55d2075e32_c.jpg)
インストールが完了したら、”Installed”を選び、”Apply and restart UI”ボタンを押します。
さらに、下記よりControlNet用のモデルをダウンロードします。control_openpose-fp16.safetensorsだけでも良いですが、他のモデルも入れておくと良いかも。
https://huggingface.co/webui/ControlNet-modules-safetensors/tree/main
- canny:輪郭検出アルゴリズムを使用するモデル
- depth:画像の深度情報を元に画像生成を行うモデル
- hed:色変更やスタイル設定に適したモデル
- mlsd:直線的な輪郭の検出アルゴリズムを使用するモデル
- normal:法線マップ(ノーマルマップ)を使用するモデル
- openpose:ポーズ検出を使って画像生成を行うモデル
- scribble:落書きを元に画像生成を行うモデル
- seg:セマンティックセグメンテーションを使用するモデル
ダウンロードしたら、stable diffusion web UI配下の”extensions/sd-webui-controlnet/models“フォルダに入れます。
ControlNetの使い方
![screencapture-127-0-0-1-30000-2023-02-17-21_50_33](https://live.staticflickr.com/65535/52694696260_3cea0854a0_c.jpg)
txt2imgやimg2imgタブで、ControlNetの◀を押して展開します。
Enableにチェックを入れて、Processorと対応するModelを設定します。
canny と control_canny-fp16.safetensors
openposeやopenpose_hand と control_openpose-fp16.safetensors
Imageのところに姿勢の参考になる画像を入れます。
![46311448411_6907982ec2_c](https://live.staticflickr.com/65535/52694697400_3c76feb15c_c.jpg)
この画像でcannyで輪郭抽出して絵を描くと
![03335-790123229-angel in the light, white dress, wing, masterpiece, best quality](https://live.staticflickr.com/65535/52694777698_94a92b031a_c.jpg)
こんな感じに。img2imgよりは形に忠実に、その他はあまり引っ張られない感じですね。
背景があると背景の形も指示した感じになります。
![03336-4135284968-angel in the light, night, masterpiece, best quality](https://live.staticflickr.com/65535/52694697655_771bde3b3a_c.jpg)
openposeを使うと、画像から姿勢(関節等)の情報を抽出して絵を描いてくれます。
![03337-3765571428-angel in the light, night, masterpiece, best quality](https://live.staticflickr.com/65535/52694287286_23cdae5488_c.jpg)
姿勢以外はプロンプトで指示した感じになります。
![03338-2676016288-angel in the light, night, masterpiece, best quality](https://live.staticflickr.com/65535/52693770982_ea6a626c0a_c.jpg)
![screencapture-127-0-0-1-30000-2023-02-17-22_15_17](https://live.staticflickr.com/65535/52694695825_e027411d7a_c.jpg)
別の画像でも。openposeの例。
![03365-1142225586-pin-up model, idol, chair, masterpiece, best quality](https://live.staticflickr.com/65535/52693772872_be41e35c3a_c.jpg)
cannyの例。
![03361-1301714016-pin-up model, idol, chair, masterpiece, best quality](https://live.staticflickr.com/65535/52694552784_4b8781997c_c.jpg)
openposeを使ってモーション模写に再チャレンジ
以前、img2imgを使って、人の動きを模写できるかチャレンジしてみましたが、かなり難しい感じでした。
![](https://digitallife.tokyo/wp/wp-content/uploads/2022/10/animegif.gif)
今回、ControlNetのopenposeを使って同じ画像を使って生成してみたのがこちら。
![](https://digitallife.tokyo/wp/wp-content/uploads/2023/02/mikurun.gif)
動きはかなりそれっぽくなりました(一部姿勢の検出が間違っているところもありますが)。
ただ、やはり顔や服装の一貫性を持たせるのが一番難しい感じです。(プロンプトでなるべく変わりにくいものを指示するのと、seedを固定すると同じような絵になりやすいですが。)
![03426-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694700775_2027298b2b.jpg)
![03427-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694700750_abc84a046e.jpg)
![03428-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694554134_747bc3f9f2.jpg)
![03429-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694290156_9e572d0727.jpg)
![03430-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52693773632_8ec5231f92.jpg)
![03431-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694554109_7813fbe724.jpg)
![03432-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694780923_203abf56cc.jpg)
![03433-2481628271-18 years old hatsune miku, white t-shirt, black pants, running, black background, masterpiece, best quality](https://live.staticflickr.com/65535/52694290071_8dd984a778.jpg)
もう一つ、かなり以前に撮影させていただいた動画からも生成してみました。
服装はフレームごとにコロコロ変わっていますが、姿勢は連続性がある感じで面白いですね。
(元画像が姿勢の認識が難しい画像なので、間違いも多いのですが)
![](https://digitallife.tokyo/wp/wp-content/uploads/2023/02/sdanime.gif)
![03465-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695833053_2eb808e2de.jpg)
![03466-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52694828602_b39d1085f6.jpg)
![03467-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695343086_23a3a66184.jpg)
![03469-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757325_db208f56ce.jpg)
![03470-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52694828567_8b5cd2910f.jpg)
![03471-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757295_795db81fa3.jpg)
![03472-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52694828537_49883ef2c5.jpg)
![03473-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757270_a00ac17396.jpg)
![03474-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695833013_22dde39486.jpg)
![03475-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757220_53682cc390.jpg)
![03476-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695832988_ab032d261d.jpg)
![03477-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757185_dc83fdde90.jpg)
![03478-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757195_528ce92986.jpg)
![03479-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695832973_c42bd8eb8d.jpg)
![03480-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695832948_029fe86e74.jpg)
![03481-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52694828402_6da1eecf8f.jpg)
![03482-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695757130_50be5a136c.jpg)
![03483-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695832898_19bfd4b298.jpg)
![03484-2030801829-cute girl , red and white japanese shrine dress, dance, white hair, white background,, masterpiece, best quality](https://live.staticflickr.com/65535/52695607789_7cc03c0fc0.jpg)
(追記) 下記記事で、openposeの骨格モデルを編集できるOpenPose Editorや、実写風画像の生成について書きましたので合わせてご覧ください。
ピンバック: #StableDiffusion で 実写風女性画像生成に適したモデル3選 と モデルのマージ #ControlNet による姿勢の指定に便利な openpose-editor | Digital Life Innovator
ピンバック: 最新実写美少女モデル #BRAV5 と イラストモデル #AnythingV4 の併用による AIコスプレ写真 と #DepthLib での手の補正 #StableDiffusion #LoRA #ControlNet #コスプレ | Digital Life Innovator
ピンバック: Stable Diffusion の mov2mov で AI動画作成 #StableDiffusion #mov2mov #ControlNet | Digital Life Innovator
ピンバック: 2023年の振り返り | Digital Life Innovator