patrickvonplaten commited on
Commit
c99f7ad
·
1 Parent(s): 8e8daa7
run_bug_4297_new.py CHANGED
@@ -9,7 +9,7 @@ torch.backends.cuda.enable_flash_sdp(False)
9
 
10
  # vae = AutoEncoderKL.from_pretrained("stabilityai/sdxl-vae", torch_dtype=torch.float16)
11
  # base_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", vae=vae, torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
12
- base_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", vae, torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
13
  base_pipe.to("cuda") # OR, pipe.enable_sequential_cpu_offload() OR,
14
 
15
  # Reproducibility.
@@ -32,9 +32,8 @@ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refine
32
  pipe.unet.to(memory_format=torch.channels_last)
33
  pipe.to("cuda") # OR, pipe.enable_sequential_cpu_offload() OR,
34
 
35
- # Generate the base image.
36
  pre_image = base_pipe(prompt=prompt, generator=generator,
37
- num_inference_steps=total_num_steps, negative_prompt=negative_prompt, num_images_per_prompt=batch_size, output_type="latent" if do_latent else "pil").images
38
 
39
  # Generate a range from 0.1 to 0.9, with 0.1 increments.
40
  test_strengths = [0.5]
 
9
 
10
  # vae = AutoEncoderKL.from_pretrained("stabilityai/sdxl-vae", torch_dtype=torch.float16)
11
  # base_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", vae=vae, torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
12
+ base_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
13
  base_pipe.to("cuda") # OR, pipe.enable_sequential_cpu_offload() OR,
14
 
15
  # Reproducibility.
 
32
  pipe.unet.to(memory_format=torch.channels_last)
33
  pipe.to("cuda") # OR, pipe.enable_sequential_cpu_offload() OR,
34
 
 
35
  pre_image = base_pipe(prompt=prompt, generator=generator,
36
+ num_inference_steps=total_num_steps, negative_prompt=negative_prompt, num_images_per_prompt=batch_size, output_type="latent" if do_latent else "pil").images
37
 
38
  # Generate a range from 0.1 to 0.9, with 0.1 increments.
39
  test_strengths = [0.5]
run_xl_lora.py CHANGED
@@ -1,7 +1,32 @@
1
  #!/usr/bin/env python3
2
  from diffusers import DiffusionPipeline
3
  import torch
 
 
 
4
 
5
- pipe = DiffusionPipeline.from_pretrained("/home/patrick/sai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
6
- pipe.load_lora_weights("/home/patrick/sai/stable-diffusion-xl-base-1.0/sd_xl_offset_example-lora_1.0.safetensors")
7
- import ipdb; ipdb.set_trace()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/usr/bin/env python3
2
  from diffusers import DiffusionPipeline
3
  import torch
4
+ from pathlib import Path
5
+ from huggingface_hub import HfApi
6
+ import os
7
 
8
+ api = HfApi()
9
+
10
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
11
+ pipe.load_lora_weights("./sd_xl_offset_example-lora_1.0.safetensors")
12
+ pipe.to(torch_dtype=torch.float16)
13
+ pipe.to("cuda")
14
+
15
+ torch.manual_seed(0)
16
+
17
+ prompt = "beautiful scenery nature glass bottle landscape, , purple galaxy bottle"
18
+ negative_prompt = "text, watermark"
19
+
20
+ image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=25).images[0]
21
+
22
+ file_name = f"aaa"
23
+ path = os.path.join(Path.home(), "images", f"{file_name}.png")
24
+ image.save(path)
25
+
26
+ api.upload_file(
27
+ path_or_fileobj=path,
28
+ path_in_repo=path.split("/")[-1],
29
+ repo_id="patrickvonplaten/images",
30
+ repo_type="dataset",
31
+ )
32
+ print(f"https://huggingface.co/datasets/patrickvonplaten/images/blob/main/{file_name}.png")
sd_xl_offset_example-lora_1.0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4852686128f953d0277d0793e2f0335352f96a919c9c16a09787d77f55cbdf6f
3
+ size 49553604