adaface-neurips commited on
Commit
abaeb15
1 Parent(s): 13d8b07

fix None prompt bug

Browse files
Files changed (2) hide show
  1. adaface/adaface_wrapper.py +3 -0
  2. app.py +4 -1
adaface/adaface_wrapper.py CHANGED
@@ -190,6 +190,9 @@ class AdaFaceWrapper(nn.Module):
190
  print(f"Updated {len(self.placeholder_token_ids)} tokens ({self.placeholder_tokens_str}) in the text encoder.")
191
 
192
  def update_prompt(self, prompt):
 
 
 
193
  # If the placeholder tokens are already in the prompt, then return the prompt as is.
194
  if self.placeholder_tokens_str in prompt:
195
  return prompt
 
190
  print(f"Updated {len(self.placeholder_token_ids)} tokens ({self.placeholder_tokens_str}) in the text encoder.")
191
 
192
  def update_prompt(self, prompt):
193
+ if prompt is None:
194
+ prompt = ""
195
+
196
  # If the placeholder tokens are already in the prompt, then return the prompt as is.
197
  if self.placeholder_tokens_str in prompt:
198
  return prompt
app.py CHANGED
@@ -109,6 +109,9 @@ def generate_image(image_container, uploaded_image_paths, init_img_file_paths, i
109
  is_adaface_enabled, adaface_ckpt_path, adaface_id_cfg_scale, adaface_power_scale,
110
  adaface_anneal_steps, progress=gr.Progress(track_tqdm=True)):
111
 
 
 
 
112
  prompt = prompt + " 8k uhd, high quality"
113
  if " shot" not in prompt:
114
  prompt = prompt + ", medium shot"
@@ -135,7 +138,7 @@ def generate_image(image_container, uploaded_image_paths, init_img_file_paths, i
135
  adaface.generate_adaface_embeddings(image_folder=None, image_paths=uploaded_image_paths,
136
  out_id_embs_scale=adaface_id_cfg_scale, update_text_encoder=True)
137
  # adaface_prompt_embeds: [1, 77, 768].
138
- adaface_prompt_embeds, _ = adaface.encode_prompt(prompt)
139
 
140
  # init_img_file_paths is a list of image paths. If not chose, init_img_file_paths is None.
141
  if init_img_file_paths is not None:
 
109
  is_adaface_enabled, adaface_ckpt_path, adaface_id_cfg_scale, adaface_power_scale,
110
  adaface_anneal_steps, progress=gr.Progress(track_tqdm=True)):
111
 
112
+ if prompt is None:
113
+ prompt = ""
114
+
115
  prompt = prompt + " 8k uhd, high quality"
116
  if " shot" not in prompt:
117
  prompt = prompt + ", medium shot"
 
138
  adaface.generate_adaface_embeddings(image_folder=None, image_paths=uploaded_image_paths,
139
  out_id_embs_scale=adaface_id_cfg_scale, update_text_encoder=True)
140
  # adaface_prompt_embeds: [1, 77, 768].
141
+ adaface_prompt_embeds, _ = adaface.encode_prompt(prompt, verbose=True)
142
 
143
  # init_img_file_paths is a list of image paths. If not chose, init_img_file_paths is None.
144
  if init_img_file_paths is not None: