Spaces:
Build error
Build error
Commit ·
586de43
1
Parent(s): ea0bceb
update
Browse files64 unmodified lines6566676869707111 unmodified lines83848586878889909192247 unmodified lines3403413423433443453463473483495 unmodified lines3553563573583593603611 unmodified line36336436536636736836964 unmodified lines#### import diffusion modelstext_encoder = CLIPTextModel.from_pretrained('JingyeChen22/textdiffuser2-full-ft', subfolder="text_encoder", ignore_mismatched_sizes=True).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()unet = UNet2DConditionModel.from_pretrained('JingyeChen22/textdiffuser2-full-ft', subfolder="unet").cuda()text_encoder.resize_token_embeddings(len(tokenizer))247 unmodified linesscheduler = 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 = noiseencoder_hidden_states_cond = text_encoder(prompts_cond)[0]encoder_hidden_states_nocond = text_encoder(prompts_nocond)[0]for t in tqdm(scheduler.timesteps):5 unmodified linesdel noise_pred_conddel noise_pred_uncondtorch.cuda.empty_cache()# decodeinput = 1 / vae.config.scaling_factor * input1 unmodified linewidth, height = 512, 512results = []new_image = Image.new('RGB', (2*width, 2*height))for index, image in enumerate(images.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')64 unmodified lines6566676869707111 unmodified lines83848586878889909192247 unmodified lines3403413423433443453463473483495 unmodified lines3553563573583593603611 unmodified line36336436536636736836964 unmodified lines#### import diffusion modelstext_encoder = CLIPTextModel.from_pretrained('JingyeChen22/textdiffuser2-full-ft', subfolder="text_encoder", ignore_mismatched_sizes=True).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").half().cuda()unet = UNet2DConditionModel.from_pretrained('JingyeChen22/textdiffuser2-full-ft', subfolder="unet").half().cuda()text_encoder.resize_token_embeddings(len(tokenizer))247 unmodified linesscheduler = 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.half()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 linesdel noise_pred_conddel noise_pred_uncondtorch.cuda.empty_cache()# decodeinput = 1 / vae.config.scaling_factor * input1 unmodified linewidth, height = 512, 512results = []new_image = Image.new('RGB', (2*width, 2*height))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