Spaces:
Running
on
Zero
Running
on
Zero
Update pipline_StableDiffusionXL_ConsistentID.py
Browse files
pipline_StableDiffusionXL_ConsistentID.py
CHANGED
@@ -261,15 +261,16 @@ class ConsistentIDStableDiffusionXLPipeline(StableDiffusionXLPipeline):
|
|
261 |
attn_processor.scale = scale
|
262 |
|
263 |
@torch.inference_mode()
|
264 |
-
def get_prepare_faceid(self, input_image_path=None):
|
265 |
-
faceid_image = cv2.imread(input_image_path)
|
|
|
266 |
face_info = self.app.get(faceid_image)
|
267 |
if face_info==[]:
|
268 |
faceid_embeds = torch.zeros_like(torch.empty((1, 512)))
|
269 |
else:
|
270 |
faceid_embeds = torch.from_numpy(face_info[0].normed_embedding).unsqueeze(0)
|
271 |
|
272 |
-
|
273 |
return faceid_embeds
|
274 |
|
275 |
@torch.inference_mode()
|
@@ -507,7 +508,7 @@ class ConsistentIDStableDiffusionXLPipeline(StableDiffusionXLPipeline):
|
|
507 |
do_classifier_free_guidance = guidance_scale >= 1.0
|
508 |
input_image_file = input_id_images[0]
|
509 |
|
510 |
-
faceid_embeds = self.get_prepare_faceid(input_image_path=input_image_path)
|
511 |
face_caption = self.get_prepare_llva_caption(input_image_file=input_image_file)
|
512 |
key_parsing_mask_list, vis_parsing_anno_color = self.get_prepare_facemask(input_image_file)
|
513 |
|
|
|
261 |
attn_processor.scale = scale
|
262 |
|
263 |
@torch.inference_mode()
|
264 |
+
def get_prepare_faceid(self,input_image_file=None, input_image_path=None):
|
265 |
+
# faceid_image = cv2.imread(input_image_path) ### path may error
|
266 |
+
faceid_image = cv2.cvtColor(np.array(input_image_file), cv2.COLOR_RGB2BGR)
|
267 |
face_info = self.app.get(faceid_image)
|
268 |
if face_info==[]:
|
269 |
faceid_embeds = torch.zeros_like(torch.empty((1, 512)))
|
270 |
else:
|
271 |
faceid_embeds = torch.from_numpy(face_info[0].normed_embedding).unsqueeze(0)
|
272 |
|
273 |
+
print(f" ========== faceid_embeds is : {faceid_embeds} ==========\r\n")
|
274 |
return faceid_embeds
|
275 |
|
276 |
@torch.inference_mode()
|
|
|
508 |
do_classifier_free_guidance = guidance_scale >= 1.0
|
509 |
input_image_file = input_id_images[0]
|
510 |
|
511 |
+
faceid_embeds = self.get_prepare_faceid(input_image_file=input_image_file, input_image_path=input_image_path)
|
512 |
face_caption = self.get_prepare_llva_caption(input_image_file=input_image_file)
|
513 |
key_parsing_mask_list, vis_parsing_anno_color = self.get_prepare_facemask(input_image_file)
|
514 |
|