Text-to-Image
Diffusers
Safetensors
English
Chinese
QwenImage21Pipeline
bitsandbytes
int8
image-generation
image-editing
rgba
8-bit precision
Instructions to use ixim/Image21-INT8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ixim/Image21-INT8 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ixim/Image21-INT8", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download tests/gpu_roundtrip.py from ixim/Image21-INT8: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/ixim/Image21-INT8/resolve/main/tests/gpu_roundtrip.py
- Command line
-
hf download hf://ixim/Image21-INT8/tests/gpu_roundtrip.py
-
curl -L -o gpu_roundtrip.py https://huggingface.co/ixim/Image21-INT8/resolve/main/tests/gpu_roundtrip.py
1.06 kB
| """Explicit GPU integration test; run with python -m tests.gpu_roundtrip.""" | |
| import tempfile | |
| from pathlib import Path | |
| import torch | |
| from diffusers import QwenImage21Transformer2DModel | |
| from scripts.quantize import quantize_component | |
| def main(): | |
| with tempfile.TemporaryDirectory() as d: | |
| root = Path(d) | |
| model = QwenImage21Transformer2DModel( | |
| num_layers=1, num_attention_heads=2, attention_head_dim=32, | |
| axes_dims_rope=(8, 12, 12), context_in_dim=64) | |
| model.save_pretrained(root / 'source' / 'transformer') | |
| del model | |
| report = quantize_component(root / 'source', root / 'target', 'transformer') | |
| assert report['int8_parameters'] > 0, report | |
| loaded = QwenImage21Transformer2DModel.from_pretrained( | |
| root / 'target' / 'transformer', device_map={'': 0}, dtype=torch.bfloat16) | |
| assert any(p.dtype == torch.int8 for p in loaded.parameters()) | |
| print('PASS: real QwenImage21Transformer2DModel INT8 save/reload', report) | |
| if __name__ == '__main__': | |
| main() | |