AlekseyCalvin commited on
Commit
7e1b760
1 Parent(s): 96a8ce2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -6,7 +6,10 @@ import torch
6
  from PIL import Image
7
  from os import path
8
  import spaces
9
- from diffusers import DiffusionPipeline, AutoencoderTiny, AutoencoderKL, FlowMatchEulerDiscreteScheduler,
 
 
 
10
  import copy
11
  import random
12
  import time
@@ -44,6 +47,23 @@ torch_dtype=torch.bfloat16,
44
  trust_remote_code=True,
45
  ).to(device)
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  MAX_SEED = 2**32-1
48
 
49
  class calculateDuration:
 
6
  from PIL import Image
7
  from os import path
8
  import spaces
9
+ from diffusers import DiffusionPipeline, AutoencoderTiny, AutoencoderKL
10
+ from diffusers.models.transformers import FluxTransformer2DModel
11
+ from diffusers.schedulers import FlowMatchEulerDiscreteScheduler
12
+ from transformers import CLIPModel, CLIPProcessor, CLIPTextModel, CLIPTokenizer, CLIPConfig, T5EncoderModel, T5Tokenizer
13
  import copy
14
  import random
15
  import time
 
47
  trust_remote_code=True,
48
  ).to(device)
49
 
50
+ clipmodel = 'norm'
51
+ if clipmodel == "long":
52
+ model_id = "zer0int/LongCLIP-GmP-ViT-L-14"
53
+ config = CLIPConfig.from_pretrained(model_id)
54
+ maxtokens = 248
55
+ if clipmodel == "norm":
56
+ model_id = "zer0int/CLIP-GmP-ViT-L-14"
57
+ config = CLIPConfig.from_pretrained(model_id)
58
+ maxtokens = 77
59
+ clip_model = CLIPModel.from_pretrained(model_id, torch_dtype=torch.bfloat16, config=config, ignore_mismatched_sizes=True).to("cuda")
60
+ clip_processor = CLIPProcessor.from_pretrained(model_id, padding="max_length", max_length=maxtokens, ignore_mismatched_sizes=True, return_tensors="pt", truncation=True)
61
+
62
+ pipe.tokenizer = clip_processor.tokenizer
63
+ pipe.text_encoder = clip_model.text_model
64
+ pipe.tokenizer_max_length = maxtokens
65
+ pipe.text_encoder.dtype = torch.bfloat16
66
+
67
  MAX_SEED = 2**32-1
68
 
69
  class calculateDuration: