dhairyashil commited on
Commit
6dd89d5
·
1 Parent(s): cc3ad99

add readme and config

Browse files
Files changed (2) hide show
  1. README.md +105 -3
  2. config.json +59 -0
README.md CHANGED
@@ -1,3 +1,105 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ tags:
5
+ - text-to-image
6
+ - diffusion
7
+ - mflux
8
+ - development
9
+ datasets:
10
+ - custom
11
+ ---
12
+
13
+ # FLUX.1-dev-mflux-8bit
14
+
15
+ [![Hugging Face](https://img.shields.io/badge/🤗%20Hugging%20Face-FLUX.1--dev--mflux--8bit-blue)](https://huggingface.co/dhairyashil/FLUX.1-dev-mflux-8bit)
16
+
17
+ ![comparison_output](comparison.png)
18
+
19
+ A quantized version of the [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) text-to-image model, implemented using the [mflux](https://github.com/filipstrand/mflux) (version 0.6.2) quantization approach.
20
+
21
+ ## Overview
22
+
23
+ This repository contains the 8-bit quantized FLUX.1 model, which significantly reduces the memory footprint while maintaining most of the generation quality. The quantization was performed using the mflux.
24
+
25
+ ### Benefits of 8-bit Quantization
26
+
27
+ - **Reduced Memory Usage**: ~50% reduction in memory requirements compared to the original model
28
+ - **Faster Loading Times**: Smaller model size means quicker initialization
29
+ - **Lower Storage Requirements**: Significantly smaller disk footprint
30
+ - **Accessibility**: Can run on consumer hardware with limited VRAM
31
+ - **Minimal Quality Loss**: Maintains nearly identical output quality to the original model
32
+
33
+ ## Model Structure
34
+
35
+ This repository contains the following components:
36
+
37
+ - `text_encoder/`: CLIP text encoder (8-bit quantized)
38
+ - `text_encoder_2/`: Secondary text encoder (8-bit quantized)
39
+ - `tokenizer/`: CLIP tokenizer configuration and vocabulary
40
+ - `tokenizer_2/`: Secondary tokenizer configuration
41
+ - `transformer/`: Main diffusion model components (8-bit quantized)
42
+ - `vae/`: Variational autoencoder for image encoding/decoding (8-bit quantized)
43
+
44
+ ## Usage
45
+
46
+ ### Requirements
47
+
48
+ - Python
49
+ - PyTorch
50
+ - Transformers
51
+ - Diffusers
52
+ - [mflux](https://github.com/filipstrand/mflux) library (for 8-bit model support)
53
+
54
+ ### Installation
55
+
56
+ ```bash
57
+ pip install torch diffusers transformers accelerate
58
+ uv tool install mflux # check mflux README for more details
59
+ ```
60
+
61
+ ### Example Usage
62
+
63
+ ```bash
64
+ # export path for mflux
65
+ % mflux-generate \
66
+ --path "dhairyashil/FLUX.1-dev-mflux-8bit" \
67
+ --model dev \
68
+ --steps 25 \
69
+ --seed 2 \
70
+ --height 1920 \
71
+ --width 1024 \
72
+ --prompt "hot chocolate dish"
73
+ ```
74
+
75
+ ### Comparison Output
76
+ The images generated from above prompt for different models are shown at the top.
77
+
78
+ fp16 and 8-bit results look visibly almost the same, with the 8-bit version maintaining excellent quality while using significantly less memory.
79
+
80
+ A [4-bit development model](https://huggingface.co/dhairyashil/FLUX.1-dev-mflux-4bit) may also be available for testing, though with more noticeable quality difference.
81
+
82
+ ## Performance Comparison
83
+
84
+ | Model Version | Memory Usage | Inference Speed | Quality |
85
+ |---------------|--------------|-----------------|--------|
86
+ | Original FP16 | ~36 GB | Base | Base |
87
+ | 8-bit Quantized | ~18 GB | Nearly identical | Nearly identical |
88
+ | 4-bit Quantized | ~9 GB | Nearly identical | Moderately reduced |
89
+
90
+ ## Other Highlights
91
+
92
+ - Very minimal quality degradation compared to the original model
93
+ - Nearly identical inference speed
94
+ - Rare artifacts that are generally imperceptible in most use cases
95
+
96
+ ## Acknowledgements
97
+
98
+ - [Black Forest Labs](https://huggingface.co/black-forest-labs) for creating the original FLUX.1 model family
99
+ - [Filip Strand](https://github.com/filipstrand) for developing the mflux quantization methodology
100
+ - The Hugging Face team for their Diffusers and Transformers libraries
101
+ - All contributors to the development version for their testing and improvements
102
+
103
+ ## License
104
+
105
+ This model inherits the license of the original FLUX.1 model. Please refer to the [original model repository](https://huggingface.co/black-forest-labs/FLUX.1) for licensing information.
config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "FluxPipeline",
3
+ "_diffusers_version": "0.19.0",
4
+ "force_zeros_for_empty_prompt": true,
5
+ "add_watermarker": false,
6
+ "feature_extractor": [
7
+ "transformers",
8
+ "CLIPImageProcessor"
9
+ ],
10
+ "text_encoder": [
11
+ "transformers",
12
+ "CLIPTextModel"
13
+ ],
14
+ "text_encoder_2": [
15
+ "transformers",
16
+ "CLIPTextModelWithProjection"
17
+ ],
18
+ "tokenizer": [
19
+ "transformers",
20
+ "CLIPTokenizer"
21
+ ],
22
+ "tokenizer_2": [
23
+ "transformers",
24
+ "CLIPTokenizer"
25
+ ],
26
+ "transformer": [
27
+ "diffusers",
28
+ "FluxTransformerModel"
29
+ ],
30
+ "vae": [
31
+ "diffusers",
32
+ "AutoencoderKL"
33
+ ],
34
+ "model_type": "flux-rectified-flow",
35
+ "architecture": "rectified-flow-transformer",
36
+ "parameters": 12000000000,
37
+ "prediction_type": "flow",
38
+ "max_sequence_length": 256,
39
+ "requires_safety_checker": false,
40
+ "safety_checker": null,
41
+ "original_model": "black-forest-labs/FLUX.1-dev",
42
+ "model_description": "A development version of the 12 billion parameter rectified flow transformer capable of generating images from text descriptions using a hybrid architecture of multimodal and parallel diffusion transformer blocks",
43
+ "quantization": {
44
+ "method": "mflux",
45
+ "version": "0.6.2",
46
+ "bits": 8,
47
+ "original_dtype": "float16"
48
+ },
49
+ "memory_requirements": {
50
+ "original_fp16": "~57 GB",
51
+ "quantized_8bit": "~18 GB"
52
+ },
53
+ "recommended_inference_parameters": {
54
+ "steps": 25,
55
+ "guidance_scale": 0.0,
56
+ "max_sequence_length": 256
57
+ },
58
+ "license": "apache-2.0"
59
+ }