Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model:
|
| 3 |
+
- tencent/SRPO
|
| 4 |
+
base_model_relation: quantized
|
| 5 |
+
library_name: diffusers
|
| 6 |
+
license: other
|
| 7 |
+
license_name: tencent-hunyuan-community
|
| 8 |
+
license_link: https://github.com/Tencent-Hunyuan/SRPO/blob/main/LICENSE.txt
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
+
pipeline_tag: text-to-image
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
For more information (including how to compress models yourself), check out https://huggingface.co/DFloat11 and https://github.com/LeanModels/DFloat11
|
| 15 |
+
|
| 16 |
+
Feel free to request for other models for compression as well, although compressing models that do not use the Flux architecture might be tricky for me.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
### How to Use
|
| 20 |
+
|
| 21 |
+
#### `diffusers`
|
| 22 |
+
|
| 23 |
+
1. Install the DFloat11 pip package *(installs the CUDA kernel automatically; requires a CUDA-compatible GPU and PyTorch installed)*:
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
pip install dfloat11[cuda12]
|
| 27 |
+
# or if you have CUDA version 11:
|
| 28 |
+
# pip install dfloat11[cuda11]
|
| 29 |
+
```
|
| 30 |
+
2. To use the DFloat11 model, run the following example code in Python:
|
| 31 |
+
```python
|
| 32 |
+
import torch
|
| 33 |
+
from diffusers import FluxPipeline, FluxTransformer2DModel
|
| 34 |
+
from dfloat11 import DFloat11Model
|
| 35 |
+
with no_init_weights():
|
| 36 |
+
transformer = FluxTransformer2DModel.from_config(
|
| 37 |
+
FluxTransformer2DModel.load_config(
|
| 38 |
+
"black-forest-labs/FLUX.1-dev",
|
| 39 |
+
subfolder="transformer"
|
| 40 |
+
),
|
| 41 |
+
torch_dtype=torch.bfloat16
|
| 42 |
+
).to(torch.bfloat16)
|
| 43 |
+
|
| 44 |
+
pipe = FluxPipeline.from_pretrained(
|
| 45 |
+
"black-forest-labs/FLUX.1-dev",
|
| 46 |
+
transformer=transformer,
|
| 47 |
+
torch_dtype=torch.bfloat16
|
| 48 |
+
)
|
| 49 |
+
DFloat11Model.from_pretrained('mingyi456/SRPO-DF11', device='cpu', bfloat16_model=pipe.transformer)
|
| 50 |
+
pipe.enable_model_cpu_offload()
|
| 51 |
+
prompt = "A futuristic cityscape at sunset, with flying cars, neon lights, and reflective water canals"
|
| 52 |
+
image = pipe(
|
| 53 |
+
prompt,
|
| 54 |
+
guidance_scale=3.5,
|
| 55 |
+
num_inference_steps=30,
|
| 56 |
+
max_sequence_length=256,
|
| 57 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
| 58 |
+
).images[0]
|
| 59 |
+
image.save("SPRO.png")
|
| 60 |
+
```
|
| 61 |
+
#### ComfyUI
|
| 62 |
+
Follow the instructions (have not tested myself) here: https://github.com/LeanModels/ComfyUI-DFloat11
|