Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
babf748
1
Parent(s):
6f75c6d
chroma
Browse files
app.py
CHANGED
@@ -1,21 +1,14 @@
|
|
1 |
import spaces
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
-
from diffusers import
|
5 |
-
from transformers import T5EncoderModel, BitsAndBytesConfig as BitsAndBytesConfigTF
|
6 |
|
7 |
# Initialize model outside the function
|
8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
9 |
dtype = torch.bfloat16
|
10 |
file_url = "https://huggingface.co/lodestones/Chroma/resolve/main/chroma-unlocked-v31.safetensors"
|
11 |
|
12 |
-
|
13 |
-
text_encoder_2 = T5EncoderModel.from_single_file(file_url, subfolder="text_encoder_2", torch_dtype=dtype, quantization_config=quantization_config_tf)
|
14 |
-
|
15 |
-
quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.bfloat16)
|
16 |
-
transformer = FluxTransformer2DModel.from_single_file(file_url, subfolder="transformer", torch_dtype=dtype, quantization_config=quantization_config)
|
17 |
-
|
18 |
-
flux_pipeline = FluxPipeline.from_single_file(file_url, transformer=transformer, text_encoder_2=text_encoder_2, torch_dtype=dtype)
|
19 |
flux_pipeline.to(device)
|
20 |
|
21 |
@spaces.GPU()
|
|
|
1 |
import spaces
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
+
from diffusers import FluxPipeline
|
|
|
5 |
|
6 |
# Initialize model outside the function
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
dtype = torch.bfloat16
|
9 |
file_url = "https://huggingface.co/lodestones/Chroma/resolve/main/chroma-unlocked-v31.safetensors"
|
10 |
|
11 |
+
flux_pipeline = FluxPipeline.from_single_file(file_url, torch_dtype=dtype)
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
flux_pipeline.to(device)
|
13 |
|
14 |
@spaces.GPU()
|