Silan10 commited on
Commit
ca2cc13
·
verified ·
1 Parent(s): 9c652af

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -0
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - text-to-image
4
+ - flux
5
+ - diffusers
6
+ - quantization
7
+ - bitsandbytes
8
+ - int8
9
+ license: other
10
+ language:
11
+ - en
12
+ base_model:
13
+ - black-forest-labs/FLUX.1-dev
14
+ pipeline_tag: text-to-image
15
+ ---
16
+
17
+ ## Model Overview
18
+
19
+ `Silan10/flux_quantized_bitsandbytes` is an **8-bit quantized version** of the
20
+ [`black-forest-labs/FLUX.1-dev`](https://huggingface.co/black-forest-labs/FLUX.1-dev)
21
+ text-to-image model. In this version, the **`transformer`**, **`text_encoder`** and
22
+ **`text_encoder_2`** components have been quantized to 8-bit precision using
23
+ [bitsandbytes](https://github.com/TimDettmers/bitsandbytes).
24
+
25
+ Bitsandbytes quantization uses **intelligent 8-bit integer
26
+ representation** with dynamic scaling factors. This provides substantial memory savings while maintaining high image quality through
27
+ mixed-precision computation.
28
+
29
+ ## Usage
30
+
31
+ import torch
32
+ import os
33
+ from diffusers import FluxPipeline
34
+
35
+ # Local model path or Hugging Face repository ID of an already-quantized model.
36
+ model_path = "Silan10/flux_quantized_bitsandbytes"
37
+
38
+ print("Loading pipeline...")
39
+
40
+ pipe = FluxPipeline.from_pretrained(
41
+ model_path,
42
+ torch_dtype=torch.bfloat16
43
+ )
44
+ pipe.to("cuda")
45
+ print("✓ Pipeline loaded successfully.")
46
+
47
+ prompt = "Ultra-detailed nighttime cyberpunk city street, several pedestrians in modern clothes, one person in the foreground looking toward the camera, sharp facial features and detailed hair, wet pavement reflecting colorful neon signs, shop windows with small readable text on signs, a gradient sky fading from deep blue to purple, a mix of strong highlights and deep shadows, highly detailed, 4K, cinematic lighting."
48
+ print(f"Generating image...")
49
+
50
+ image = pipe(
51
+ prompt,
52
+ num_inference_steps=20,
53
+ guidance_scale=3.5,
54
+ max_sequence_length=512,
55
+ width=1024,
56
+ height=1024,
57
+ generator=torch.Generator("cpu").manual_seed(42)
58
+ ).images[0]
59
+
60
+ image.save("output_bitsandbytes.png")
61
+ print(f"✓ Image generated successfully.")
62
+ print("DONE!")
63
+
64
+ ## Credits
65
+
66
+ - **Quantization**: [bitsandbytes](https://github.com/TimDettmers/bitsandbytes) by Tim Dettmers