Update Fluently-XL-v2.py
Browse files- Fluently-XL-v2.py +17 -23
Fluently-XL-v2.py
CHANGED
|
@@ -4,22 +4,21 @@
|
|
| 4 |
|
| 5 |
import torch
|
| 6 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
| 7 |
-
import uuid
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def save_image(img):
|
|
|
|
| 11 |
unique_name = str(uuid.uuid4()) + ".png"
|
| 12 |
img.save(unique_name)
|
| 13 |
return unique_name
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 18 |
-
"fluently/Fluently-XL-v2",
|
| 19 |
-
torch_dtype=torch.float16,
|
| 20 |
-
use_safetensors=True,
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 24 |
|
| 25 |
## lora
|
|
@@ -28,13 +27,7 @@ if torch.cuda.is_available():
|
|
| 28 |
|
| 29 |
pipe.to("cuda")
|
| 30 |
|
| 31 |
-
|
| 32 |
-
negative_prompt = "(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)"
|
| 33 |
-
width, height = 1024, 1024
|
| 34 |
-
guidance_scale = 6
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
images = pipe(
|
| 38 |
prompt=prompt,
|
| 39 |
negative_prompt=negative_prompt,
|
| 40 |
width=width,
|
|
@@ -44,10 +37,11 @@ if torch.cuda.is_available():
|
|
| 44 |
num_images_per_prompt=1,
|
| 45 |
cross_attention_kwargs={"scale": 0.65},
|
| 46 |
output_type="pil",
|
| 47 |
-
).images
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
print(image_paths)
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
import torch
|
| 6 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
|
|
|
| 7 |
|
| 8 |
+
model_id = "fluently/Fluently-XL-v2"
|
| 9 |
+
negative_prompt = "(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)"
|
| 10 |
+
width, height = 1024, 1024
|
| 11 |
+
guidance_scale = 6
|
| 12 |
|
| 13 |
def save_image(img):
|
| 14 |
+
import uuid
|
| 15 |
unique_name = str(uuid.uuid4()) + ".png"
|
| 16 |
img.save(unique_name)
|
| 17 |
return unique_name
|
| 18 |
+
|
| 19 |
+
def t2i(prompt):
|
| 20 |
+
|
| 21 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_safetensors=True,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 23 |
|
| 24 |
## lora
|
|
|
|
| 27 |
|
| 28 |
pipe.to("cuda")
|
| 29 |
|
| 30 |
+
image = pipe(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
prompt=prompt,
|
| 32 |
negative_prompt=negative_prompt,
|
| 33 |
width=width,
|
|
|
|
| 37 |
num_images_per_prompt=1,
|
| 38 |
cross_attention_kwargs={"scale": 0.65},
|
| 39 |
output_type="pil",
|
| 40 |
+
).images[0]
|
| 41 |
+
|
| 42 |
+
return image
|
|
|
|
| 43 |
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
prompt = "a girl in beijing"
|
| 46 |
+
image = t2i(prompt)
|
| 47 |
+
image.save("fluently-xl-v2_output.png")
|