# Text to Image With ControlNet

ControlNetを利用した画像生成を行います。

Unityのカメラから取得したDepthまたはNormal情報を使用し画像を生成します。

| Input                                                                                                                                                                                                              | Depth                                                                                                                                                                                                                                             | Normal                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2FEx2AG8wqXbqOETCabhlc%2Fimage.png?alt=media\&token=82a25746-016f-4a70-8c67-c9213606bf86) | ![](https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2F5s0wQlf1521fTJHCsLmQ%2Fa76b827e-2172-4dc7-a985-f1b8b62c558f.png?alt=media\&token=42aaf849-e89a-4f20-b38f-597f79be5b6b) | ![](https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2FdVWGlien5tv0baQQBHHW%2F0d6300a8-6609-4eed-adc9-46bb88c5d125.png?alt=media\&token=24291ccc-8696-4433-8025-b03478f979b0) |

これにより形状が大事なゲームシステムに関連する箇所についても画像生成を用いることが出来るようになります。

※VRAMをかなり使用します。動作確認はVRAM12GBのGPUで行っています。VRAM不足で生成できない場合は解像度を落とすなどが必用となります。

<figure><img src="https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2FHopoCg1krhRMj8L70NpT%2Fimage.png?alt=media&#x26;token=8df41fbb-1d14-469a-9aeb-aa2850a07300" alt=""><figcaption></figcaption></figure>

Text2ImgWithControlNet.csコンポーネントをオブジェクトにアタッチして使用します

事前に設定用のカメラを設定します。CullingMaskのUIのチェックを外してください

＊これを行わない場合UI要素も最近傍のDepth情報を取得してしまうため下記RawImage等の影響を受けてしまいます。

<figure><img src="https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2F53EUD7NUJX6BpfGOF27d%2Fimage.png?alt=media&#x26;token=1876e109-1eef-4018-93d7-69fa34703a5e" alt=""><figcaption></figcaption></figure>

以下ローカルサーバーが立ち上がっている前提です。下記を参考にStartServerしてからご使用ください

[rkarusbnitsuite](https://docs.witchpot.com/production/rkarusbnitsuite "mention")

カメラの範囲に3Dオブジェクトを配置して使用します

<figure><img src="https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2FFLgeI1GV4TXSyIoDnKUK%2Fimage.png?alt=media&#x26;token=58de1c56-dbfd-471a-90f3-2fcc5a13e47a" alt=""><figcaption><p>カメラ範囲</p></figcaption></figure>

<figure><img src="https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2FdEJ8BzilS9O3RLYvbM0r%2Fimage.png?alt=media&#x26;token=bf3c329b-b4de-4c3a-a3b3-098027866c27" alt=""><figcaption><p>カメラ範囲に3Dモデルを配置</p></figcaption></figure>

パラメータ概要を下記に示します。特によく調整を行うパラメータを太字にしています

<table><thead><tr><th width="177">パラメータ</th><th>内容</th></tr></thead><tbody><tr><td><strong>Prompt</strong></td><td>生成したい画像を自然言語で入力</td></tr><tr><td><strong>NegativePrompt</strong></td><td>生成画像に含みたくない要素を自然言語で入力</td></tr><tr><td><strong>Size</strong></td><td>生成画像の横幅/高さをX/Yでpixelで入力します。</td></tr><tr><td>Steps</td><td><p>生成画像の精細さが変わります</p><p>生成画像がぼやけた感じになる場合に大きくしてください</p></td></tr><tr><td><strong>Cfg Scale</strong></td><td>プロンプトに従う強さ<br>プロンプトの要素の反映が弱い場合に多きな値に調整してください。</td></tr><tr><td>Seed</td><td>シード値を固定すると同じような画像が生成かの可能<br>-1の場合ランダムとなる</td></tr><tr><td><strong>Batch Count</strong></td><td>画像生成を行う枚数を指定します<br>1~100枚で選択することが出来ます。<br>生成画像はStreamingAssets/StableDiffusion内に保存されます。エクスプローラーで日時順などにして確認してください</td></tr><tr><td><strong>Camera</strong></td><td>上記で設定を行ったカメラを設定してください。</td></tr><tr><td><strong>ControlType</strong></td><td>Depth/Normalが選択可能です。<br>どちらも3Dモデル形状に則した画像生成が可能です。</td></tr><tr><td>Weight</td><td>ControlNetの影響を反映する強さを調整できます</td></tr><tr><td>Sampler</td><td>生成画像のニュアンスを変える</td></tr><tr><td><strong>Model</strong></td><td>ベースとなるモデル<br>変え方はも<a href="../production/moderuloranoshie">モデル/LoRAの差し替え</a>ご覧ください</td></tr><tr><td><strong>Lora</strong></td><td>追加学習により特定の要素を出しやすくする要素<br>変え方は<a href="../production/moderuloranoshie">モデル/LoRAの差し替え</a>をご覧ください<br>Loraを選択するとPromptに&#x3C;lora:ファイル名:1>が追加されて使用可能になります</td></tr></tbody></table>

<figure><img src="https://501701507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxpygm4kgEjp47Cbyg5EY%2Fuploads%2FooRZxuAqdCy1MgMdovaT%2F00026-4237068665.png?alt=media&#x26;token=63b5aa09-e91c-4d05-a496-c5985e84f2cf" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.witchpot.com/component/text-to-image-with-controlnet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
