Text-to-Image
Diffusers
sd3
sd3-diffusers
simpletuner
Not-For-All-Audiences
lora
template:sd-lora
lycoris
Model card auto-generated by SimpleTuner
Browse files
README.md
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
base_model: "stabilityai/stable-diffusion-3.5-large"
|
4 |
+
tags:
|
5 |
+
- sd3
|
6 |
+
- sd3-diffusers
|
7 |
+
- text-to-image
|
8 |
+
- diffusers
|
9 |
+
- simpletuner
|
10 |
+
- not-for-all-audiences
|
11 |
+
- lora
|
12 |
+
- template:sd-lora
|
13 |
+
- lycoris
|
14 |
+
inference: true
|
15 |
+
widget:
|
16 |
+
- text: 'unconditional (blank prompt)'
|
17 |
+
parameters:
|
18 |
+
negative_prompt: 'blurry, cropped, ugly'
|
19 |
+
output:
|
20 |
+
url: ./assets/image_0_0.png
|
21 |
+
- text: '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'
|
22 |
+
parameters:
|
23 |
+
negative_prompt: 'blurry, cropped, ugly'
|
24 |
+
output:
|
25 |
+
url: ./assets/image_1_0.png
|
26 |
+
---
|
27 |
+
|
28 |
+
# sd35-training
|
29 |
+
|
30 |
+
This is a LyCORIS adapter derived from [stabilityai/stable-diffusion-3.5-large](https://huggingface.co/stabilityai/stable-diffusion-3.5-large).
|
31 |
+
|
32 |
+
|
33 |
+
The main validation prompt used during training was:
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
```
|
38 |
+
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
|
39 |
+
```
|
40 |
+
|
41 |
+
## Validation settings
|
42 |
+
- CFG: `5.0`
|
43 |
+
- CFG Rescale: `0.0`
|
44 |
+
- Steps: `30`
|
45 |
+
- Sampler: `None`
|
46 |
+
- Seed: `42`
|
47 |
+
- Resolution: `1024`
|
48 |
+
|
49 |
+
Note: The validation settings are not necessarily the same as the [training settings](#training-settings).
|
50 |
+
|
51 |
+
You can find some example images in the following gallery:
|
52 |
+
|
53 |
+
|
54 |
+
<Gallery />
|
55 |
+
|
56 |
+
The text encoder **was not** trained.
|
57 |
+
You may reuse the base model text encoder for inference.
|
58 |
+
|
59 |
+
|
60 |
+
## Training settings
|
61 |
+
|
62 |
+
- Training epochs: 3
|
63 |
+
- Training steps: 100
|
64 |
+
- Learning rate: 0.0001
|
65 |
+
- Max grad norm: 0.01
|
66 |
+
- Effective batch size: 2
|
67 |
+
- Micro-batch size: 2
|
68 |
+
- Gradient accumulation steps: 1
|
69 |
+
- Number of GPUs: 1
|
70 |
+
- Prediction type: flow-matching (extra parameters=['shift=3'])
|
71 |
+
- Rescaled betas zero SNR: False
|
72 |
+
- Optimizer: adamw_bf16
|
73 |
+
- Precision: Pure BF16
|
74 |
+
- Quantised: Yes: int8-quanto
|
75 |
+
- Xformers: Not used
|
76 |
+
- LyCORIS Config:
|
77 |
+
```json
|
78 |
+
{
|
79 |
+
"bypass_mode": true,
|
80 |
+
"algo": "lokr",
|
81 |
+
"multiplier": 1.0,
|
82 |
+
"full_matrix": true,
|
83 |
+
"linear_dim": 10000,
|
84 |
+
"linear_alpha": 1,
|
85 |
+
"factor": 12,
|
86 |
+
"apply_preset": {
|
87 |
+
"target_module": [
|
88 |
+
"Attention"
|
89 |
+
],
|
90 |
+
"module_algo_map": {
|
91 |
+
"Attention": {
|
92 |
+
"factor": 6
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
```
|
98 |
+
|
99 |
+
## Datasets
|
100 |
+
|
101 |
+
### emaSde3Ver1
|
102 |
+
- Repeats: 0
|
103 |
+
- Total number of images: 50
|
104 |
+
- Total number of aspect buckets: 1
|
105 |
+
- Resolution: 1.0 megapixels
|
106 |
+
- Cropped: true
|
107 |
+
- Crop style: center
|
108 |
+
- Crop aspect: square
|
109 |
+
- Used for regularisation data: No
|
110 |
+
|
111 |
+
|
112 |
+
## Inference
|
113 |
+
|
114 |
+
|
115 |
+
```python
|
116 |
+
import torch
|
117 |
+
from diffusers import DiffusionPipeline
|
118 |
+
from lycoris import create_lycoris_from_weights
|
119 |
+
|
120 |
+
|
121 |
+
def download_adapter(repo_id: str):
|
122 |
+
import os
|
123 |
+
from huggingface_hub import hf_hub_download
|
124 |
+
adapter_filename = "pytorch_lora_weights.safetensors"
|
125 |
+
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
|
126 |
+
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
|
127 |
+
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
|
128 |
+
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
|
129 |
+
os.makedirs(path_to_adapter, exist_ok=True)
|
130 |
+
hf_hub_download(
|
131 |
+
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
|
132 |
+
)
|
133 |
+
|
134 |
+
return path_to_adapter_file
|
135 |
+
|
136 |
+
model_id = 'stabilityai/stable-diffusion-3.5-large'
|
137 |
+
adapter_repo_id = 'alexnvo/sd35-training'
|
138 |
+
adapter_filename = 'pytorch_lora_weights.safetensors'
|
139 |
+
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
|
140 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
|
141 |
+
lora_scale = 1.0
|
142 |
+
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
|
143 |
+
wrapper.merge_to()
|
144 |
+
|
145 |
+
prompt = "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"
|
146 |
+
negative_prompt = 'blurry, cropped, ugly'
|
147 |
+
|
148 |
+
## Optional: quantise the model to save on vram.
|
149 |
+
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
|
150 |
+
from optimum.quanto import quantize, freeze, qint8
|
151 |
+
quantize(pipeline.transformer, weights=qint8)
|
152 |
+
freeze(pipeline.transformer)
|
153 |
+
|
154 |
+
pipeline.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
|
155 |
+
image = pipeline(
|
156 |
+
prompt=prompt,
|
157 |
+
negative_prompt=negative_prompt,
|
158 |
+
num_inference_steps=30,
|
159 |
+
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(1641421826),
|
160 |
+
width=1024,
|
161 |
+
height=1024,
|
162 |
+
guidance_scale=5.0,
|
163 |
+
).images[0]
|
164 |
+
image.save("output.png", format="PNG")
|
165 |
+
```
|
166 |
+
|