Commit
·
ae23482
1
Parent(s):
a032108
correct vocab
Browse files- load_lora.py +12 -0
- run_local.py +20 -17
load_lora.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import torch
|
| 3 |
+
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
| 4 |
+
|
| 5 |
+
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 6 |
+
"runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, safety_checker=None
|
| 7 |
+
).to("cuda")
|
| 8 |
+
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(
|
| 9 |
+
pipeline.scheduler.config, use_karras_sigmas=True
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
pipeline.load_lora_weights("sayakpaul/sd-model-finetuned-lora-t4")
|
run_local.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
-
from diffusers import StableDiffusionPipeline
|
| 3 |
import time
|
| 4 |
import os
|
| 5 |
from huggingface_hub import HfApi
|
|
@@ -10,31 +10,34 @@ import requests
|
|
| 10 |
from PIL import Image
|
| 11 |
from io import BytesIO
|
| 12 |
|
| 13 |
-
begin = ["a picture of <rickmann>", "a photo of <rickmann>", "<rickmann>", "an image of <rickmann>"]
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
api = HfApi()
|
| 17 |
start_time = time.time()
|
| 18 |
path = "patrickvonplaten/papa_out_5"
|
| 19 |
pipe = StableDiffusionPipeline.from_pretrained(path, safety_checker=None, torch_dtype=torch.float16)
|
|
|
|
| 20 |
pipe = pipe.to("cuda")
|
| 21 |
counter = 0
|
| 22 |
|
| 23 |
for b in begin:
|
| 24 |
-
for
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
+
from diffusers import StableDiffusionPipeline, DDIMScheduler
|
| 3 |
import time
|
| 4 |
import os
|
| 5 |
from huggingface_hub import HfApi
|
|
|
|
| 10 |
from PIL import Image
|
| 11 |
from io import BytesIO
|
| 12 |
|
| 13 |
+
begin = ["a picture of <rickmann>", "a photo of <rickmann>", "The <rickmann>", "an image of <rickmann>"]
|
| 14 |
+
mid = ["", " on a bike", " with sunglasses", " at the beach", " in front of a mountain", " in the water", " on a boat", " at a fashion show", " as a superstar model", " while it snows", " in a forest", " with a nice landscape"]
|
| 15 |
+
end = ["", " , disco light style", ", minecraft style", " , picasso style", " as a lego person", ""]
|
| 16 |
|
| 17 |
api = HfApi()
|
| 18 |
start_time = time.time()
|
| 19 |
path = "patrickvonplaten/papa_out_5"
|
| 20 |
pipe = StableDiffusionPipeline.from_pretrained(path, safety_checker=None, torch_dtype=torch.float16)
|
| 21 |
+
pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
|
| 22 |
pipe = pipe.to("cuda")
|
| 23 |
counter = 0
|
| 24 |
|
| 25 |
for b in begin:
|
| 26 |
+
for m in mid:
|
| 27 |
+
for e in end:
|
| 28 |
+
prompt = b + mid + e + ", highly realistic, super resolution, high quality photography, beautiful"
|
| 29 |
|
| 30 |
+
images = pipe(prompt=prompt, num_images_per_prompt=2, eta=1.0, negative_prompt="ugly, bad quality, deformed", num_inference_steps=50).images
|
| 31 |
|
| 32 |
+
for i, image in enumerate(images):
|
| 33 |
+
path = os.path.join(Path.home(), "papa", f"{counter}.png")
|
| 34 |
+
image.save(path)
|
| 35 |
|
| 36 |
+
api.upload_file(
|
| 37 |
+
path_or_fileobj=path,
|
| 38 |
+
path_in_repo=path.split("/")[-1],
|
| 39 |
+
repo_id="patrickvonplaten/papa",
|
| 40 |
+
repo_type="dataset",
|
| 41 |
+
)
|
| 42 |
+
print(f"https://huggingface.co/datasets/patrickvonplaten/papa/blob/main/{counter}.png")
|
| 43 |
+
counter += 1
|