Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- image-generation
|
| 7 |
+
- diffusion
|
| 8 |
+
- burn
|
| 9 |
+
- rust
|
| 10 |
+
- text-to-image
|
| 11 |
+
library_name: burn
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Z-Image Turbo (Burn)
|
| 15 |
+
|
| 16 |
+
Z-Image Turbo model weights converted to Burn's Burnpack format for use with the [Burn deep learning framework](https://burn.dev).
|
| 17 |
+
|
| 18 |
+
## Model Description
|
| 19 |
+
|
| 20 |
+
Z-Image is a fast image generation model based on flow-matching diffusion, designed for generating high-quality images from text prompts. This repository contains the model weights in Burnpack (.bpk) format, optimized for inference on Apple Silicon (Metal) and other Burn backends.
|
| 21 |
+
|
| 22 |
+
## Files
|
| 23 |
+
|
| 24 |
+
| File | Size | Description |
|
| 25 |
+
|------|------|-------------|
|
| 26 |
+
| `z_image_turbo_bf16.bpk` | 11 GB | Transformer weights in BF16 precision |
|
| 27 |
+
|
| 28 |
+
## Additional Required Files
|
| 29 |
+
|
| 30 |
+
To run Z-Image, you also need:
|
| 31 |
+
|
| 32 |
+
- **Tokenizer**: From [holgt/qwen3-0.6b-burn](https://huggingface.co/holgt/qwen3-0.6b-burn) (tokenizer.json)
|
| 33 |
+
- **Text Encoder**: From [Comfy-Org/z_image_turbo](https://huggingface.co/Comfy-Org/z_image_turbo/tree/main/split_files/text_encoders) (qwen_3_4b.safetensors)
|
| 34 |
+
- **Autoencoder**: From [black-forest-labs/FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) (ae.safetensors)
|
| 35 |
+
|
| 36 |
+
## Usage
|
| 37 |
+
|
| 38 |
+
### With the z-image-app
|
| 39 |
+
|
| 40 |
+
See the [z-image-app](https://github.com/holg/qwen3-burn/tree/main/z-image-app) for a macOS GUI application.
|
| 41 |
+
|
| 42 |
+
### Rust Code Example
|
| 43 |
+
|
| 44 |
+
```rust
|
| 45 |
+
use burn::backend::candle::{Candle, CandleDevice};
|
| 46 |
+
use half::bf16;
|
| 47 |
+
use qwen3_burn::{Qwen3Config, Qwen3Model, Qwen3Tokenizer};
|
| 48 |
+
use z_image::{GenerateFromTextOpts, modules::ae::AutoEncoderConfig, modules::transformer::ZImageModelConfig};
|
| 49 |
+
|
| 50 |
+
type Backend = Candle<bf16, i64>;
|
| 51 |
+
|
| 52 |
+
fn main() {
|
| 53 |
+
let device = CandleDevice::metal(0);
|
| 54 |
+
let model_dir = PathBuf::from("./models");
|
| 55 |
+
|
| 56 |
+
// Load components
|
| 57 |
+
let tokenizer = Qwen3Tokenizer::from_file(model_dir.join("qwen3-tokenizer.json")).unwrap();
|
| 58 |
+
|
| 59 |
+
let mut text_encoder: Qwen3Model<Backend> = Qwen3Config::z_image_text_encoder().init(&device);
|
| 60 |
+
text_encoder.load_weights(model_dir.join("qwen3_4b_text_encoder.safetensors")).unwrap();
|
| 61 |
+
|
| 62 |
+
let mut transformer = ZImageModelConfig::default().init(&device);
|
| 63 |
+
transformer.load_weights(model_dir.join("z_image_turbo_bf16.bpk")).unwrap();
|
| 64 |
+
|
| 65 |
+
let mut ae = AutoEncoderConfig::flux_ae().init(&device);
|
| 66 |
+
ae.load_weights(model_dir.join("ae.safetensors")).unwrap();
|
| 67 |
+
|
| 68 |
+
// Generate image
|
| 69 |
+
let opts = GenerateFromTextOpts {
|
| 70 |
+
prompt: "A beautiful sunset over mountains".to_string(),
|
| 71 |
+
out_path: PathBuf::from("output.png"),
|
| 72 |
+
width: 512,
|
| 73 |
+
height: 512,
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
z_image::generate_from_text(&opts, &tokenizer, &text_encoder, &ae, &transformer, &device).unwrap();
|
| 77 |
+
}
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## Requirements
|
| 81 |
+
|
| 82 |
+
- Apple Silicon Mac with Metal support, or
|
| 83 |
+
- CUDA-capable GPU (with appropriate Burn backend)
|
| 84 |
+
- ~16GB RAM for 512x512 images
|
| 85 |
+
- Rust 2024 edition
|
| 86 |
+
|
| 87 |
+
## License
|
| 88 |
+
|
| 89 |
+
Apache 2.0
|
| 90 |
+
|
| 91 |
+
## Acknowledgments
|
| 92 |
+
|
| 93 |
+
- [Burn](https://burn.dev) - Deep learning framework
|
| 94 |
+
- [Comfy-Org](https://github.com/comfyanonymous/ComfyUI) - Original Z-Image model
|
| 95 |
+
- [black-forest-labs](https://huggingface.co/black-forest-labs) - FLUX autoencoder
|