Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -80,7 +80,7 @@ text_encoder = CLIPTextModel.from_pretrained("SG161222/Realistic_Vision_V4.0_noV
|
|
80 |
image_encoder = CLIPVisionModelWithProjection.from_pretrained("h94/IP-Adapter", subfolder="models/image_encoder").to(dtype=torch.float16, device=args.device)
|
81 |
unet = UNet2DConditionModel.from_pretrained("SG161222/Realistic_Vision_V4.0_noVAE", subfolder="unet").to(dtype=torch.float16,device=args.device)
|
82 |
|
83 |
-
|
84 |
|
85 |
#face_model
|
86 |
app = FaceAnalysis(model_path="buffalo_l", providers=[('CUDAExecutionProvider', {"device_id": args.device})]) ##使用GPU:0, 默认使用buffalo_l就可以了
|
@@ -278,18 +278,18 @@ def dress_process(garm_img, face_img, pose_img, prompt, cloth_guidance_scale, ca
|
|
278 |
num_inference_steps=denoise_steps,
|
279 |
).images
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
return output[0]
|
291 |
|
292 |
-
|
293 |
example_path = os.path.join(os.path.dirname(__file__), 'example')
|
294 |
|
295 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
|
|
80 |
image_encoder = CLIPVisionModelWithProjection.from_pretrained("h94/IP-Adapter", subfolder="models/image_encoder").to(dtype=torch.float16, device=args.device)
|
81 |
unet = UNet2DConditionModel.from_pretrained("SG161222/Realistic_Vision_V4.0_noVAE", subfolder="unet").to(dtype=torch.float16,device=args.device)
|
82 |
|
83 |
+
image_face_fusion = pipeline('face_fusion_torch', model='damo/cv_unet_face_fusion_torch', model_revision='v1.0.3')
|
84 |
|
85 |
#face_model
|
86 |
app = FaceAnalysis(model_path="buffalo_l", providers=[('CUDAExecutionProvider', {"device_id": args.device})]) ##使用GPU:0, 默认使用buffalo_l就可以了
|
|
|
278 |
num_inference_steps=denoise_steps,
|
279 |
).images
|
280 |
|
281 |
+
if if_post and if_ipa:
|
282 |
+
# 将 PIL 图像转换为 NumPy 数组
|
283 |
+
output_array = np.array(output[0])
|
284 |
+
# 将 RGB 图像转换为 BGR 图像
|
285 |
+
bgr_array = cv2.cvtColor(output_array, cv2.COLOR_RGB2BGR)
|
286 |
+
# 将 NumPy 数组转换为 PIL 图像
|
287 |
+
bgr_image = Image.fromarray(bgr_array)
|
288 |
+
result = image_face_fusion(dict(template=bgr_image, user=Image.fromarray(face_image.astype('uint8'))))
|
289 |
+
return result[OutputKeys.OUTPUT_IMG]
|
290 |
return output[0]
|
291 |
|
292 |
+
|
293 |
example_path = os.path.join(os.path.dirname(__file__), 'example')
|
294 |
|
295 |
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|