Delete Fluently-XL-v2.py
Browse files- Fluently-XL-v2.py +0 -47
Fluently-XL-v2.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
# https://huggingface.co/spaces/ehristoforu/dalle-3-xl-lora-v2
|
| 2 |
-
# pip install diffusers transformers accelerate safetensors
|
| 3 |
-
# HF_ENDPOINT=https://hf-mirror.com python Fluently-XL-v2.py
|
| 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
|
| 25 |
-
# pipe.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle")
|
| 26 |
-
# pipe.set_adapters("dalle")
|
| 27 |
-
|
| 28 |
-
pipe.to("cuda")
|
| 29 |
-
|
| 30 |
-
image = pipe(
|
| 31 |
-
prompt=prompt,
|
| 32 |
-
negative_prompt=negative_prompt,
|
| 33 |
-
width=width,
|
| 34 |
-
height=height,
|
| 35 |
-
guidance_scale=guidance_scale,
|
| 36 |
-
num_inference_steps=25,
|
| 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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|