Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,12 @@ from huggingface_hub import hf_hub_download
|
|
12 |
# The base model your LoRA was trained on.
|
13 |
base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
14 |
|
|
|
15 |
# The path to your LoRA file on the Hugging Face Hub.
|
16 |
-
lora_repo_id = "
|
17 |
lora_filename = "emilyh.safetensors"
|
18 |
|
19 |
-
# --- Load the Pipeline ---
|
20 |
# Use a recommended VAE for SDXL
|
21 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
22 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
@@ -27,21 +28,15 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
27 |
use_safetensors=True
|
28 |
)
|
29 |
|
30 |
-
# --- Load and Fuse the LoRA ---
|
31 |
# Download the LoRA file and load the state dict.
|
32 |
lora_file_path = hf_hub_download(repo_id=lora_repo_id, filename=lora_filename)
|
33 |
pipe.load_lora_weights(lora_file_path)
|
34 |
|
35 |
-
# It's recommended to fuse the LoRA weights for better performance,
|
36 |
-
# but this is optional. You can also use pipe.set_adapters(["default"], adapter_weights=[0.9])
|
37 |
-
# during inference if you prefer more dynamic control.
|
38 |
-
# pipe.fuse_lora(lora_scale=0.9) # Fusing is more efficient
|
39 |
-
|
40 |
# Move the pipeline to the GPU
|
41 |
pipe.to("cuda")
|
42 |
|
43 |
# --- Default Settings from your Recommendations ---
|
44 |
-
# These are pulled directly from your "Recomendations.txt".
|
45 |
default_positive_prompt = "masterpiece, best quality, ultra-detailed, realistic skin, intricate details, highres"
|
46 |
default_negative_prompt = "low quality, worst quality, blurry, (deformed:1.3), extra fingers, cartoon, 3d, anime, bad anatomy"
|
47 |
default_sampler = "DPM++ 2M Karras"
|
@@ -79,7 +74,7 @@ def generate_image(prompt, negative_prompt, sampler, steps, cfg, width, height,
|
|
79 |
guidance_scale=cfg,
|
80 |
num_inference_steps=steps,
|
81 |
generator=generator,
|
82 |
-
cross_attention_kwargs={"scale": 0.9}
|
83 |
).images[0]
|
84 |
|
85 |
return image
|
|
|
12 |
# The base model your LoRA was trained on.
|
13 |
base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
14 |
|
15 |
+
# --- CORRECTED REPOSITORY PATH ---
|
16 |
# The path to your LoRA file on the Hugging Face Hub.
|
17 |
+
lora_repo_id = "TuringSolutions/EmilyH" # Corrected from "TuringsSolutions"
|
18 |
lora_filename = "emilyh.safetensors"
|
19 |
|
20 |
+
# --- Load the Pipeline (No token needed for public repos) ---
|
21 |
# Use a recommended VAE for SDXL
|
22 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
23 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
|
28 |
use_safetensors=True
|
29 |
)
|
30 |
|
31 |
+
# --- Load and Fuse the LoRA (No token needed for public repos) ---
|
32 |
# Download the LoRA file and load the state dict.
|
33 |
lora_file_path = hf_hub_download(repo_id=lora_repo_id, filename=lora_filename)
|
34 |
pipe.load_lora_weights(lora_file_path)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
# Move the pipeline to the GPU
|
37 |
pipe.to("cuda")
|
38 |
|
39 |
# --- Default Settings from your Recommendations ---
|
|
|
40 |
default_positive_prompt = "masterpiece, best quality, ultra-detailed, realistic skin, intricate details, highres"
|
41 |
default_negative_prompt = "low quality, worst quality, blurry, (deformed:1.3), extra fingers, cartoon, 3d, anime, bad anatomy"
|
42 |
default_sampler = "DPM++ 2M Karras"
|
|
|
74 |
guidance_scale=cfg,
|
75 |
num_inference_steps=steps,
|
76 |
generator=generator,
|
77 |
+
cross_attention_kwargs={"scale": 0.9}
|
78 |
).images[0]
|
79 |
|
80 |
return image
|