gokaygokay commited on
Commit
59463a5
·
1 Parent(s): bad81d8
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -3,7 +3,7 @@ import torch
3
  import gradio as gr
4
  import os
5
  from diffusers import FluxPipeline
6
- from transformers import T5EncoderModel
7
 
8
  # Initialize model outside the function
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -12,6 +12,13 @@ file_url = "https://huggingface.co/lodestones/Chroma/blob/main/chroma-unlocked-v
12
  huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
13
  single_file_base_model = "camenduru/FLUX.1-dev-diffusers"
14
 
 
 
 
 
 
 
 
15
 
16
  text_encoder_2 = T5EncoderModel.from_pretrained(
17
  single_file_base_model,
@@ -24,11 +31,10 @@ text_encoder_2 = T5EncoderModel.from_pretrained(
24
  # Load the pipeline with proper configuration
25
  flux_pipeline = FluxPipeline.from_single_file(
26
  file_url,
 
27
  text_encoder_2=text_encoder_2,
28
  torch_dtype=dtype,
29
- token=huggingface_token,
30
- use_safetensors=True,
31
- variant="fp16"
32
  )
33
  flux_pipeline.to(device)
34
 
 
3
  import gradio as gr
4
  import os
5
  from diffusers import FluxPipeline
6
+ from transformers import T5EncoderModel, CLIPTextModel
7
 
8
  # Initialize model outside the function
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
12
  huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
13
  single_file_base_model = "camenduru/FLUX.1-dev-diffusers"
14
 
15
+ # Initialize text encoders
16
+ text_encoder = CLIPTextModel.from_pretrained(
17
+ single_file_base_model,
18
+ subfolder="text_encoder",
19
+ torch_dtype=dtype,
20
+ token=huggingface_token
21
+ )
22
 
23
  text_encoder_2 = T5EncoderModel.from_pretrained(
24
  single_file_base_model,
 
31
  # Load the pipeline with proper configuration
32
  flux_pipeline = FluxPipeline.from_single_file(
33
  file_url,
34
+ text_encoder=text_encoder,
35
  text_encoder_2=text_encoder_2,
36
  torch_dtype=dtype,
37
+ token=huggingface_token
 
 
38
  )
39
  flux_pipeline.to(device)
40