ACG LoRA的寫實風運用 - Stable Diffusion

2023/05/23閱讀時間約 21 分鐘
*本篇心得Automatic1111和Vlad Diffusion介面均適用。

ACG LoRA的寫實風難題

  用ACG圖片訓練出來的LoRA models,時有難以使用寫實風checkpoints models繪製出滿意成果的情況。
  之前我會嘗試先用ACG風格的checkpoint運算text2Image,再使用寫實風的checkpoint運算image2image,不過結果往往不盡人意。
  但ControlNet推出tile resample後,上述方式已成為能有效運用的方法了。
  以下所有算圖成果的-Prompts均如下:
bad-hands-5, ng_deepnegative_v1_75t, (low quality, worst quality:1.4), (monochrome:1.1), (greyscale), watermark, text, blurry, jpeg artifacts, cropped, normal quality, signature, username, artist name, cartoon, canvas frame, lowres, (disfigured), (bad art), (deformed), (extra limbs), (b&w), weird colors, (duplicate), (morbid), (mutilated), mutated hands, (poorly drawn hands), (poorly drawn face), (mutation), (ugly),  (bad proportions), cloned face, out of frame, gross proportions, (malformed limbs), (missing arms), (missing legs), (extra arms), (extra legs), fused fingers, (long neck), lowres, (grayscale), (skin spots), acnes, skin blemishes, (age spot),
*bad-hands-5 Textual Inversion由此下載
*ng_deepnegative_v1_75 Textual Inversion由此下載
  使用的checkpoint models有二:
寫實風:FantasticMix
ACG風:SweetMix
*請注意!本篇心得無18禁內容,但連結連往的CIVITAI網頁會有。
  使用的upscale演算法(放大演算法,會在HiresFix、Tiled Diffusion用到):4x_NMKD-Superscale-SP_178000_G
  
下載該網頁的「4x_NMKD-Superscale-SP_178000_G.pth」檔案後,請放到models\ESRGAN資料夾內。
演算法的作者網頁:https://nmkd.de/?esrgan

約兒

  說真的,約兒的LoRA能直接用在寫實風checkpoint model上,例如下圖:
直接用FanstasticMix + Hires.fix的成果
+
ultra realistic 8k cg, masterpiece, ((ultra detailed background, delicate pattern, intricate detail)), (highly detailed, fine details), best quality, 1girl, (photorealistic:1.4),beautiful lighting,  absurdres, yor briar, 1girl, backlighting, bare shoulders, black background, black dress, black gloves, black hair, blood, blood on face, blood on weapon, breasts, closed mouth, cowboy shot, dress, earrings, expressionless, fingerless gloves, floating hair, floral print, flower, gloves, gold earrings, gold hairband, hair flower, hair ornament, hairband, holding, holding weapon, jewelry, large breasts, light particles, long hair, looking at viewer, off-shoulder dress, off shoulder, petals, red eyes, rose, rose petals, rose print, short hair with long locks, sidelocks, solo, spikes, thighs, two-sided dress, two-sided fabric, weapon, RAW photo, film grain, <lora:yor:1>,
Steps:30
Sampler: Euler a
CFG scale: 7
Seed: 2855893784
Size: 512x768
Model: fantasticmix_v40
Denoising strength: 0.4
Clip skip: 2
Hires.fix upscale: 2
Hires.fix upscaler: 4x_NMKD-Superscale-SP_178000_G
  嗯,成果不錯,但接著來試試看完全一樣的設定,不過先使用SweetMix checkpoint model運算:
直接用SweetMix + Hires.fix的成果
  誠心地說,我更喜歡SweetMix算出來的神韻風采。那麼,下一步即是使用ControlNet的tile resample功能搭配FantasticMix來轉換為寫實風格了。依然是和上面完全一樣的設定,但搭配使用ControlNet的tile resample,成果如下:
把SweetMix算出來的圖當作tile resample的參考圖,使用FantasticMix算出來的成果
  我個人是更喜歡這個版本算出來的約兒(P.S. 因為與這次心得主題無關,手指問題我沒有花時間修復)。特別需要提出來的事項有三:
  1. 這完全是使用Text2Image的成果,沒有用到Image2Image(圖算圖);
  2. tile resample的Down Sampling Rate我設為8;
  3. 因為是Text2Image,所以tile resample需要加入SweetMix算出來的ACG版本當作參考圖。
  ACG checkpoint算出來的成果,角色的姿態往往更加多元動態,我覺得這可能是因為ACG角色往往有更誇張、更多元的動作,所以用ACG圖片訓練出來的checkpoint也就承襲了這樣的優點。

愛德(愛德華·愛力克)

  《鋼鍊》的愛德就很難搞了,沒辦法像SpyXFamily的約兒能直接用Text2Image一次搞定。直接讓大家看看用愛德LoRA + FantasticMix算出來的成果便能知道原因:
直接用FanstasticMix + Hires.fix的成果
+
ultra realistic 8k cg, masterpiece, ultra detailed background, delicate pattern, intricate detail, highly detailed, fine details, best quality, 1boy, flat chin, manly, (photorealistic:1.4), beautiful lighting,  absurdres, Edward Elric, backlighting, black background, ((black jacket)), ((white gloves)), yellow hair, grin, cowboy shot, ((red hoody)), ((red coat)), light particles, hair braid, looking at viewer, yellow eyes, solo, RAW photo, film grain, <lora:edwardElricFullmetal_v3:1>,
Steps: 30
Sampler: Euler a
CFG scale: 5
Seed: 3400642652
Size: 512x768
Model: fantasticmix_v40
Denoising strength: 0.4
Hires.Fix upscale: 2
Hires.Fix upscaler: 4x_NMKD-Superscale-SP_178000_G
  媽的、見鬼了,而且不知道為啥我覺得有點楊麗花(沒有不敬的意思),變成像是富有英氣的女角。我認為有這樣的結果,可能的原因有下列兩點:
  1. 熱衷於Stable Diffusion的男性阿宅數量遠遠超過女性阿宅,導致人物類checkpoint models的訓練非常偏重女性角色,尤其NSFW類的models更明顯。
  2. 愛德相較約兒更「卡通化」,也就是「更偏離現實的五官比例、形狀和臉型」,導致寫實風的checkpoint model「難以看懂」,無法妥當地轉換為寫實臉孔。
  ......總之先和約兒一樣如法炮製,保留所有設定但改用ACG風的SweetMix,不過這次我就先不用Hires.Fix了,因為根據經驗接下來轉寫實風的步驟失敗率會很高,不想先算大圖:
直接用SweetMix的成果
  嘛、不意外地很不錯,接著嘗試用這張搭配tile resample,成果如下:
把SweetMix算出來的圖當作tile resample的參考圖,使用FantasticMix算出來的成果
  ......是沒有那麼像歌仔戲的英俊小生了,但還是不太行,尤其眼睛實在太大。這時我就想了,乾脆來試試看ControlNet另一個新功能reference_only吧(仍保留相同設定,但seed改為隨機):
改用reference_only搭配FantasticMix的成果,seed 1661784639
  .......反而變得更糟了。這時我想說有沒有可能是因為已經用ACG風的原圖當參考了,還多重複了一次相同的正面提示詞所導致,便乾脆把正面提示詞全空白再試一次:
改用reference_only、正面提示詞留白,搭配FantasticMix的成果
  ........結果不只變得像ACG風(畢竟參考了原圖嘛)還性轉了(也似乎證實了我的「偏重女角」推測)。不得不說轉得還蠻可愛的,但這不是我想要的成果,所以我調整了正面提示詞再做嘗試:
是怎樣?正面提示詞中的「1boy」直接無視,硬要性轉就對了?雖然是真的很會畫女角啦......
+
ultra realistic 8k cg, masterpiece, ultra detailed background, delicate pattern, intricate detail, highly detailed, fine details, best quality, 1boy, flat chin, manly, (photorealistic:1.4), beautiful lighting,  absurdres,
正面提示詞只加回愛德的LoRA指令......還是不行
+
<lora:edwardElricFullmetal_v3:1>
  事實證明reference_only不是解答,還是得回到Tile Reample上,於是我回到使用原本的ACG風原圖為Tile Resample的參考圖搭配FantasticMix,但持續調整正面提示詞和使用隨機seed,終於獲得一個還能接受的成果:
左眼的顏色原本偏深灰,這是手動調整後的版本。
+
ultra realistic 8k cg, masterpiece, best quality, 1boy, flat chin, manly, (photorealistic:1.4), beautiful lighting,  absurdres, Edward Elric, <lora:edwardElricFullmetal_v3:1>, (cosplay), yellow eyes, red coat,
  接著我將上圖傳到Image2Image放大,除了負面提示詞都有略作調整,最後成果如下:
FantasticMix有點過度喜歡添加細節。
+
ultra realistic 8k cg, masterpiece, best quality, 1boy, (((flat chin))), (((wide chin))), (((manly face))), (((man's face))), (muscular face), (photorealistic:1.4), beautiful lighting,  absurdres, Edward Elric, <lora:edwardElricFullmetal_v3:0.1>, (cosplay), yellow eyes, red coat, RAW photo, film grain,  <lora:add_detail:-1>, thin lips,
_
bad-hands-5, ng_deepnegative_v1_75t, (low quality, worst quality:1.4), (monochrome:1.1), (greyscale), watermark, text, blurry, jpeg artifacts, cropped, normal quality, signature, username, artist name, cartoon, canvas frame, lowres, (disfigured), (bad art), (deformed), (extra limbs), (b&w), weird colors, (duplicate), (morbid), (mutilated), mutated hands, (poorly drawn hands), (poorly drawn face), (mutation), (ugly),  (bad proportions), cloned face, out of frame, gross proportions, (malformed limbs), (missing arms), (missing legs), (extra arms), (extra legs), fused fingers, (long neck), lowres, (grayscale), (skin spots), acnes, skin blemishes, (age spot), (((beard))), (((moustache))),
Steps: 30
Sampler: DPM++ 2S a Karras
CFG scale: 6
Seed: 2652740664
Size: 1024x1536
Model: fantasticmix_v40
Denoising strength: 0.5
Tiled Diffusion upscaler: 4x_NMKD-Superscale-SP_178000_G
Tiled Diffusion scale factor: 2
Tiled Diffusion: "{'Method': 'Mixture of Diffusers', 'Tile tile width': 128, 'Tile tile height': 128, 'Tile Overlap': 24, 'Tile batch size': 1, 'Upscaler': '4x_NMKD-Superscale-SP_178000_G', 'Upscale factor': 2, 'Keep input size': True}"
ControlNet: "preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 1, starting/ending: (0, 1), resize mode: Crop and Resize, pixel perfect: True, control mode: Balanced, preprocessor params: (64, 1, 64)"
  因為FantasticMix會過度增加細節,所以這裡我使用了調整細節的LoRA嘗試減少細節量,效果很不錯,不過沒法改掉衣服不必要的波浪邊緣。
下載LoRA Detail Tweaker(細節調整):https://civitai.com/models/58390/detail-tweaker-lora-lora
*此LoRA是少數可以使用負權重的LoRA,負=減少細節,正=增加細節,數值在-2~2之間,例如<lora:add_detail:-1>。
  另外,實際上嘴唇的部分有手動後製過,由以下正面提示詞算出來的圖取代:
+
ultra realistic 8k cg, masterpiece, best quality, 1boy, flat chin, manly, (photorealistic:1.4), beautiful lighting,  absurdres, Edward Elric, <lora:edwardElricFullmetal_v3:1>, (cosplay), yellow eyes, red coat,
  主要是愛德LoRA提示詞的權重:<lora:edwardElricFullmetal_v3:0.1>和<lora:edwardElricFullmetal_v3:1>的差別。
  總結來說,比約兒要多花很多功夫,且成果可能還沒有約兒的滿意(依然有點像女性),好的方面則是成功使用了愛德的LoRA達成寫實風的成果。
  ——算是及格啦!

補充資料

ControlNet的Tile Resample、reference_only,以及MultiDiffusion的Tiled Diffusion、Tiled VAE,請參考我的以下三篇心得:
另外,若想使用Vlad Diffusion webui介面,可參考我的這篇心得:
祝算圖愉快!
為什麼會看到廣告
78會員
104內容數
筆者探索AI工具時遇到的難題、解方和雜談,不定期更新。
留言0
查看全部
發表第一個留言支持創作者!