multimodalart HF staff commited on
Commit
81b26b5
1 Parent(s): c29fb74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -22
app.py CHANGED
@@ -3,32 +3,12 @@ import numpy as np
3
  import random
4
  import spaces
5
  import torch
6
- from diffusers import FluxPipeline, FluxTransformer2DModel,FlowMatchEulerDiscreteScheduler, AutoencoderKL
7
- from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
8
 
9
  dtype = torch.bfloat16
10
- device = "cuda"
11
-
12
- bfl_repo = "black-forest-labs/FLUX.1-schnell"
13
- scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained(bfl_repo, subfolder="scheduler", revision="refs/pr/1")
14
- text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=dtype)
15
- tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14", torch_dtype=dtype)
16
- text_encoder_2 = T5EncoderModel.from_pretrained(bfl_repo, subfolder="text_encoder_2", torch_dtype=dtype, revision="refs/pr/1")
17
- tokenizer_2 = T5TokenizerFast.from_pretrained(bfl_repo, subfolder="tokenizer_2", torch_dtype=dtype, revision="refs/pr/1")
18
- vae = AutoencoderKL.from_pretrained(bfl_repo, subfolder="vae", torch_dtype=dtype, revision="refs/pr/1")
19
- transformer = FluxTransformer2DModel.from_pretrained(bfl_repo, subfolder="transformer", torch_dtype=dtype, revision="refs/pr/1")
20
-
21
  device = "cuda" if torch.cuda.is_available() else "cpu"
22
 
23
- pipe = FluxPipeline(
24
- scheduler=scheduler,
25
- text_encoder=text_encoder,
26
- tokenizer=tokenizer,
27
- text_encoder_2=text_encoder_2,
28
- tokenizer_2=tokenizer_2,
29
- vae=vae,
30
- transformer=transformer,
31
- ).to("cuda")
32
 
33
  MAX_SEED = np.iinfo(np.int32).max
34
  MAX_IMAGE_SIZE = 2048
 
3
  import random
4
  import spaces
5
  import torch
6
+ from diffusers import DiffusionPipeline
 
7
 
8
  dtype = torch.bfloat16
 
 
 
 
 
 
 
 
 
 
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
 
11
+ pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, revision="refs/pr/1").to(device)
 
 
 
 
 
 
 
 
12
 
13
  MAX_SEED = np.iinfo(np.int32).max
14
  MAX_IMAGE_SIZE = 2048