Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Google Colaboratory でStable Diffusionの実装 / Impl...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
tasotaku
October 29, 2022
Programming
0
430
Google Colaboratory でStable Diffusionの実装 / Implementation of Stable Diffusion at Google Colaboratory
Google Colaboratory でStable Diffusionを実装しました。少し遊んでみたのと、構造も少し調べました。
tasotaku
October 29, 2022
Tweet
Share
More Decks by tasotaku
See All by tasotaku
duel_masters_RAG
tasotaku
0
72
DQNによるポーカーの強化学習/Reinforcement Learning in Poker with DQN
tasotaku
0
820
オセロCPU/Othello CPU
tasotaku
0
170
オセロAI / OthelloAI
tasotaku
0
190
私、ChatGPTがChatGPTを解説するよ! / ChatGPT explains ChatGPT
tasotaku
0
490
機械学習入門
tasotaku
0
450
AIが作る予想外な画像を考える / Consider the unexpected images that AI creates
tasotaku
0
340
Other Decks in Programming
See All in Programming
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
0
220
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
550
JPUG勉強会 OSSデータベースの内部構造を理解しよう
oga5
2
230
2026/02/04 AIキャラクター人格の実装論 口 調の模倣から、コンテキスト制御による 『思想』と『行動』の創発へ
sr2mg4
0
680
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
440
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
210
2026年は Rust 置き換えが流行る! / 20260220-niigata-5min-tech
girigiribauer
0
220
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1k
The Ralph Wiggum Loop: First Principles of Autonomous Development
sembayui
0
3.7k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
390
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
200
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
160
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
280
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
340
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Ethics towards AI in product and experience design
skipperchong
2
210
Leo the Paperboy
mayatellez
4
1.5k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
280
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
240
How to train your dragon (web standard)
notwaldorf
97
6.5k
Transcript
Google Colaboratory で Stable Diffusionの実装 B2 tasotaku
もくじ ◼ Stable Diffusion とは ◼ Stable Diffusion の特徴 ◼
Diffusers ◼ Stable Diffusion の中身
Stable Diffusion とは ◼ Stable Diffusion とは、文章から画像を生成するAI ◼ Google Colaboratory
での実装方法はこちら ◼ できること ⚫ 文章から画像を生成 ⚫ 生成した画像を微調整する ⚫ 文章と画像から新たな画像を生成 ⚫ etc
Stable Diffusion の特徴 ◼ 解像度の高い画像を生成できる ◼ メモリや時間がかからない ⚫ ノートパソコンでも Google
Colaboratory で実行可能 ◼ 特定のジャンルに弱い ⚫ 学習に使ったデータセットに起因? ⚫ ファインチューニングすれば解決 ◼ 作成した画像はフリー画像
文章から画像を生成 a photograph of an astronaut riding a horse
画像と文章から画像を生成 Gold desk +
画像とマスク画像と文章から画像を生成 ◼ マスク画像を使うことで、部分的に調整が可能 robot
ファインチューニング ◼ 特定の画像で訓練することで、苦手な分野に対応する ファインチューニング前 ファインチューニング後
Diffusers ◼ Diffusers とは、段階的にノイズ除去するように訓練された機械学習システム ◼ Stable Diffusion はこれをベースに作られている 引用: https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/diffusers_intro.ipynb
Stable Diffusion の中身 ◼ Latents ◼ A text-encoder ◼ A
U-Net ◼ Scheduler ◼ An autoencoder (VAE) 引用: https://huggingface.co/blog/stable_diffusion
Stable Diffusion の中身 ◼ Latents ◼ A text-encoder ◼ A
U-Net ◼ Scheduler ◼ An autoencoder (VAE) 引用: https://huggingface.co/blog/stable_diffusion
Latents ◼ seed値をもとにノイズ画像を作る ◼ その画像を U-Net が扱えるように、 画素行列(latents)に変換 ◼ 出力する画像は
512 × 512 なのに対して、 latents はより低次元である ◼ こうすることで、メモリと計算量を軽減している 引用: https://huggingface.co/blog/stable_diffusion
text-encoder ◼ 文章をU-Netが理解できるかたちに変換する ◼ 機械翻訳ではないので、文法はあまり見ない ⚫単語(キーワード)を複数与えるだけでも機能する 引用: https://huggingface.co/blog/stable_diffusion
U-Net と Scheduler ◼ U-Net を用いて、文章をもとにノイズ画像を ノイズの少ない画像にする ◼ Scheduler で二つの画像のノイズの差を
計算してフィードバック ◼ これを繰り返して画像(のlatents) を生成する ◼ U-Net は ResNet からなるエンコーダーと デコーダーをもつ ◼ Scheduler は複数種類があり、選ぶことができる 引用: https://huggingface.co/blog/stable_diffusion
autoencoder (VAE) ◼ U-Net で生成した latents を、画像に 復号(decode)して画像を出力する ◼ VAE
はエンコーダー(encoder)と デコーダー(decoder)の二つの部分からなる ◼ 画像生成ではデコーダーしか使わないが、 訓練する時にエンコーダーも使う 引用: https://huggingface.co/blog/stable_diffusion
学習 ◼ 元の画像にノイズをかける ◼ 文章を加えてノイズを取り除く ◼ 出力と元の画像、文章から損失を計算する 文章 比較
最後に ◼ 扱いやすさを重視したお絵描きAI ◼ フリー画像の新たな選択肢 ◼ すでに Stable Diffusion を利用したアプリなどが登場している
◼ Diffusers は用途が多く、音声や動画バージョンも作成予定らしい
参考 ◼ https://github.com/huggingface/diffusers ◼ https://colab.research.google.com/github/huggingface/noteb ooks/blob/main/diffusers/stable_diffusion.ipynb