1inkusFace commited on
Commit
7257f4c
·
verified ·
1 Parent(s): 02ab915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -118,7 +118,11 @@ def infer_30(
118
  torch.set_float32_matmul_precision("highest")
119
  seed = random.randint(0, MAX_SEED)
120
  generator = torch.Generator(device='cuda').manual_seed(seed)
121
- input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids.to(device)
 
 
 
 
122
  print('-- generating image --')
123
  sd_image = pipe(
124
  prompt_embeds = pipe.text_encoder(input_ids)[0], #ensure that the input_ids are on the correct device.
@@ -170,7 +174,11 @@ def infer_60(
170
  torch.set_float32_matmul_precision("highest")
171
  seed = random.randint(0, MAX_SEED)
172
  generator = torch.Generator(device='cuda').manual_seed(seed)
173
- input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids.to(device)
 
 
 
 
174
  print('-- generating image --')
175
  sd_image = pipe(
176
  prompt_embeds = pipe.text_encoder(input_ids)[0], #ensure that the input_ids are on the correct device.
@@ -222,7 +230,11 @@ def infer_90(
222
  torch.set_float32_matmul_precision("highest")
223
  seed = random.randint(0, MAX_SEED)
224
  generator = torch.Generator(device='cuda').manual_seed(seed)
225
- input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids.to(device)
 
 
 
 
226
  print('-- generating image --')
227
  sd_image = pipe(
228
  prompt_embeds = pipe.text_encoder(input_ids)[0], #ensure that the input_ids are on the correct device.
 
118
  torch.set_float32_matmul_precision("highest")
119
  seed = random.randint(0, MAX_SEED)
120
  generator = torch.Generator(device='cuda').manual_seed(seed)
121
+ input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids
122
+ max_length = 77
123
+ if input_ids.shape[1] > max_length:
124
+ input_ids = input_ids[:, :max_length]
125
+ input_ids = input_ids.to(device)
126
  print('-- generating image --')
127
  sd_image = pipe(
128
  prompt_embeds = pipe.text_encoder(input_ids)[0], #ensure that the input_ids are on the correct device.
 
174
  torch.set_float32_matmul_precision("highest")
175
  seed = random.randint(0, MAX_SEED)
176
  generator = torch.Generator(device='cuda').manual_seed(seed)
177
+ input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids
178
+ max_length = 77
179
+ if input_ids.shape[1] > max_length:
180
+ input_ids = input_ids[:, :max_length]
181
+ input_ids = input_ids.to(device)
182
  print('-- generating image --')
183
  sd_image = pipe(
184
  prompt_embeds = pipe.text_encoder(input_ids)[0], #ensure that the input_ids are on the correct device.
 
230
  torch.set_float32_matmul_precision("highest")
231
  seed = random.randint(0, MAX_SEED)
232
  generator = torch.Generator(device='cuda').manual_seed(seed)
233
+ input_ids = pipe.tokenizer(prompt, return_tensors="pt").input_ids
234
+ max_length = 77
235
+ if input_ids.shape[1] > max_length:
236
+ input_ids = input_ids[:, :max_length]
237
+ input_ids = input_ids.to(device)
238
  print('-- generating image --')
239
  sd_image = pipe(
240
  prompt_embeds = pipe.text_encoder(input_ids)[0], #ensure that the input_ids are on the correct device.