Views
No views yet
emaSde3Ver1, a high-resolution photograph featuring a young caucasian woman with long, wavy, platinum blonde hair cascading over her shoulders, she has a slender yet curvaceous physique with prominent breasts and a small waist, her skin is fair and smooth, with a slight blush on her cheeks, giving her a sultry expression, she is wearing a sheer, black fishnet bodysuit that accentuates her curves, with her back to the viewer, revealing her lower back and buttocks, the bodice is made of a soft, textured fabric that clings to her body, emphasizing her curves and the texture of the fishnet fabric, she also wears a black choker around her neck, adding a touch of sensuality to her attire, the background features a blurred, out-of-focus view of a cityscape with distant mountains and a clear blue sky, suggesting an outdoor setting, the balcony she is standing on has wooden railings and a wooden railing, adding to the sense of a balcony or terrace, the overall mood of the photograph is sensual and intimate, emphasizing the subject's allure and beauty5.00.030None4210241{
2 "bypass_mode": true,
3 "algo": "lokr",
4 "multiplier": 1.0,
5 "full_matrix": true,
6 "linear_dim": 10000,
7 "linear_alpha": 1,
8 "factor": 12,
9 "apply_preset": {
10 "target_module": [
11 "Attention"
12 ],
13 "module_algo_map": {
14 "Attention": {
15 "factor": 6
16 }
17 }
18 }
19}1import torch
2from diffusers import DiffusionPipeline
3from lycoris import create_lycoris_from_weights
4
5
6def download_adapter(repo_id: str):
7 import os
8 from huggingface_hub import hf_hub_download
9 adapter_filename = "pytorch_lora_weights.safetensors"
10 cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
11 cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
12 path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
13 path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
14 os.makedirs(path_to_adapter, exist_ok=True)
15 hf_hub_download(
16 repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
17 )
18
19 return path_to_adapter_file
20
21model_id = 'stabilityai/stable-diffusion-3.5-large'
22adapter_repo_id = 'alexnvo/sd35-training'
23adapter_filename = 'pytorch_lora_weights.safetensors'
24adapter_file_path = download_adapter(repo_id=adapter_repo_id)
25pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
26lora_scale = 1.0
27wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
28wrapper.merge_to()
29
30prompt = "emaSde3Ver1, a high-resolution photograph featuring a young caucasian woman with long, wavy, platinum blonde hair cascading over her shoulders, she has a slender yet curvaceous physique with prominent breasts and a small waist, her skin is fair and smooth, with a slight blush on her cheeks, giving her a sultry expression, she is wearing a sheer, black fishnet bodysuit that accentuates her curves, with her back to the viewer, revealing her lower back and buttocks, the bodice is made of a soft, textured fabric that clings to her body, emphasizing her curves and the texture of the fishnet fabric, she also wears a black choker around her neck, adding a touch of sensuality to her attire, the background features a blurred, out-of-focus view of a cityscape with distant mountains and a clear blue sky, suggesting an outdoor setting, the balcony she is standing on has wooden railings and a wooden railing, adding to the sense of a balcony or terrace, the overall mood of the photograph is sensual and intimate, emphasizing the subject's allure and beauty"
31negative_prompt = 'blurry, cropped, ugly'
32
33## Optional: quantise the model to save on vram.
34## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
35from optimum.quanto import quantize, freeze, qint8
36quantize(pipeline.transformer, weights=qint8)
37freeze(pipeline.transformer)
38
39pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu') # the pipeline is already in its target precision level
40image = pipeline(
41 prompt=prompt,
42 negative_prompt=negative_prompt,
43 num_inference_steps=30,
44 generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(1641421826),
45 width=1024,
46 height=1024,
47 guidance_scale=5.0,
48).images[0]
49image.save("output.png", format="PNG")