<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>插圖 on kenji.blog</title><link>http://kenji.blog/zh-tw/tags/%E6%8F%92%E5%9C%96/</link><description>Recent content in 插圖 on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>zh-tw</language><copyright>kenjinote</copyright><lastBuildDate>Thu, 06 Apr 2023 00:43:19 +0900</lastBuildDate><atom:link href="http://kenji.blog/zh-tw/tags/%E6%8F%92%E5%9C%96/index.xml" rel="self" type="application/rss+xml"/><item><title>如何使用 AI (Stable Diffusion) 生成插圖</title><link>http://kenji.blog/zh-tw/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/</link><pubDate>Thu, 06 Apr 2023 00:43:19 +0900</pubDate><guid>http://kenji.blog/zh-tw/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/</guid><description>&lt;img src="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img.png" alt="Featured image of post 如何使用 AI (Stable Diffusion) 生成插圖" />&lt;h1 id="什麼是-stable-diffusion">什麼是 Stable diffusion
&lt;/h1>&lt;p>Stable diffusion 是由德國慕尼黑大學研究團隊開發的，一種根據輸入文字資訊生成圖像的 AI。
透過讓它學習各種圖像，它可以生成從寫實照片到插圖等各式各樣的圖片。&lt;/p>
&lt;p>這次，我將介紹如何使用 Stable diffusion 的預訓練資料來生成插圖。&lt;/p>
&lt;h1 id="需要準備的東西">需要準備的東西
&lt;/h1>&lt;ul>
&lt;li>Google 帳號&lt;/li>
&lt;/ul>
&lt;p>僅此而已&lt;/p>
&lt;h1 id="生成步驟">生成步驟
&lt;/h1>&lt;ol>
&lt;li>打開 &lt;a class="link" href="https://colab.research.google.com" target="_blank" rel="noopener"
>https://colab.research.google.com&lt;/a>&lt;/li>
&lt;li>從左上角的 &lt;code>檔案&lt;/code> 中選擇 &lt;code>新增筆記本&lt;/code>&lt;/li>
&lt;li>從 &lt;code>編輯&lt;/code> 中選擇 &lt;code>筆記本設定&lt;/code>&lt;/li>
&lt;li>將 &lt;code>硬體加速器&lt;/code> 更改為 &lt;code>GPU&lt;/code>
&lt;img src="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_2.png"
width="627"
height="324"
srcset="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_2_hud7bbdf6a24e33b2b36528d9e25b016c8_23961_480x0_resize_box_3.png 480w, http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_2_hud7bbdf6a24e33b2b36528d9e25b016c8_23961_1024x0_resize_box_3.png 1024w"
loading="lazy"
alt="img_2.png"
class="gallery-image"
data-flex-grow="193"
data-flex-basis="464px"
>&lt;/li>
&lt;li>貼上並執行以下程式碼&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">!pip install diffusers==0.8.0 transformers
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ol start="6">
&lt;li>貼上並執行以下程式碼&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">from diffusers import StableDiffusionPipeline
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ol start="7">
&lt;li>貼上並執行以下程式碼&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">pipe = StableDiffusionPipeline.from_pretrained(&amp;#34;gsdf/Counterfeit-V2.5&amp;#34;)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">pipe.to(&amp;#34;cuda&amp;#34;)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ol start="8">
&lt;li>貼上並執行以下程式碼&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">prompt = &amp;#34;((masterpiece,best quality)),1girl, solo, animal ears, rabbit, barefoot, knees up, dress, sitting, rabbit ears, short sleeves, looking at viewer, grass, short hair, smile, white hair, puffy sleeves, outdoors, puffy short sleeves, bangs, on ground, full body, animal, white dress, sunlight, brown eyes, dappled sunlight, day, depth of field&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">n_prompt = &amp;#34;EasyNegative, extra fingers,fewer fingers&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">image = pipe(prompt, negative_prompt = n_prompt).images[0]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">image
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>這裡使用的 &lt;code>Prompt&lt;/code> 參考了 &lt;a class="link" href="https://huggingface.co/gsdf/Counterfeit-V2.5" target="_blank" rel="noopener"
>https://huggingface.co/gsdf/Counterfeit-V2.5&lt;/a> 的 &lt;code>Prompt&lt;/code>。&lt;/p>
&lt;h2 id="生成結果部分">生成結果（部分）
&lt;/h2>&lt;p>&lt;img src="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_1.png"
width="512"
height="512"
srcset="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_1_hu1ec19e515fd7538067cc14f2c3c8bddf_594392_480x0_resize_box_3.png 480w, http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_1_hu1ec19e515fd7538067cc14f2c3c8bddf_594392_1024x0_resize_box_3.png 1024w"
loading="lazy"
alt="img_1.png"
class="gallery-image"
data-flex-grow="100"
data-flex-basis="240px"
>&lt;/p>
&lt;p>&lt;img src="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_3.png"
width="512"
height="512"
srcset="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_3_hu67e673668e1b02812ead4fb15912ac36_533749_480x0_resize_box_3.png 480w, http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_3_hu67e673668e1b02812ead4fb15912ac36_533749_1024x0_resize_box_3.png 1024w"
loading="lazy"
alt="img_3.png"
class="gallery-image"
data-flex-grow="100"
data-flex-basis="240px"
>&lt;/p>
&lt;p>&lt;img src="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_4.png"
width="512"
height="512"
srcset="http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_4_hu2b826ec3ad4d7685d995efaa40aac0c5_597506_480x0_resize_box_3.png 480w, http://kenji.blog/p/aistablediffusion%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A4%E3%83%A9%E3%82%B9%E3%83%88%E7%94%BB%E5%83%8F%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_4_hu2b826ec3ad4d7685d995efaa40aac0c5_597506_1024x0_resize_box_3.png 1024w"
loading="lazy"
alt="img_4.png"
class="gallery-image"
data-flex-grow="100"
data-flex-basis="240px"
>&lt;/p>
&lt;h2 id="參考">參考
&lt;/h2>&lt;ul>
&lt;li>&lt;a class="link" href="https://huggingface.co/gsdf/Counterfeit-V2.5" target="_blank" rel="noopener"
>https://huggingface.co/gsdf/Counterfeit-V2.5&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://www.youtube.com/watch?v=l8-fVSM2PVQ" target="_blank" rel="noopener"
>花了15分鐘使用人工智慧（AI）製作了圖像生成程式【實況編程】&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>