Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Google Colaboratory でStable Diffusionの実装 / Impl...

Avatar for tasotaku tasotaku
October 29, 2022

Google Colaboratory でStable Diffusionの実装 / Implementation of Stable Diffusion at Google Colaboratory

Google Colaboratory でStable Diffusionを実装しました。少し遊んでみたのと、構造も少し調べました。

Avatar for tasotaku

tasotaku

October 29, 2022
Tweet

More Decks by tasotaku

Other Decks in Programming

Transcript

  1. Stable Diffusion とは ◼ Stable Diffusion とは、文章から画像を生成するAI ◼ Google Colaboratory

    での実装方法はこちら ◼ できること ⚫ 文章から画像を生成 ⚫ 生成した画像を微調整する ⚫ 文章と画像から新たな画像を生成 ⚫ etc
  2. Stable Diffusion の特徴 ◼ 解像度の高い画像を生成できる ◼ メモリや時間がかからない ⚫ ノートパソコンでも Google

    Colaboratory で実行可能 ◼ 特定のジャンルに弱い ⚫ 学習に使ったデータセットに起因? ⚫ ファインチューニングすれば解決 ◼ 作成した画像はフリー画像
  3. Stable Diffusion の中身 ◼ Latents ◼ A text-encoder ◼ A

    U-Net ◼ Scheduler ◼ An autoencoder (VAE) 引用: https://huggingface.co/blog/stable_diffusion
  4. Stable Diffusion の中身 ◼ Latents ◼ A text-encoder ◼ A

    U-Net ◼ Scheduler ◼ An autoencoder (VAE) 引用: https://huggingface.co/blog/stable_diffusion
  5. Latents ◼ seed値をもとにノイズ画像を作る ◼ その画像を U-Net が扱えるように、 画素行列(latents)に変換 ◼ 出力する画像は

    512 × 512 なのに対して、 latents はより低次元である ◼ こうすることで、メモリと計算量を軽減している 引用: https://huggingface.co/blog/stable_diffusion
  6. U-Net と Scheduler ◼ U-Net を用いて、文章をもとにノイズ画像を ノイズの少ない画像にする ◼ Scheduler で二つの画像のノイズの差を

    計算してフィードバック ◼ これを繰り返して画像(のlatents) を生成する ◼ U-Net は ResNet からなるエンコーダーと デコーダーをもつ ◼ Scheduler は複数種類があり、選ぶことができる 引用: https://huggingface.co/blog/stable_diffusion
  7. autoencoder (VAE) ◼ U-Net で生成した latents を、画像に 復号(decode)して画像を出力する ◼ VAE

    はエンコーダー(encoder)と デコーダー(decoder)の二つの部分からなる ◼ 画像生成ではデコーダーしか使わないが、 訓練する時にエンコーダーも使う 引用: https://huggingface.co/blog/stable_diffusion