BryanW commited on
Commit
04a2751
1 Parent(s): 363cb08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -17,14 +17,17 @@ import spaces
17
 
18
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
19
 
 
 
20
  model_path = "MeissonFlow/Meissonic"
21
- model = Transformer2DModel.from_pretrained(model_path, subfolder="transformer")
22
- vq_model = VQModel.from_pretrained(model_path, subfolder="vqvae")
23
- # text_encoder = CLIPTextModelWithProjection.from_pretrained(model_path, subfolder="text_encoder")
24
- text_encoder = CLIPTextModelWithProjection.from_pretrained( #more stable sampling for some cases
25
  "laion/CLIP-ViT-H-14-laion2B-s32B-b79K"
26
- )
27
- tokenizer = CLIPTokenizer.from_pretrained(model_path, subfolder="tokenizer")
 
28
  scheduler = Scheduler.from_pretrained(model_path, subfolder="scheduler")
29
  pipe = Pipeline(vq_model, tokenizer=tokenizer, text_encoder=text_encoder, transformer=model, scheduler=scheduler)
30
  pipe.to(device)
 
17
 
18
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
19
 
20
+
21
+ dtype = torch.bfloat16
22
  model_path = "MeissonFlow/Meissonic"
23
+ model = Transformer2DModel.from_pretrained(model_path, subfolder="transformer", torch_dtype=dtype)
24
+ vq_model = VQModel.from_pretrained(model_path, subfolder="vqvae", torch_dtype=dtype)
25
+ # text_encoder = CLIPTextModelWithProjection.from_pretrained(model_path,subfolder="text_encoder", torch_dtype=dtype)
26
+ text_encoder = CLIPTextModelWithProjection.from_pretrained( #using original text enc for stable sampling
27
  "laion/CLIP-ViT-H-14-laion2B-s32B-b79K"
28
+ torch_dtype=dtype
29
+ )
30
+ tokenizer = CLIPTokenizer.from_pretrained(model_path, subfolder="tokenizer", torch_dtype=dtype)
31
  scheduler = Scheduler.from_pretrained(model_path, subfolder="scheduler")
32
  pipe = Pipeline(vq_model, tokenizer=tokenizer, text_encoder=text_encoder, transformer=model, scheduler=scheduler)
33
  pipe.to(device)