Spaces:
Build error
Build error
Commit ·
586de43
1
Parent(s): ea0bceb
update
Browse files64 unmodified lines656667686869707111 unmodified lines838485868687888989909192247 unmodified lines3403413423433433443453463453463473483495 unmodified lines3553563573583583593603611 unmodified line36336436536636636736836964 unmodified lines#### import diffusion modelstext_encoder = CLIPTextModel.from_pretrained( 'JingyeChen22/textdiffuser2-full-ft', subfolder="text_encoder", ignore_mismatched_sizes=True).cuda()).half().cuda()tokenizer = CLIPTokenizer.from_pretrained( 'runwayml/stable-diffusion-v1-5', subfolder="tokenizer")11 unmodified linesprint(len(tokenizer))print('***************')
vae = AutoencoderKL.from_pretrained('runwayml/stable-diffusion-v1-5', subfolder="vae").cuda()vae = AutoencoderKL.from_pretrained('runwayml/stable-diffusion-v1-5', subfolder="vae").half().cuda()unet = UNet2DConditionModel.from_pretrained( 'JingyeChen22/textdiffuser2-full-ft', subfolder="unet").cuda()).half().cuda()text_encoder.resize_token_embeddings(len(tokenizer))
247 unmodified lines scheduler = DDPMScheduler.from_pretrained('runwayml/stable-diffusion-v1-5', subfolder="scheduler") scheduler.set_timesteps(slider_step) noise = torch.randn((slider_batch, 4, 64, 64)).to("cuda") input = noise input = noise.half()
encoder_hidden_states_cond = text_encoder(prompts_cond)[0] encoder_hidden_states_nocond = text_encoder(prompts_nocond)[0] encoder_hidden_states_cond = text_encoder(prompts_cond)[0].half() encoder_hidden_states_nocond = text_encoder(prompts_nocond)[0] .half()
for t in tqdm(scheduler.timesteps):5 unmodified lines del noise_pred_cond del noise_pred_uncond
torch.cuda.empty_cache() torch.cuda.empty_cache()
# decode input = 1 / vae.config.scaling_factor * input 1 unmodified line width, height = 512, 512 results = [] new_image = Image.new('RGB', (2*width, 2*height)) for index, image in enumerate(images.float()): for index, image in enumerate(images.cpu().float()): image = (image / 2 + 0.5).clamp(0, 1).unsqueeze(0) image = image.cpu().permute(0, 2, 3, 1).numpy()[0] image = Image.fromarray((image * 255).round().astype("uint8")).convert('RGB')app.py+8-8