MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / inference

Method inference

datasets/INFERENCE.py:107–285  ·  view source on GitHub ↗
(self, outs)

Source from the content-addressed store, hash-verified

105 return result
106
107 def inference(self, outs):
108 img_paths = self.img_paths
109 sample_num = len(outs)
110 output = {}
111
112 for out in outs:
113 ann_idx = out['image_idx']
114 img_cropped = mmcv.imdenormalize(
115 img=(out['img'].cpu().numpy()).transpose(1, 2, 0),
116 mean=np.array([123.675, 116.28, 103.53]),
117 std=np.array([58.395, 57.12, 57.375]),
118 to_bgr=True).astype(np.uint8)
119 # bb2img_trans = out['bb2img_trans']
120 # img2bb_trans = out['img2bb_trans']
121 scores = out['scores'].clone().cpu().numpy()
122 img_shape = out['img_shape'].cpu().numpy()[::-1] # w, h
123 width,height = img_shape
124 width += width % 2
125 height += height % 2
126 img_shape = np.array([width, height])
127 img = cv2.imread(img_paths[ann_idx]) # h, w
128
129
130 joint_proj = out['smplx_joint_proj'].clone().cpu().numpy()
131 joint_vis = out['smplx_joint_proj'].clone().cpu().numpy()
132 joint_coco = out['keypoints_coco'].clone().cpu().numpy()
133 joint_coco_raw = joint_coco.copy()
134 smpl_kp3d_coco, _ = convert_kps(out['smpl_kp3d'].clone().cpu().numpy(),src='smplx',dst='coco', approximate=True)
135
136
137
138 body_bbox = out['body_bbox'].clone().cpu().numpy()
139 lhand_bbox = out['lhand_bbox'].clone().cpu().numpy()
140 rhand_bbox = out['rhand_bbox'].clone().cpu().numpy()
141 face_bbox = out['face_bbox'].clone().cpu().numpy()
142
143 if self.resolution == [720, 1280]:
144 joint_proj[:, :, 0] = joint_proj[:, :, 0] / img_shape[0] * 3840
145 joint_proj[:, :, 1] = joint_proj[:, :, 1] / img_shape[1] * 2160
146 joint_vis[:, :, 0] = joint_vis[:, :, 0] / img_shape[0] * img.shape[1]
147 joint_vis[:, :, 1] = joint_vis[:, :, 1]/ img_shape[1] * img.shape[0]
148
149 joint_coco[:, :, 0] = joint_coco[:, :, 0] / img_shape[0] * img.shape[1]
150 joint_coco[:, :, 1] = joint_coco[:, :, 1]/ img_shape[1] * img.shape[0]
151 scale = np.array([
152 img.shape[1]/img_shape[0],
153 img.shape[1]/img_shape[0],
154 img.shape[1]/img_shape[0],
155 img.shape[1]/img_shape[0],
156 ])
157 body_bbox_raw = body_bbox.copy()
158 body_bbox = body_bbox * scale
159 lhand_bbox = lhand_bbox * scale
160 rhand_bbox = rhand_bbox * scale
161 face_bbox = face_bbox * scale
162 elif self.resolution == [1200, 1600]:
163
164 joint_proj[:, :, 0] = joint_proj[:, :, 0] * (1200 / 800)

Callers 1

inferenceFunction · 0.45

Calls 9

convert_kpsFunction · 0.90
xyxy2xywhFunction · 0.90
build_body_modelFunction · 0.90
render_smplFunction · 0.90
cloneMethod · 0.80
copyMethod · 0.80
dumpMethod · 0.45
updateMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected