Update README.md
Browse files
README.md
CHANGED
|
@@ -10,7 +10,9 @@ license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICE
|
|
| 10 |

|
| 11 |
|
| 12 |
FLUX.1 dev Modern Anime FP8 With Quanto is an anime model with 8-bit float by Quanto library.
|
| 13 |
-
We can load this anime model < 15GB VRAM
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Usage
|
| 16 |
- diffusers
|
|
@@ -31,6 +33,8 @@ from optimum.quanto import QuantizedDiffusersModel, QuantizedTransformersModel
|
|
| 31 |
from transformers import T5EncoderModel
|
| 32 |
from huggingface_hub import snapshot_download
|
| 33 |
|
|
|
|
|
|
|
| 34 |
snapshot_download(repo_id="alfredplpl/flux.1-dev-modern-anime-fp8",local_dir="./anime_fp8")
|
| 35 |
|
| 36 |
class QuantizedT5EncoderModel(QuantizedTransformersModel):
|
|
@@ -45,10 +49,16 @@ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev",
|
|
| 45 |
text_encoder_2=None,
|
| 46 |
torch_dtype=torch.bfloat16)
|
| 47 |
|
| 48 |
-
pipe.transformer=QuantizedFlux2DModel.from_pretrained("./anime_fp8/transformer")
|
| 49 |
-
pipe.text_encoder_2=QuantizedT5EncoderModel.from_pretrained("./anime_fp8/text_encoder_2")
|
| 50 |
pipe.vae=pipe.vae.to(torch.float32)
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
prompt = "modern anime style, A close-up portrait of a young girl with green hair. Her hair is vibrant and shoulder-length, framing her face softly. She has large, expressive eyes that are slightly tilted upward, with a gentle and calm expression. Her facial features are delicate, with a small nose and soft lips. The background is simple, focusing attention on her face, with soft lighting that highlights her features. The overall style of the illustration is warm and inviting, with a soft color palette and a slightly dreamy atmosphere."
|
| 54 |
image = pipe(
|
|
|
|
| 10 |

|
| 11 |
|
| 12 |
FLUX.1 dev Modern Anime FP8 With Quanto is an anime model with 8-bit float by Quanto library.
|
| 13 |
+
We can load this anime model < 15GB VRAM if enable_model_cpu_offload is True.
|
| 14 |
+
otherwise, we can load this anime model < 20GB VRAM.
|
| 15 |
+
We can run this model on RTX 4090 or NVIDIA L4.
|
| 16 |
|
| 17 |
# Usage
|
| 18 |
- diffusers
|
|
|
|
| 33 |
from transformers import T5EncoderModel
|
| 34 |
from huggingface_hub import snapshot_download
|
| 35 |
|
| 36 |
+
enable_model_cpu_offload=True
|
| 37 |
+
|
| 38 |
snapshot_download(repo_id="alfredplpl/flux.1-dev-modern-anime-fp8",local_dir="./anime_fp8")
|
| 39 |
|
| 40 |
class QuantizedT5EncoderModel(QuantizedTransformersModel):
|
|
|
|
| 49 |
text_encoder_2=None,
|
| 50 |
torch_dtype=torch.bfloat16)
|
| 51 |
|
| 52 |
+
pipe.transformer=QuantizedFlux2DModel.from_pretrained("./anime_fp8/transformer")._wrapped
|
| 53 |
+
pipe.text_encoder_2=QuantizedT5EncoderModel.from_pretrained("./anime_fp8/text_encoder_2")._wrapped
|
| 54 |
pipe.vae=pipe.vae.to(torch.float32)
|
| 55 |
+
# Option
|
| 56 |
+
if(enable_model_cpu_offload):
|
| 57 |
+
pipe.enable_model_cpu_offload()
|
| 58 |
+
else:
|
| 59 |
+
pipe.text_encoder_2=pipe.text_encoder_2.to("cuda:1")
|
| 60 |
+
pipe.transformer=pipe.transformer.to("cuda:1")
|
| 61 |
+
pipe=pipe.to("cuda:1")
|
| 62 |
|
| 63 |
prompt = "modern anime style, A close-up portrait of a young girl with green hair. Her hair is vibrant and shoulder-length, framing her face softly. She has large, expressive eyes that are slightly tilted upward, with a gentle and calm expression. Her facial features are delicate, with a small nose and soft lips. The background is simple, focusing attention on her face, with soft lighting that highlights her features. The overall style of the illustration is warm and inviting, with a soft color palette and a slightly dreamy atmosphere."
|
| 64 |
image = pipe(
|