Commit ·
95ea872
1
Parent(s): 62ee77b
Enable xformers
Browse files17 unmodified lines181920212223509 unmodified lines53353453553653753853917 unmodified linesfrom accelerate.logging import get_loggerfrom accelerate.utils import set_seedfrom diffusers import AutoencoderKL, DDPMScheduler, StableDiffusionPipeline, UNet2DConditionModelfrom diffusers.optimization import get_schedulerfrom huggingface_hub import HfFolder, Repository, whoamifrom PIL import Image509 unmodified linestext_encoder = CLIPTextModel.from_pretrained(args.pretrained_model_name_or_path, subfolder="text_encoder")vae = AutoencoderKL.from_pretrained(args.pretrained_model_name_or_path, subfolder="vae")unet = UNet2DConditionModel.from_pretrained(args.pretrained_model_name_or_path, subfolder="unet")vae.requires_grad_(False)if not args.train_text_encoder:text_encoder.requires_grad_(False)17 unmodified lines18192021222324509 unmodified lines53453553653753853954054154254354454554654717 unmodified linesfrom accelerate.logging import get_loggerfrom accelerate.utils import set_seedfrom diffusers import AutoencoderKL, DDPMScheduler, StableDiffusionPipeline, UNet2DConditionModelfrom diffusers.utils.import_utils import is_xformers_availablefrom diffusers.optimization import get_schedulerfrom huggingface_hub import HfFolder, Repository, whoamifrom PIL import Image509 unmodified linestext_encoder = CLIPTextModel.from_pretrained(args.pretrained_model_name_or_path, subfolder="text_encoder")vae = AutoencoderKL.from_pretrained(args.pretrained_model_name_or_path, subfolder="vae")unet = UNet2DConditionModel.from_pretrained(args.pretrained_model_name_or_path, subfolder="unet")if is_xformers_available():try:print("Enabling memory efficient attention with xformers...")unet.enable_xformers_memory_efficient_attention()except Exception as e:logger.warning(f"Could not enable memory efficient attention. Make sure xformers is installed correctly and a GPU is available: {e}")vae.requires_grad_(False)if not args.train_text_encoder:text_encoder.requires_grad_(False)
train_dreambooth.py+9-1