Supershipの名畑です。16bitセンセーション ANOTHER LAYERとか、少し前だとハイスコアガールとか、懐古できる系の作品は琴線を刺激する。
はじめに
以前「Stable Diffusionの最新モデル「SDXL 1.0」と過去モデルの生成画像をひたすら比較して進化を実感してみた」という記事を書きました。Stable Diffusionの新モデルStable Diffusion XLの1.0がリリースされたので、過去バージョンとの生成画像を比べていくというものでした。
今回の記事では、超話題になっているOpenAIのDALL·E 3でも同じように画像を生成し、それをStable Diffusion XLでの生成画像と比較してみます。
現在のDALL·E 3はChatGPT経由で利用できます。会話形式のため、たとえば、生成した画像を元にしてさらに画像を再生成するなど、単体での画像生成にとどまらないかなり柔軟性ある使い方が可能です。プロンプトの生成をしてくれるという特徴もあります。
また、Stable Diffusionでは、再学習したモデルを使われる方が多いかとは思います。入手するサイトとしてはHugging FaceやCivitaiなどが有名でしょうか。
そういった特徴を考慮せず、今回の記事では「デフォルトで生成した画像を比較する」ということをしているため、かなり限定的な条件下とはなります。ご注意ください。
また、Stable Diffusion XLでの生成は先述の過去記事の結果をそのまま流用しております。
別記事のままだと見づらいので一つの記事にまとめました。
Stable Diffusion XL 1.0での画像生成方法
Stable Diffusion XL 1.0での画像生成は以下のコードでWeb APIを叩いた上で、生成された画像を512x512にリサイズしています。リサイズしているのは記事掲載時の容量削減のためです。
style_presetにスタイルを書き、text_promptsにプロンプト(指示)を書いています。今回の記事ではこの2つのみをいじって画像を変えています。
import base64
import os
import requests
import time
engine_id = "stable-diffusion-xl-1024-v1-0" # SDXL 1.0
api_host = os.getenv('API_HOST', 'https://api.stability.ai')
api_key = os.getenv("STABILITY_API_KEY")
# API Keyの取得確認
if api_key is None:
raise Exception("Missing Stability API key.")
# API呼び出し
response = requests.post(
f"{api_host}/v1/generation/{engine_id}/text-to-image",
headers={
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {api_key}"
},
json={
"Samples": 3,
"style_preset": "anime",
"text_prompts": [
{
"text": "Japanese moe heroine"
}
],
},
)
# レスポンス確認
if response.status_code != 200:
raise Exception("Non-200 response: " + str(response.text))
# レスポンス取得
data = response.json()
# 画像保存
# ファイル名にはタイムスタンプとengine_id、通番を含めています
# 通番は0〜samplesの値 - 1
for i, image in enumerate(data["artifacts"]):
with open(f"./{engine_id}_{int(time.time())}_{i}.png", "wb") as f:
f.write(base64.b64decode(image["base64"]))
DALL·E 3での画像生成方法
ChatGPT上でプロンプトとして下記のように1行目に描いてほしいもの、2行目にスタイル、3行目には3枚の画像という指示を出します。こちらも512x512にリサイズします。
Japanese moe heroine
Anime style
3 images
以下の結果においては共通である3 imagesの部分は省きます。
結果
ここからが結果です。
8種類のプロンプトで画像を生成しました。
Stable Diffusion XL 1.0とDALL·E 3の生成結果が3枚ずつ交互に並びます。
日本の萌えヒロイン
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "anime",
"text_prompts": [
{
"text": "Japanese moe heroine"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
Japanese moe heroine
Anime style
DALL·E 3の生成画像
日本の人気アニメに登場するスイーツ
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "anime",
"text_prompts": [
{
"text": "Sweets that appear in popular Japanese anime"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
Sweets that appear in popular Japanese anime
Anime style
DALL·E 3の生成画像
修学旅行中の男子高校生
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "anime",
"text_prompts": [
{
"text": "Male high school student on a school trip"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
Male high school student on a school trip
Anime style
DALL·E 3の生成画像
ギターを演奏するお姫様
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "fantasy-art",
"text_prompts": [
{
"text": "A princess playing guitar"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
A princess playing guitar
Fantasy-art style
DALL·E 3の生成画像
ノートパソコン上の可愛い妖精
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "photographic",
"text_prompts": [
{
"text": "A cute fairy on top of a white laptop"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
A cute fairy on top of a white laptop
Photographic style
DALL·E 3の生成画像
黒いボブヘアで可愛い28歳の日本人女性
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "photographic",
"text_prompts": [
{
"text": "28-year-old Japanese pretty woman with black bobbed hair"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
28-year-old Japanese pretty woman with black bobbed hair
Photographic style
DALL·E 3の生成画像
1980年代の香港の繁華街
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "photographic",
"text_prompts": [
{
"text": "Hong Kong downtown in the 1980s"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
Hong Kong downtown in the 1980s
Photographic style
DALL·E 3の生成画像
2020年の新宿歌舞伎町
Stable Diffusion XL 1.0のスタイルとプロンプト
"style_preset": "photographic",
"text_prompts": [
{
"text": "Shinjuku Kabukicho in 2020"
}
],
Stable Diffusion XL 1.0の生成画像



DALL·E 3のプロンプト
Shinjuku Kabukicho in 2020
Photographic style
DALL·E 3での生成画像
最後に
かなり定性的なもののため良し悪しについては語りづらいのですが、DALL·E 3の方がプロンプトで指示した特徴がより色濃く出るようになっているような気もします。
人体や文字の描画といった部分に課題があることはどちらも変わらずという印象です。
冒頭で書いた通り、かなり限定的な条件下での比較となりますが、この限定的な条件下が多くの方にとってのデフォルトになっていくのかもしれないとも思っています。
宣伝
SupershipのQiita Organizationを合わせてご覧いただけますと嬉しいです。他のメンバーの記事も多数あります。
Supershipではプロダクト開発やサービス開発に関わる方を絶賛募集しております。
興味がある方はSupership株式会社 採用サイトよりご確認ください。