rajveeritme commited on
Commit
8961a38
1 Parent(s): 1747fbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -6,13 +6,19 @@ import torch
6
  from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, AutoencoderTiny, AutoencoderKL
7
  from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
8
  from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
 
 
 
 
9
 
10
  dtype = torch.bfloat16
 
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
12
 
13
  taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
14
- good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=dtype).to(device)
15
- pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=dtype, vae=taef1).to(device)
16
  torch.cuda.empty_cache()
17
 
18
  MAX_SEED = np.iinfo(np.int32).max
 
6
  from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, AutoencoderTiny, AutoencoderKL
7
  from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
8
  from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
9
+ import os # Import os module to access environment variables
10
+
11
+ # Retrieve the token from the environment variable
12
+ hf_token = os.environ.get("HF_API_TOKEN")
13
 
14
  dtype = torch.bfloat16
15
+
16
  device = "cuda" if torch.cuda.is_available() else "cpu"
17
+
18
 
19
  taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
20
+ good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=dtype, token=hf_token).to(device)
21
+ pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=dtype, vae=taef1, token=hf_token).to(device)
22
  torch.cuda.empty_cache()
23
 
24
  MAX_SEED = np.iinfo(np.int32).max