**SD-28 tex2img & img2img & inpaint 基本操作(九典)**

**推薦教學影片**
【生成式AI導論 2024】台大李宏毅教授線上課程
https://www.youtube.com/watch?v=AVIKFXLCPY8&list=PLJV_el3uVTsPz6CTopeRp2L2t4aL_KgiI&index=2
【生成式AI導論 2024】第15講:為什麼語言模型用文字接龍,圖片生成不用像素接龍呢?— 淺談生成式人工智慧的生成策略
【生成式AI導論 2024】第17講:
有關影像的生成式AI (上) — AI 如何產生圖片和影片 (Sora 背後可能用的原理)
【生成式AI導論 2024】第18講:
有關影像的生成式AI (下) — 快速導讀經典影像生成方法 (VAE, Flow, Diffusion, GAN) 以及與生成的影片互動
**WebUI 操作介面**

**文生圖(tex2img)範例練習一**
最基本的提示詞
Prompt:masterpiece,best quality,outdoors,sunset,modern single house,landscape,tree,(nature background:1.5),4K uhd
Negative Prompt:noisy,ugly,low quality,deform,blurry,night,
每一次Generate(產生)都是隨機 所以都有不同的畫面組合

(512x512)

Seed固定 嘗試不同畫布尺寸(以512為基準 64*8=512,64*12=768)
(768x512)

(768x768)

提示詞繼續加入
RAW photo,subject,dslr,soft lighting,high quality,film grain,Fujiflm XT3,
(RAW 照片、主體、8k 超高清、數位單眼相機、柔和的燈光、高品質、底片顆粒、Fujiflm XT3、)

換成這段文字:
photography, dynamic view, minimalist design, Canon EOS 5D Mark IV, EF 24mm f/1. 4L II USM lens, set f/2. 8, depth of field that highlights architectural photography,
(攝影、動態取景、簡約設計、Canon EOS 5D Mark IV、EF 24mm f/1。 4L II USM 鏡頭,設定 f/2。突顯建築攝影的景深,)

**提示詞範例練習**

1. Prompt:Modern luxury apartment in Taipei, glass and metal facade, highlights urban exquisite charm, rainy and humid weather, outdoor,
(一座位於台北市的現代豪華公寓大樓,以都會風格為主,提供高檔設施和便利的生活方式,突顯都市生活的精緻魅力。)
Negative Prompt:Rural landscapes, traditional homes, snow
(鄉村風景、傳統住宅、雪)
1. Prompt:Seaside villa in Taitung, wood and glass facade, comfortable seaside living, warm and humid climate, outdoor,
(一座位於台東縣的海濱度假別墅,結合了現代設計與海洋元素,營造出寧靜與放鬆的度假氛圍,提供舒適的海濱生活體驗。)
Negative Prompt:Urban pollution, desert landscapes, heavy snow
(城市污染、沙漠景觀、大雪)
**不同Checkpoint model有不同的風格生成**

Model:ArchitectureRealMix_v1


Model:realistic_v10BAKEDVAE

**加入Lora model 讓效果更突出**

Model:ArchitectureRealMix_v1
加入Lora:<lora:AIDVN_GreenCondominium:0.5>

加入Lora:<lora:0512sketch05:0.6>,
及觸發詞:sketch

加入Lora:<lora:XSArchi_127:0.55>,

若對生成的圖片滿意 可以立刻將此圖進行放大演算

圖片即馬上放大二倍 並進行更多細節的補充

使用第二個提示詞(台東縣的海濱度假別墅)

Sampling steps參數提高(取樣步驟) 圖面會生成更多細節

**要使用底圖(不管3D或手繪)建議先進行圖面尺寸調整**
原圖大小 (1924*1167) Resize 為 (1024*621)

**圖生圖(img2img)範例練習一**
進行圖生圖(img2img)-使用的底圖可以是手繪稿,照片,3D model圖等
Denoising strength (重繪幅度的參數調整 會影響與底圖的差異性 參數0~1 參數越小差異性越小 0.7是一個臨界值)
Prompt:Eco-friendly mountain villa in Hualien, wood and stone facade, harmonious living with nature, mild and rainy weather
(花蓮環保山莊,木石立面,與自然和諧相處,氣候溫和多雨)
Negative Prompt:Urban elements, pollution, heavy machinery
(城市元素、污染、重型機械)
Model: realistic_v10BAKEDVAE


**手繪底圖一(683*512)**

CFG Scale:5(提示詞相關性)
Denoising strength:0.6(重繪幅度)

CFG Scale:5.5(提示詞相關性)
Denoising strength:0.62(重繪幅度)

**Lora modle是一種微調模型 會增加某種特殊風格或效果**
**加入Lora**:<lora:0512sketch05:0.6>,
及觸發詞:sketch,building


**手繪底圖二(683*512)**

只換底圖 其餘所有提示詞及參數都不變

**修改圖面寬度 及高度**
記得調整縮放模式(Resize Mode) 修改圖面比例
共有四種可調整的選項:Just resize, Crop and resize, Resize and fill, Just resize(latent upscale)
若要增加建築物之外的空間 且保持建築比例不變 Resize and fill

將圖面resize成(1024*678) 會有

**inpaint 局部重繪**
在數次跌代後 選一張滿意的圖片 再放入img2img的inpaint進行建築以外的環境局部重繪
**開啟 Soft inpainting**
Soft inpainting 會將臨界面區域柔化


**針對天空進行局部重繪**
提示詞只要寫:sunset


**啟用ControlNet**
Model: ArchitectureRealMix_v1
**Control Type選用:Scribble**



**更改大模型 其他參數不變**
Model: realistic_v10BAKEDVAE, VAE hash: 235745af8d


**Control Type選用:Depth**



**加入Lora**:<lora:0512sketch05:0.6>,
及觸發詞:sketch,building

**運算生成景觀平面&景觀意象圖**
最好使用大一點畫布尺寸,關鍵字一定要打park plane,plan, plan drawing, 否則不出平面出透視。
景觀運算時 經常會遇到尺度不對的問題 要注意使用的Lora
效果強化prompt: landscape master plan (可以整出偏真實的效果)CN控制:推薦LINEART, Control Mode: ControlNet is more important
Model: landscapesupermix_v2
**手繪底圖二(1024*840)**



Prompt:(masterplan:1.5),landscape master plan,five cube building volumes plan,beautiful landscape,grass and trees,high detailed,
**加入lora及觸發詞**
:lora:AARG_plan_V1.0:0.6,aargsitemap,
Negative Prompt:noisy,blurry,deformed,ugly,16-token-negative-deliberate-neg,EasyNegative,realisticvision-negative-embedding,



**手繪底圖三(1024*840)**
1

2

3

4

5
Model: v1-5-pruned-emaonly
Prompt:landscape plan,(masterpiece),(high quality),five cube building volumes plan,best quality,super detailed,(full detail),(4k),8k,no humans,tree,white background,plant,<lora:AARG_plan_V1.0:0.5>,aargsitemap,
Negative Prompt:text,watermark,paintings,sketches,low res,(normal quality),(worst quality),(low quality),cropped,error,night,

6
