image_shape(target_sizes): input image shape
(self, outputs, target_sizes, targets, data_batch_nc, image_shape= None, not_to_xyxy=False, test=False)
| 1548 | |
| 1549 | @torch.no_grad() |
| 1550 | def forward(self, outputs, target_sizes, targets, data_batch_nc, image_shape= None, not_to_xyxy=False, test=False): |
| 1551 | """ |
| 1552 | image_shape(target_sizes): input image shape |
| 1553 | |
| 1554 | """ |
| 1555 | |
| 1556 | batch_size = outputs['pred_smpl_beta'].shape[0] |
| 1557 | results = [] |
| 1558 | device = outputs['pred_smpl_beta'].device |
| 1559 | |
| 1560 | num_select = self.num_select |
| 1561 | out_logits, out_bbox= outputs['pred_logits'], outputs['pred_boxes'] |
| 1562 | |
| 1563 | out_body_bbox, out_lhand_bbox, out_rhand_bbox, out_face_bbox = \ |
| 1564 | outputs['pred_boxes'], outputs['pred_lhand_boxes'], \ |
| 1565 | outputs['pred_rhand_boxes'], outputs['pred_face_boxes'] |
| 1566 | |
| 1567 | out_smpl_pose, out_smpl_beta, out_smpl_expr, out_smpl_cam, out_smpl_kp3d, out_smpl_verts = \ |
| 1568 | outputs['pred_smpl_fullpose'], outputs['pred_smpl_beta'], outputs['pred_smpl_expr'], \ |
| 1569 | outputs['pred_smpl_cam'], outputs['pred_smpl_kp3d'], outputs['pred_smpl_verts'] |
| 1570 | |
| 1571 | out_smpl_kp2d = [] |
| 1572 | for bs in range(batch_size): |
| 1573 | out_kp3d_i = out_smpl_kp3d[bs] |
| 1574 | out_cam_i = out_smpl_cam[bs] |
| 1575 | out_img_shape = data_batch_nc['img_shape'][bs].flip(-1)[None] |
| 1576 | |
| 1577 | out_kp2d_i = project_points_new( |
| 1578 | points_3d=out_kp3d_i, |
| 1579 | pred_cam=out_cam_i, |
| 1580 | focal_length=5000, |
| 1581 | camera_center=out_img_shape/2 |
| 1582 | ) |
| 1583 | out_smpl_kp2d.append(out_kp2d_i.detach().cpu().numpy()) |
| 1584 | out_smpl_kp2d = torch.tensor(out_smpl_kp2d).to(device) |
| 1585 | |
| 1586 | |
| 1587 | prob = out_logits.sigmoid() |
| 1588 | topk_values, topk_indexes = \ |
| 1589 | torch.topk(prob.view(out_logits.shape[0], -1), num_select, dim=1) |
| 1590 | scores = topk_values |
| 1591 | |
| 1592 | # bbox |
| 1593 | topk_boxes = topk_indexes // out_logits.shape[2] |
| 1594 | labels = topk_indexes % out_logits.shape[2] |
| 1595 | |
| 1596 | if not_to_xyxy: |
| 1597 | boxes = out_bbox |
| 1598 | else: |
| 1599 | boxes = box_ops.box_cxcywh_to_xyxy(out_bbox) |
| 1600 | out_body_bbox = box_ops.box_cxcywh_to_xyxy(out_body_bbox) |
| 1601 | out_lhand_bbox = box_ops.box_cxcywh_to_xyxy(out_lhand_bbox) |
| 1602 | out_rhand_bbox = box_ops.box_cxcywh_to_xyxy(out_rhand_bbox) |
| 1603 | out_face_bbox = box_ops.box_cxcywh_to_xyxy(out_face_bbox) |
| 1604 | |
| 1605 | # gather body bbox |
| 1606 | target_sizes = target_sizes.type_as(boxes) |
| 1607 | img_h, img_w = target_sizes.unbind(1) |
nothing calls this directly
no test coverage detected