| 383 | return True |
| 384 | |
| 385 | def get_editing_prompts(self, tpl_pose_metas, refer_pose_meta): |
| 386 | arm_visible = False |
| 387 | leg_visible = False |
| 388 | for tpl_pose_meta in tpl_pose_metas: |
| 389 | tpl_keypoints = tpl_pose_meta["keypoints_body"] |
| 390 | if tpl_keypoints[3].all() != 0 or tpl_keypoints[4].all() != 0 or tpl_keypoints[6].all() != 0 or tpl_keypoints[7].all() != 0: |
| 391 | if ( |
| 392 | (tpl_keypoints[3][0] <= 1 and tpl_keypoints[3][1] <= 1 and tpl_keypoints[3][2] >= 0.75) |
| 393 | or (tpl_keypoints[4][0] <= 1 and tpl_keypoints[4][1] <= 1 and tpl_keypoints[4][2] >= 0.75) |
| 394 | or (tpl_keypoints[6][0] <= 1 and tpl_keypoints[6][1] <= 1 and tpl_keypoints[6][2] >= 0.75) |
| 395 | or (tpl_keypoints[7][0] <= 1 and tpl_keypoints[7][1] <= 1 and tpl_keypoints[7][2] >= 0.75) |
| 396 | ): |
| 397 | arm_visible = True |
| 398 | if tpl_keypoints[9].all() != 0 or tpl_keypoints[12].all() != 0 or tpl_keypoints[10].all() != 0 or tpl_keypoints[13].all() != 0: |
| 399 | if ( |
| 400 | (tpl_keypoints[9][0] <= 1 and tpl_keypoints[9][1] <= 1 and tpl_keypoints[9][2] >= 0.75) |
| 401 | or (tpl_keypoints[12][0] <= 1 and tpl_keypoints[12][1] <= 1 and tpl_keypoints[12][2] >= 0.75) |
| 402 | or (tpl_keypoints[10][0] <= 1 and tpl_keypoints[10][1] <= 1 and tpl_keypoints[10][2] >= 0.75) |
| 403 | or (tpl_keypoints[13][0] <= 1 and tpl_keypoints[13][1] <= 1 and tpl_keypoints[13][2] >= 0.75) |
| 404 | ): |
| 405 | leg_visible = True |
| 406 | if arm_visible and leg_visible: |
| 407 | break |
| 408 | |
| 409 | if leg_visible: |
| 410 | if tpl_pose_meta["width"] > tpl_pose_meta["height"]: |
| 411 | tpl_prompt = "Change the person to a standard T-pose (facing forward with arms extended). The person is standing. Feet and Hands are visible in the image." |
| 412 | else: |
| 413 | tpl_prompt = "Change the person to a standard pose with the face oriented forward and arms extending straight down by the sides. The person is standing. Feet and Hands are visible in the image." |
| 414 | |
| 415 | if refer_pose_meta["width"] > refer_pose_meta["height"]: |
| 416 | refer_prompt = "Change the person to a standard T-pose (facing forward with arms extended). The person is standing. Feet and Hands are visible in the image." |
| 417 | else: |
| 418 | refer_prompt = "Change the person to a standard pose with the face oriented forward and arms extending straight down by the sides. The person is standing. Feet and Hands are visible in the image." |
| 419 | elif arm_visible: |
| 420 | if tpl_pose_meta["width"] > tpl_pose_meta["height"]: |
| 421 | tpl_prompt = "Change the person to a standard T-pose (facing forward with arms extended). Hands are visible in the image." |
| 422 | else: |
| 423 | tpl_prompt = "Change the person to a standard pose with the face oriented forward and arms extending straight down by the sides. Hands are visible in the image." |
| 424 | |
| 425 | if refer_pose_meta["width"] > refer_pose_meta["height"]: |
| 426 | refer_prompt = "Change the person to a standard T-pose (facing forward with arms extended). Hands are visible in the image." |
| 427 | else: |
| 428 | refer_prompt = "Change the person to a standard pose with the face oriented forward and arms extending straight down by the sides. Hands are visible in the image." |
| 429 | else: |
| 430 | tpl_prompt = "Change the person to face forward." |
| 431 | refer_prompt = "Change the person to face forward." |
| 432 | |
| 433 | return tpl_prompt, refer_prompt |
| 434 | |
| 435 | def get_mask(self, frames, th_step, kp2ds_all, use_valid_body_keypoints=True): |
| 436 | frame_num = len(frames) |