Update README.md
Browse files
README.md
CHANGED
|
@@ -9,4 +9,40 @@ license_link: https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia
|
|
| 9 |
language:
|
| 10 |
- en
|
| 11 |
pipeline_tag: text-to-image
|
| 12 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 15 |
+
|
| 16 |
+
This is my first time using DF11 to compress a model outside the Flux architecture. The reason why it is much easier for me to compress Flux-based models is that
|
| 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 Cosmos2TextToImagePipeline
|
| 34 |
+
from dfloat11 import DFloat11Model
|
| 35 |
+
pipe = Cosmos2TextToImagePipeline.from_pretrained("nvidia/Cosmos-Predict2-14B-Text2Image", torch_dtype=torch.bfloat16)
|
| 36 |
+
pipe.enable_model_cpu_offload()
|
| 37 |
+
DFloat11Model.from_pretrained("mingyi456/Cosmos-Predict2-14B-Text2Image-DF11", device='cpu', bfloat16_model=pipe.transformer)
|
| 38 |
+
prompt = "A futuristic cityscape at sunset, with flying cars, neon lights, and reflective water canals"
|
| 39 |
+
image = pipe(
|
| 40 |
+
prompt,
|
| 41 |
+
max_sequence_length=256,
|
| 42 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
| 43 |
+
).images[0]
|
| 44 |
+
image.save("Cosmos-Predict2-14B-Text2Image.png")
|
| 45 |
+
```
|
| 46 |
+
#### ComfyUI
|
| 47 |
+
|
| 48 |
+
~~Follow the instructions (have not tested myself) here: https://github.com/LeanModels/ComfyUI-DFloat11~~
|