見出し画像

Stable DiffusionでQRコードの作り方解説(その1)

今、AIイラストレーターやAI Art界隈で人気の、Stable Diffusionを使ってのQRコードの作り方を出来る限り解説します。
解説動画は2部構成です。1つ目は大まかなやり方解説。

恐らく現時点でこれを日本語で解説しているのは私くらい(こんな面倒な事をやる人がいないw)だと思います。
では、始めます😚

QRコード解説動画のまとめ(1つ目)

QRコードの建築画像
私が3日かかって作ったQRコード家
ちゃんと読めます!!
  1. QRコードをimg2imgに入れる

  2. Denoising Strength = 1

  3. QRコードをコントロールネットに入れる

  4. コントロールネット、プリプロセッサーTile resample選択 tile_resample

  5. コントロールネットモデル: Tile選択 control_v11f1e_sd15_tile

6 Control Weight : 0.9 Prompt: A photo-realistic rendering of a 2 story house with greenery, pool, (Botanical:1.5), (Photorealistic:1.3), (Highly detailed:1.2), (Natural light:1.2), art inspired by Architectural Digest, Vogue Living, and Elle Decor, <lora:epiNoiseoffset_v2:1> Negative prompt: bad_pictures, (bad_prompt_version2:0.8), EasyNegative, 3d, cartoon, anime, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 2443712455, Size: 768x768, Model hash: 4199bcdd14, Model: revAnimated_v122, Denoising strength: 1, Clip skip: 2, ENSD: 31341, Token merging ratio: 0.6, ControlNet 2: "preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 0.9, starting/ending: (0, 1), resize mode: Crop and Resize, pixel perfect: True, control mode: ControlNet is more important, preprocessor params: (512, 1, 0)", Lora hashes: "epiNoiseoffset_v2: d1131f7207d6", Score: 5.04, Version: v1.3.2

Lora: Epi Noise Offset
https://civitai.com/models/13941?modelVersionId=16576

Model: ReV Animated

Discord内のまとめ

QRコード解説動画2つ目

QRコード美女
QRコード美女
私が作ったQRコード美女(ジョジョのスタンド攻撃食らったような?)
  1. より適切に動作/スキャンできる画像を取得するには、いくつかの生成実験が必要な場合があります。

  2. 丸いものよりも大きな四角が3つあるものでQRを取得するのが良い。

  3. URLは長すぎないように

  4. 補正率30%のQRはもう少し良い。

Prompt: 1girl, bare_shoulders, blue_eyes, blurry, blurry_background, blurry_foreground, breasts, cleavage, couch, depth_of_field, earrings, indoors, jewelry, lace, lace_trim, long_hair, looking_at_viewer, medium_breasts, mole, mole_onbreast, photo(medium), pillow, pink_hair, plant, potted_plant, realistic, sitting, smile, solo, (Masterpiece:1.1), detailed, intricate,

Negative Prompt: (worst quality, low quality:1.3) badhandv4, extra fingers, extra arms, fewer fingers,(low quality, worst quality:1.4), (bad anatomy), (inaccurate limb:1.2), bad composition, inaccurate eyes, fewer digits,(extra arms:1.2), easynegative, (bad fingers), deformed hands, merged fingers, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((grayscale)), skin spot s, acnes, skin blemishes, bad anatomy Steps: 60, Sampler: Euler a, CFG scale: 7, Seed: 778751666, Size: 1024x1024, Model hash: 33c9f6dfcb, Denoising strength: 1, ControlNet: "preprocessor: inpaint_global_harmonious, model: control_v11f1e_sd15_tile [a371b31b], weight: 0.5,starting/ending: (0, 1), resize mode: Resize and Fill, pixel perfect: False, control mode: Balanced, preprocessor params: (-1, -1, -1)", Version: v1.3.1

Model: majicMix Realistic

Discord内のまとめ

QRコード解説動画3つ目


QR四天王(?)
  1. Img2imgを使った

  2. 画像サイズ 768x768

  3. Denoising strength = 1

  4. コントロールネット、プリプロセッサー tile_resample: weight: 0.9

  5. コントロールネット:starting/ending: (0.23, 1)

Prompt: futobot, cyborg, ((masterpiece),(best quality),(ultra-detailed), (full body:1.2), 1male, solo, hood up, upper body, mask, 1boy, male focus, black gloves, cloak, long sleeves, <lora:Futuristicbot4:0.8>

Negative prompt: paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glans, nsfw, nipples, (((necklace))), (worst quality, low quality:1.2), watermark, username, signature, text, multiple breasts, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, single color, ((((ugly)))), (((duplicate))), ((morbid)), ((mutilated)), (((tranny))), (((trans))), (((trannsexual))), (hermaphrodite), extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), (((disfigured))), (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), (missing legs), (((extra arms))), (((extra legs))), mutated hands,(fused fingers), (too many fingers), (((long neck))), (bad body perspect:1.1) Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 6.5, Seed: 2178484502, Size: 768x768, Model hash: 4199bcdd14, Model: revAnimated_v122 Denoising strength: 1, Clip skip: 2, Token merging ratio: 0.6, ControlNet 0: "preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b],weight: 0.9, starting/ending: (0.23, 1), resize mode: Crop and Resize, pixel perfect: True, control mode: Balanced, preprocessor params: (64, 1, 64)", Lora hashes: "Futuristicbot4: 407714e7b6ee", Version: v1.3.2, Score: 6.0316

数時間かけて試した結果、この方法でうまくいくと思います: まず、どちらが先に実行されるかを決める必要があります。
コントロールネットか、ステーブルディフュージョンか。 Starting Control Stepボタンが鍵になります。
もしこれが0より大きければ、Diffusionプロセスが最初に実行されます。

数ステップ経過すると(startingパラメータに依存)、コントロールネットが制御を開始し、コントロールネットの入力画像に 基づいて生成するようにディフュージョン処理を誘導します。

なので、鮮明で読みやすいQRを作成したいのであれば、Starting Control Stepボタンを低く設定する必要があります。
また、美しい画像を作りたい場合は、たくさん生成して、実用的な画像を見つけなければならないので、0.28から0.3程度と高めに設定します。

コントロールネットのガイダンスで重要なのは、Control Weight`ボタンです。 これは、あなたの画像がコントロールネットの入力画像とどの程度似ているかを示すものです。 高ければ高いほど、よく似ていることになります。低いほど、よりクリエイティブで、コントロールが難しくなります。

Lora: https://civitai.com/models/60832?modelVersionId=65319

Model: Rev Animated


私がハマった点

Img2imgのDenoising:1だと ほぼQRコードのみしか出てこない。 Denoising:0.5~0.6位まで下げる必要アリ。

実際のStable Diffusion画面
Denoisingによる変化1
Denoisingによる変化2

Rコードの生成にはこのサイト2つがオススメ というのも右のError Correction LevelというのをHに設定すると、ある程度劣化しても読み取り耐性のあるQRコードが作れるからです。
https://dnschecker.org/qr-code-generator.php

こっちは短縮URLが使えるから、長いURLなんか入れる時にQRのブロックが小さくならない(入力文字が長いほどブロックは小さくなる)

あと、私の場合、Control Net Tileを使う際にどうも挙動がおかしいなと思ったら、コマンドプロンプトにcontrol_v11u_sd15_tile.yaml を入れて下さいというエラーが出てたのを見逃していたこともミスの一つでした。 ここのリンク先一番下にcontrol_v11u_sd15_tile.yaml あるので、stable-diffusion-webui\extensions\sd-webui-controlnet\models に入れる。


未公開作品

私の未公開QR作品1
私の未公開QR作品2

また次の機会に完全版のまとめ書きます😚アディオス!

この記事が気に入ったらサポートをしてみませんか?