jbilcke-hf HF staff commited on
Commit
7c58fd1
β€’
1 Parent(s): 0f55d81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -262,15 +262,12 @@ def generate_image(prompt, negative, face_emb, face_image, face_kps, image_stren
262
  text_embedding_name = lora["text_embedding_weights"]
263
  embedding_path = hf_hub_download(repo_id=lora["repo"], filename=text_embedding_name, repo_type="model")
264
  state_dict_embedding = load_file(embedding_path)
265
- try:
266
- pipe.unload_textual_inversion()
267
- pipe.load_textual_inversion(state_dict_embedding["clip_l"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder, tokenizer=pipe.tokenizer)
268
- pipe.load_textual_inversion(state_dict_embedding["clip_g"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder_2, tokenizer=pipe.tokenizer_2)
269
- except:
270
- pipe.unload_textual_inversion()
271
- pipe.load_textual_inversion(state_dict_embedding["text_encoders_0"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder, tokenizer=pipe.tokenizer)
272
- pipe.load_textual_inversion(state_dict_embedding["text_encoders_1"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder_2, tokenizer=pipe.tokenizer_2)
273
 
 
 
 
274
  print("Processing prompt...")
275
  st = time.time()
276
  conditioning, pooled = compel(prompt)
 
262
  text_embedding_name = lora["text_embedding_weights"]
263
  embedding_path = hf_hub_download(repo_id=lora["repo"], filename=text_embedding_name, repo_type="model")
264
  state_dict_embedding = load_file(embedding_path)
265
+ pipe.load_textual_inversion(state_dict_embedding["clip_l" if "clip_l" in state_dict_embedding else "text_encoders_0"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder, tokenizer=pipe.tokenizer)
266
+ pipe.load_textual_inversion(state_dict_embedding["clip_g" if "clip_g" in state_dict_embedding else "text_encoders_1"], token=["<s0>", "<s1>"], text_encoder=pipe.text_encoder_2, tokenizer=pipe.tokenizer_2)
 
 
 
 
 
 
267
 
268
+ print("Processing prompt...")
269
+ st = time.time()
270
+ conditioning, pooled = compel(prompt)
271
  print("Processing prompt...")
272
  st = time.time()
273
  conditioning, pooled = compel(prompt)