adaface-neurips commited on
Commit
b402b3c
1 Parent(s): 604320a

remove breakpoint

Browse files
Files changed (2) hide show
  1. adaface/util.py +9 -9
  2. requirements.txt +1 -0
adaface/util.py CHANGED
@@ -284,14 +284,14 @@ def get_arc2face_id_prompt_embs(face_app, clip_tokenizer, arc2face_text_encoder,
284
  print(f"Extracted ID embeddings from {image_count} images")
285
 
286
  if len(faceid_embeds) == 0:
287
- print("No face detected")
288
- breakpoint()
289
-
290
- # faceid_embeds: [10, 512]
291
- faceid_embeds = torch.cat(faceid_embeds, dim=0)
292
- # faceid_embeds: [10, 512] -> [1, 512].
293
- # and the resulted prompt embeddings are the same.
294
- faceid_embeds = faceid_embeds.mean(dim=0, keepdim=True).to(torch.float16).to(device)
295
  else:
296
  # Random face embeddings. faceid_embeds: [BS, 512].
297
  if pre_face_embs is None:
@@ -301,7 +301,7 @@ def get_arc2face_id_prompt_embs(face_app, clip_tokenizer, arc2face_text_encoder,
301
  if pre_face_embs.shape[0] == 1:
302
  faceid_embeds = faceid_embeds.repeat(id_batch_size, 1)
303
 
304
- faceid_embeds = faceid_embeds.to(torch.float16).to(device)
305
 
306
  if noise_level > 0:
307
  # If id_batch_size > 1, after adding noises, the id_batch_size embeddings will be different.
 
284
  print(f"Extracted ID embeddings from {image_count} images")
285
 
286
  if len(faceid_embeds) == 0:
287
+ print("No face detected. Use a random face instead.")
288
+ faceid_embeds = torch.randn(id_batch_size, 512).to(device=device, dtype=torch.float16)
289
+ else:
290
+ # faceid_embeds: [10, 512]
291
+ faceid_embeds = torch.cat(faceid_embeds, dim=0)
292
+ # faceid_embeds: [10, 512] -> [1, 512].
293
+ # and the resulted prompt embeddings are the same.
294
+ faceid_embeds = faceid_embeds.mean(dim=0, keepdim=True).to(device=device, dtype=torch.float16)
295
  else:
296
  # Random face embeddings. faceid_embeds: [BS, 512].
297
  if pre_face_embs is None:
 
301
  if pre_face_embs.shape[0] == 1:
302
  faceid_embeds = faceid_embeds.repeat(id_batch_size, 1)
303
 
304
+ faceid_embeds = faceid_embeds.to(device=device, dtype=torch.float16)
305
 
306
  if noise_level > 0:
307
  # If id_batch_size > 1, after adding noises, the id_batch_size embeddings will be different.
requirements.txt CHANGED
@@ -13,3 +13,4 @@ opencv-python
13
  diffusers
14
  onnx>=1.16.0
15
  onnxruntime
 
 
13
  diffusers
14
  onnx>=1.16.0
15
  onnxruntime
16
+ safetensors