赞
踩
train_text_to_image.py
代码:
- accelerator = Accelerator()->
-
- noise_sheduler = DDPMScheduler.from_pretrained(,"scheduler")->
- tokenizer = CLIPTokenizer.from_pretrained(,"tokenizer")->
- text_encoder = CLIPTokenizer.form_pretrained(,"text_encoder")->
- vae = AutoencoderKL.from_pretrained(,"vae")->
- unet = UNet2DConditionModel(,'unet')->
-
- vae.requires_grad_(False)->
- text_encoder.requires_grad_(False)->
-
- unet.enable_gradient_checkpoint()->
- optimizer_cls = torch.optim.AdamW->
- optimizer = optimizer_cls(unet.parameters(),lr,betas,weight_decay,eps)->
-
- dataset = load_dataset(dataset_name,dataset_config_name,cache_dir)->
- train_transforms = transforms.Compose([])->
- train_dataset = dataset['train'].with_transformer(preprocess_train)->
- - images = [image.convert("RGB") for image in examples[image_c
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。