Update README.md
Browse files
README.md
CHANGED
|
@@ -1,174 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: other
|
| 3 |
-
base_model: "Qwen/Qwen-Image"
|
| 4 |
-
tags:
|
| 5 |
-
- qwen_image
|
| 6 |
-
- qwen_image-diffusers
|
| 7 |
-
- text-to-image
|
| 8 |
-
- image-to-image
|
| 9 |
-
- diffusers
|
| 10 |
-
- simpletuner
|
| 11 |
-
- safe-for-work
|
| 12 |
-
- lora
|
| 13 |
-
|
| 14 |
-
- template:sd-lora
|
| 15 |
-
- lycoris
|
| 16 |
-
pipeline_tag: text-to-image
|
| 17 |
-
inference: true
|
| 18 |
-
widget:
|
| 19 |
-
- text: 'Graffito Mixed-Media Stop-Motion — MEDIUM SHOT of Tony, a puppet with a PHOTOGRAPHIC CUTOUT face and PAINTED PAPER CUTOUT body, running energetically towards the camera in a dimly lit street scene at night. Tony wears a light blue shirt with a red collar, his arms are outstretched, and his PHOTOGRAPHIC CUTOUT face shows an urgent expression. Behind him, a PAINTED CARDBOARD vehicle features a single bright headlight casting a harsh glare and illuminating Tony.'
|
| 20 |
-
parameters:
|
| 21 |
-
negative_prompt: 'blurry, cropped, ugly'
|
| 22 |
-
output:
|
| 23 |
-
url: ./assets/image_0_0.png
|
| 24 |
-
---
|
| 25 |
-
|
| 26 |
-
# gr4f1tt0_v1_qwen
|
| 27 |
-
|
| 28 |
-
This is a LyCORIS adapter derived from [Qwen/Qwen-Image](https://huggingface.co/Qwen/Qwen-Image).
|
| 29 |
-
|
| 30 |
-
The main validation prompt used during training was:
|
| 31 |
-
```
|
| 32 |
-
Graffito Mixed-Media Stop-Motion — MEDIUM SHOT of Tony, a puppet with a PHOTOGRAPHIC CUTOUT face and PAINTED PAPER CUTOUT body, running energetically towards the camera in a dimly lit street scene at night. Tony wears a light blue shirt with a red collar, his arms are outstretched, and his PHOTOGRAPHIC CUTOUT face shows an urgent expression. Behind him, a PAINTED CARDBOARD vehicle features a single bright headlight casting a harsh glare and illuminating Tony.
|
| 33 |
-
```
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
## Validation settings
|
| 37 |
-
- CFG: `3.5`
|
| 38 |
-
- CFG Rescale: `0.0`
|
| 39 |
-
- Steps: `30`
|
| 40 |
-
- Sampler: `FlowMatchEulerDiscreteScheduler`
|
| 41 |
-
- Seed: `None`
|
| 42 |
-
- Resolution: `1536x640`
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
Note: The validation settings are not necessarily the same as the [training settings](#training-settings).
|
| 46 |
-
|
| 47 |
-
You can find some example images in the following gallery:
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
<Gallery />
|
| 51 |
-
|
| 52 |
-
The text encoder **was not** trained.
|
| 53 |
-
You may reuse the base model text encoder for inference.
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
## Training settings
|
| 57 |
-
|
| 58 |
-
- Training epochs: 297
|
| 59 |
-
- Training steps: 8250
|
| 60 |
-
- Learning rate: 0.0001
|
| 61 |
-
- Learning rate schedule: constant_with_warmup
|
| 62 |
-
- Warmup steps: 100
|
| 63 |
-
- Max grad value: 0.01
|
| 64 |
-
- Effective batch size: 4
|
| 65 |
-
- Micro-batch size: 1
|
| 66 |
-
- Gradient accumulation steps: 4
|
| 67 |
-
- Number of GPUs: 1
|
| 68 |
-
- Gradient checkpointing: False
|
| 69 |
-
- Prediction type: flow_matching[]
|
| 70 |
-
- Optimizer: adamw_bf16
|
| 71 |
-
- Trainable parameter precision: Pure BF16
|
| 72 |
-
- Base model precision: `fp8-torchao`
|
| 73 |
-
- Caption dropout probability: 0.0%
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
### LyCORIS Config:
|
| 78 |
-
```json
|
| 79 |
-
{
|
| 80 |
-
"algo": "lokr",
|
| 81 |
-
"multiplier": 1.0,
|
| 82 |
-
"linear_dim": 10000,
|
| 83 |
-
"linear_alpha": 1,
|
| 84 |
-
"factor": 16,
|
| 85 |
-
"apply_preset": {
|
| 86 |
-
"target_module": [
|
| 87 |
-
"Attention",
|
| 88 |
-
"FeedForward"
|
| 89 |
-
],
|
| 90 |
-
"module_algo_map": {
|
| 91 |
-
"Attention": {
|
| 92 |
-
"factor": 16
|
| 93 |
-
},
|
| 94 |
-
"FeedForward": {
|
| 95 |
-
"factor": 8
|
| 96 |
-
}
|
| 97 |
-
}
|
| 98 |
-
}
|
| 99 |
-
}
|
| 100 |
-
```
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
## Datasets
|
| 104 |
-
|
| 105 |
-
### graffito
|
| 106 |
-
- Repeats: 0
|
| 107 |
-
- Total number of images: 111
|
| 108 |
-
- Total number of aspect buckets: 1
|
| 109 |
-
- Resolution: 1.048576 megapixels
|
| 110 |
-
- Cropped: False
|
| 111 |
-
- Crop style: None
|
| 112 |
-
- Crop aspect: None
|
| 113 |
-
- Used for regularisation data: No
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
## Inference
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
```python
|
| 120 |
-
import torch
|
| 121 |
-
from diffusers import DiffusionPipeline
|
| 122 |
-
from lycoris import create_lycoris_from_weights
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
def download_adapter(repo_id: str):
|
| 126 |
-
import os
|
| 127 |
-
from huggingface_hub import hf_hub_download
|
| 128 |
-
adapter_filename = "pytorch_lora_weights.safetensors"
|
| 129 |
-
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
|
| 130 |
-
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
|
| 131 |
-
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
|
| 132 |
-
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
|
| 133 |
-
os.makedirs(path_to_adapter, exist_ok=True)
|
| 134 |
-
hf_hub_download(
|
| 135 |
-
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
|
| 136 |
-
)
|
| 137 |
-
|
| 138 |
-
return path_to_adapter_file
|
| 139 |
-
|
| 140 |
-
model_id = 'Qwen/Qwen-Image'
|
| 141 |
-
adapter_repo_id = 'davidrd123/gr4f1tt0_v1_qwen'
|
| 142 |
-
adapter_filename = 'pytorch_lora_weights.safetensors'
|
| 143 |
-
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
|
| 144 |
-
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
|
| 145 |
-
lora_scale = 1.0
|
| 146 |
-
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
|
| 147 |
-
wrapper.merge_to()
|
| 148 |
-
|
| 149 |
-
prompt = "Graffito Mixed-Media Stop-Motion — MEDIUM SHOT of Tony, a puppet with a PHOTOGRAPHIC CUTOUT face and PAINTED PAPER CUTOUT body, running energetically towards the camera in a dimly lit street scene at night. Tony wears a light blue shirt with a red collar, his arms are outstretched, and his PHOTOGRAPHIC CUTOUT face shows an urgent expression. Behind him, a PAINTED CARDBOARD vehicle features a single bright headlight casting a harsh glare and illuminating Tony."
|
| 150 |
-
negative_prompt = 'blurry, cropped, ugly'
|
| 151 |
-
|
| 152 |
-
## Optional: quantise the model to save on vram.
|
| 153 |
-
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
|
| 154 |
-
from optimum.quanto import quantize, freeze, qint8
|
| 155 |
-
quantize(pipeline.transformer, weights=qint8)
|
| 156 |
-
freeze(pipeline.transformer)
|
| 157 |
-
|
| 158 |
-
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
|
| 159 |
-
model_output = pipeline(
|
| 160 |
-
prompt=prompt,
|
| 161 |
-
negative_prompt=negative_prompt,
|
| 162 |
-
num_inference_steps=30,
|
| 163 |
-
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
|
| 164 |
-
width=1536,
|
| 165 |
-
height=640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