extract face texture from given cropped face image
(self, opdict, images)
| 156 | opdict['texture'] = uv_texture |
| 157 | |
| 158 | def extract_texture(self, opdict, images): |
| 159 | '''extract face texture from given cropped face image |
| 160 | ''' |
| 161 | if 'texture' not in opdict.keys(): |
| 162 | self.light_albedo(opdict) |
| 163 | uv_texture = opdict['texture'] |
| 164 | trans_verts = opdict['transformed_vertices'] |
| 165 | uv_pverts = self.render.world2uv(trans_verts) |
| 166 | uv_gt = F.grid_sample(images, uv_pverts.permute( |
| 167 | 0, 2, 3, 1)[:, :, :, :2], mode='bilinear') |
| 168 | # TODO: poisson blending should give better-looking results |
| 169 | # extract face only |
| 170 | uv_texture_gt = uv_gt[:, :3, :, :]*self.smplx_face_eye_mask + \ |
| 171 | (uv_texture[:, :3, :, :]*(1-self.smplx_face_eye_mask)) |
| 172 | # use this to extract whole texture from image |
| 173 | # uv_texture_gt = uv_gt[:,:3,:,:] |
| 174 | opdict['texture'] = uv_texture_gt |
| 175 | |
| 176 | def recover_position(self, opdict, batch, tform, original_image): |
| 177 | ''' transofrm mesh back to original image space |
nothing calls this directly
no test coverage detected