SD-04 tex2img & img2img 基本操作

台大李弘毅教授Hung-yi Lee
【生成式AI時代下的機器學習(2025)】第一講:一堂課搞懂生成式人工智慧的技術突破與未來發展
https://www.youtube.com/watch?v=QLiKmca4kzI&t=893s
**Web UI的操作介面**

**更改模型路徑修改** (copy 電腦教室的.bat檔)

編輯修改webui-user.bat 檔案
**Lora的圖片如何顯示**
需安裝Civitai Helper執行Scan後 就會下載Lora圖片至檔案中

Lora下載可在資料夾中進行分類 依類別放置Lora檔案




**PNG Info圖片資訊**
將筆記中的圖片 拉入PNG Info(圖片資料)即可看到生成的所有參數設定
只要是用SD生成的圖片 都可以查看生成時所設定的參數

**tex2img(文生圖)&img2img(圖生圖)的基本操作**
Prompt: masterpiece,best quality,....
Negative Prompt: ugly,normal,....
1. Prompt: masterpiece,best quality,modern single house,façade design,window,outdoors,tree,landscape,,real world location,background,4K uhd,
1. Negative Prompt:noisy,ugly,low quality,deform,blurry,
1. Prompt:Modern luxury apartment in Taipei, glass and metal facade, highlights urban exquisite charm, rainy and humid weather, outdoor,
(一座位於台北市的現代豪華公寓大樓,以都會風格為主,提供高檔設施和便利的生活方式,突顯都市生活的精緻魅力。)
1. Negative Prompt:Rural landscapes, traditional homes, snow
(鄉村風景、傳統住宅、雪)
1. Prompt:Seaside villa in Taitung, wood and glass facade, comfortable seaside living, outdoor,building facade,
(一座位於台東縣的海濱度假別墅,結合了現代設計與海洋元素,營造出寧靜與放鬆的度假氛圍,提供舒適的海濱生活體驗。)
Negative Prompt:Urban pollution, desert landscapes, heavy snow
(城市污染、沙漠景觀、大雪)
1. Prompt: masterpiece , best quality, Office Building, outdoors, sky, day, tree, blue sky, ground vehicle, building, scenery, motor vehicle, walking, city, car, road, lamppost, street, real world location,background,4K uhd,
(傑作,最佳品質,((辦公大樓)),戶外,天空,白天,樹,藍天,地面車輛,建築,風景,摩托車,步行,城市,汽車,道路,燈柱,街道,真實世界位置,解析度)
1. (RAW photo,subject,8k uhd,dslr,soft lighting,high quality)
(RAW 照片、主體、8k 超高清、數位單眼相機、柔和的燈光、高品質)
1. photography, dynamic view, minimalist design, depth of field that highlights architectural photography,
(攝影、動態取景、簡約設計、突顯建築攝影的景深,)
**範例練習**
**手繪底圖一(1477*1108)**

**Resize imagine(512x384) or (1024x768)**

**Img2Img**

**立面底圖一**
以schroder house立面為底圖
底圖一(512x354)

底圖二(512x384)

AI生成1

AI生成2

AI生成3

加入Lora 手繪風格


AI生成4

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

1.Just resize

2.Crop and resize

3.Resize and fill

4.Just resize(latent upscale)

**加入Lora讓效果更突出**
Prompt:masterpiece,best quality,De Stijl,schroder house,modern single house,façade design,window,outdoors,tree,landscape,,real world location,background,4K uhd,
加入lora:landscapesupermix_v2:0.85



在數次跌代後 選一張滿意的圖片 再放入img2img的inpaint進行建築以外的環境局部重繪


**inpaint局部重繪**
Prompt:landscape,suburbs background,
加入lora:landscapesupermix_v2:0.85



選擇手繪風格為底圖 在局部重繪時 加入二個Lora 我會讓二個Lora的參數相加值不超過1 數值過大就會常出現過擬合的效果
<lora:landscapesupermix_v2:0.6>,<lora:CWG_archi_sketch_v1:0.4>




**練習示範**
在文生圖中輸入
prompt:masterpiece,best quality,modern building,road,landscape, office building,architectural photography,
Negative prompt: curve,lowres,normal quality,worst quality,cropped,blurry,

生成參數如下
Steps: 30, Sampler: Euler a, CFG scale: 7, Seed: 3889573801, Size: 768x512, Model hash: 6ce0161689, Model: v1-5-pruned-emaonly, Version: v1.8.0
**在圖生圖中 進行inpaint 局部重繪**

將前面道路部分塗起來 並寫入prompt如下
beautifully landscape,grass,flower,tree,
Denoising strength的參數值 0.1~1.0 將決定重繪幅度大小
0.7是一個臨界值

prompt:photography, dynamic view, minimalist building facade 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,