Model card auto-generated by SimpleTuner
Browse files
README.md
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
base_model: "Shitao/OmniGen-v1-diffusers"
|
4 |
+
tags:
|
5 |
+
- omnigen
|
6 |
+
- omnigen-diffusers
|
7 |
+
- text-to-image
|
8 |
+
- image-to-image
|
9 |
+
- diffusers
|
10 |
+
- simpletuner
|
11 |
+
- not-for-all-audiences
|
12 |
+
- lora
|
13 |
+
- template:sd-lora
|
14 |
+
- lycoris
|
15 |
+
pipeline_tag: text-to-image
|
16 |
+
inference: true
|
17 |
+
widget:
|
18 |
+
- text: 'unconditional (blank prompt)'
|
19 |
+
parameters:
|
20 |
+
negative_prompt: 'ugly, cropped, blurry, low-quality, mediocre average'
|
21 |
+
output:
|
22 |
+
url: ./assets/image_0_0.png
|
23 |
+
- text: 'An ugly hillbilly woman with missing teeth and a mediocre smile'
|
24 |
+
parameters:
|
25 |
+
negative_prompt: 'ugly, cropped, blurry, low-quality, mediocre average'
|
26 |
+
output:
|
27 |
+
url: ./assets/image_1_0.png
|
28 |
+
---
|
29 |
+
|
30 |
+
# omnigen-lora-test
|
31 |
+
|
32 |
+
This is a LyCORIS adapter derived from [Shitao/OmniGen-v1-diffusers](https://huggingface.co/Shitao/OmniGen-v1-diffusers).
|
33 |
+
|
34 |
+
The main validation prompt used during training was:
|
35 |
+
```
|
36 |
+
An ugly hillbilly woman with missing teeth and a mediocre smile
|
37 |
+
```
|
38 |
+
|
39 |
+
|
40 |
+
## Validation settings
|
41 |
+
- CFG: `3.0`
|
42 |
+
- CFG Rescale: `0.0`
|
43 |
+
- Steps: `30`
|
44 |
+
- Sampler: `FlowMatchEulerDiscreteScheduler`
|
45 |
+
- Seed: `42`
|
46 |
+
- Resolution: `768x768`
|
47 |
+
|
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: 1
|
63 |
+
- Training steps: 10
|
64 |
+
- Learning rate: 5e-05
|
65 |
+
- Learning rate schedule: cosine
|
66 |
+
- Warmup steps: 400000
|
67 |
+
- Max grad value: 0.0
|
68 |
+
- Effective batch size: 1
|
69 |
+
- Micro-batch size: 1
|
70 |
+
- Gradient accumulation steps: 1
|
71 |
+
- Number of GPUs: 1
|
72 |
+
- Gradient checkpointing: True
|
73 |
+
- Prediction type: flow_matching[]
|
74 |
+
- Optimizer: optimi-lion
|
75 |
+
- Trainable parameter precision: Pure BF16
|
76 |
+
- Base model precision: `int8-quanto`
|
77 |
+
- Caption dropout probability: 0.1%
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
### LyCORIS Config:
|
82 |
+
```json
|
83 |
+
{
|
84 |
+
"bypass_mode": true,
|
85 |
+
"algo": "lokr",
|
86 |
+
"multiplier": 1.0,
|
87 |
+
"full_matrix": true,
|
88 |
+
"linear_dim": 10000,
|
89 |
+
"linear_alpha": 1,
|
90 |
+
"factor": 4,
|
91 |
+
"apply_preset": {
|
92 |
+
"target_module": [
|
93 |
+
"Attention"
|
94 |
+
],
|
95 |
+
"module_algo_map": {
|
96 |
+
"Attention": {
|
97 |
+
"factor": 24
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
```
|
103 |
+
|
104 |
+
|
105 |
+
## Datasets
|
106 |
+
|
107 |
+
### edited-images-768
|
108 |
+
- Repeats: 0
|
109 |
+
- Total number of images: 5
|
110 |
+
- Total number of aspect buckets: 1
|
111 |
+
- Resolution: 0.589824 megapixels
|
112 |
+
- Cropped: False
|
113 |
+
- Crop style: None
|
114 |
+
- Crop aspect: None
|
115 |
+
- Used for regularisation data: No
|
116 |
+
|
117 |
+
|
118 |
+
## Inference
|
119 |
+
|
120 |
+
|
121 |
+
```python
|
122 |
+
import torch
|
123 |
+
from diffusers import DiffusionPipeline
|
124 |
+
from lycoris import create_lycoris_from_weights
|
125 |
+
|
126 |
+
|
127 |
+
def download_adapter(repo_id: str):
|
128 |
+
import os
|
129 |
+
from huggingface_hub import hf_hub_download
|
130 |
+
adapter_filename = "pytorch_lora_weights.safetensors"
|
131 |
+
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
|
132 |
+
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
|
133 |
+
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
|
134 |
+
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
|
135 |
+
os.makedirs(path_to_adapter, exist_ok=True)
|
136 |
+
hf_hub_download(
|
137 |
+
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
|
138 |
+
)
|
139 |
+
|
140 |
+
return path_to_adapter_file
|
141 |
+
|
142 |
+
model_id = 'Shitao/OmniGen-v1-diffusers'
|
143 |
+
adapter_repo_id = 'bghira/omnigen-lora-test'
|
144 |
+
adapter_filename = 'pytorch_lora_weights.safetensors'
|
145 |
+
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
|
146 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
|
147 |
+
lora_scale = 1.0
|
148 |
+
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
|
149 |
+
wrapper.merge_to()
|
150 |
+
|
151 |
+
prompt = "An ugly hillbilly woman with missing teeth and a mediocre smile"
|
152 |
+
negative_prompt = 'ugly, cropped, blurry, low-quality, mediocre average'
|
153 |
+
|
154 |
+
## Optional: quantise the model to save on vram.
|
155 |
+
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
|
156 |
+
from optimum.quanto import quantize, freeze, qint8
|
157 |
+
quantize(pipeline.transformer, weights=qint8)
|
158 |
+
freeze(pipeline.transformer)
|
159 |
+
|
160 |
+
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
|
161 |
+
model_output = pipeline(
|
162 |
+
prompt=prompt,
|
163 |
+
negative_prompt=negative_prompt,
|
164 |
+
num_inference_steps=30,
|
165 |
+
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
|
166 |
+
width=768,
|
167 |
+
height=768,
|
168 |
+
guidance_scale=3.0,
|
169 |
+
).images[0]
|
170 |
+
|
171 |
+
model_output.save("output.png", format="PNG")
|
172 |
+
|
173 |
+
```
|
174 |
+
|
175 |
+
|
176 |
+
|