当前位置:   article > 正文

diffusers中sd的微调和lora微调_train_text_to_image_lora.py

train_text_to_image_lora.py

train_text_to_image.py

代码:

  1. accelerator = Accelerator()->
  2. noise_sheduler = DDPMScheduler.from_pretrained(,"scheduler")->
  3. tokenizer = CLIPTokenizer.from_pretrained(,"tokenizer")->
  4. text_encoder = CLIPTokenizer.form_pretrained(,"text_encoder")->
  5. vae = AutoencoderKL.from_pretrained(,"vae")->
  6. unet = UNet2DConditionModel(,'unet')->
  7. vae.requires_grad_(False)->
  8. text_encoder.requires_grad_(False)->
  9. unet.enable_gradient_checkpoint()->
  10. optimizer_cls = torch.optim.AdamW->
  11. optimizer = optimizer_cls(unet.parameters(),lr,betas,weight_decay,eps)->
  12. dataset = load_dataset(dataset_name,dataset_config_name,cache_dir)->
  13. train_transforms = transforms.Compose([])->
  14. train_dataset = dataset['train'].with_transformer(preprocess_train)->
  15. - images = [image.convert("RGB") for image in examples[image_c
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/514104
推荐阅读
相关标签
  

闽ICP备14008679号