Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,12 @@ HF_TOKEN = os.getenv("HF_TOKEN")
|
|
| 20 |
# Ensure that the minimal version of diffusers is installed
|
| 21 |
check_min_version("0.30.2")
|
| 22 |
|
| 23 |
-
quant_config =
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
"black-forest-labs/FLUX.1-dev",
|
| 26 |
subfolder="text_encoder_2",
|
| 27 |
quantization_config=quant_config,
|
|
@@ -29,6 +33,14 @@ text_encoder_8bit = T5EncoderModel.from_pretrained(
|
|
| 29 |
use_safetensors=True,
|
| 30 |
token=HF_TOKEN
|
| 31 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# Build pipeline
|
| 33 |
controlnet = FluxControlNetModel.from_pretrained(
|
| 34 |
"LPX55/FLUX.1-Inpainting-8step_uncensored",
|
|
@@ -47,7 +59,7 @@ pipe = FluxControlNetInpaintingPipeline.from_pretrained(
|
|
| 47 |
# device_map="balanced",
|
| 48 |
token=HF_TOKEN
|
| 49 |
)
|
| 50 |
-
pipe.text_encoder_2 =
|
| 51 |
|
| 52 |
# pipe.load_lora_weights(
|
| 53 |
# hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"), adapter_name="hyper-sd"
|
|
|
|
| 20 |
# Ensure that the minimal version of diffusers is installed
|
| 21 |
check_min_version("0.30.2")
|
| 22 |
|
| 23 |
+
quant_config = TransformersBitsAndBytesConfig(
|
| 24 |
+
load_in_4bit=True,
|
| 25 |
+
bnb_4bit_use_double_quant=True,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
text_encoder_2_4bit = T5EncoderModel.from_pretrained(
|
| 29 |
"black-forest-labs/FLUX.1-dev",
|
| 30 |
subfolder="text_encoder_2",
|
| 31 |
quantization_config=quant_config,
|
|
|
|
| 33 |
use_safetensors=True,
|
| 34 |
token=HF_TOKEN
|
| 35 |
)
|
| 36 |
+
# text_encoder_8bit = T5EncoderModel.from_pretrained(
|
| 37 |
+
# "black-forest-labs/FLUX.1-dev",
|
| 38 |
+
# subfolder="text_encoder_2",
|
| 39 |
+
# quantization_config=quant_config,
|
| 40 |
+
# torch_dtype=torch.bfloat16,
|
| 41 |
+
# use_safetensors=True,
|
| 42 |
+
# token=HF_TOKEN
|
| 43 |
+
# )
|
| 44 |
# Build pipeline
|
| 45 |
controlnet = FluxControlNetModel.from_pretrained(
|
| 46 |
"LPX55/FLUX.1-Inpainting-8step_uncensored",
|
|
|
|
| 59 |
# device_map="balanced",
|
| 60 |
token=HF_TOKEN
|
| 61 |
)
|
| 62 |
+
pipe.text_encoder_2 = text_encoder_2_4bit
|
| 63 |
|
| 64 |
# pipe.load_lora_weights(
|
| 65 |
# hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"), adapter_name="hyper-sd"
|