Stable Diffusion (Diffusers) / DiffusersでVAE,Lora,textual_inversion,を使用する

VAE

from diffusers.models import AutoencoderKL

#vae = "stabilityai/sd-vae-ft-ema"#@param {type:"string"}
#
vae = "/content/model/vae-ft-mse-840000-ema-pruned.safetensors"#@param {type:"string"}

vae = AutoencoderKL.from_single_file(vae)
pipe = StableDiffusionPipeline.from_single_file(model_id,
                                                      vae=vae)
 

Lora


lora_model_id = "/content/model/JapaneseDollLikeness_v15.safetensors"#@param {type:"string"}
lora_weight_name = "JapaneseDollLikeness_v15.safetensors"#@param {type:"string"}
#lora_model_id = "/content/model/flat2.safetensor"#@param {type:"string"}
#lora_weight_name = "flat2.safetensors"#@param {type:"string"}

pipe.load_lora_weights(lora_model_id, weight_name=lora_weight_name)

textual_inversion

ネガティブプロンプトなどにEasyNegativeのようなワードを入れるだけで画像の質が上がります


#
textual_inversion = "embed/EasyNegative"#@param {type:"string"}
#
token = "EasyNegative"#@param {type:"string"}
#
embed_weight_name = "EasyNegative.safetensors"#@param {type:"string"}
#textual_inversion = "/content/model/negative_hand-neg.pt"#@param {type:"string"}
#token = "negative_hand-neg"#@param {type:"string"}
#embed_weight_name = "negative_hand-neg.pt"#@param {type:"string"}

if embed_weight_name != "":
    pipe.load_textual_inversion(textual_inversion, weight_name=embed_weight_name,token=token)
else:
    pipe.load_textual_inversion(textual_inversion, token=token)
#

stable-diffusion

Posted by eightban