small updates
This commit is contained in:
@@ -35,32 +35,14 @@ class UV2Mesh(nn.Module):
|
||||
self.uv_pixels = self.uv_map_discreet[m2uv]
|
||||
self.smpl_res = 14475 if not is_smpl_orig else 3638
|
||||
|
||||
self.resizer = Resize(size=(512, 256), interpolation=InterpolationMode.BILINEAR)
|
||||
|
||||
|
||||
def uv_to_mesh(self, uv):
|
||||
if uv.shape[1] == 3 or uv.shape[1] == 7:
|
||||
uv = torch.permute(uv, [0,2,3,1])
|
||||
if uv.shape[1] != 512:
|
||||
uv = Resize(uv[:,:,None], size=(512, 256), interpolation=InterpolationMode.BILINEAR)
|
||||
|
||||
# batch_size = uv.shape[0]
|
||||
|
||||
# x1_ind = tf.concat((tf.tile(self.uv_pixels[:, 0, :][tf.newaxis, :, :], [batch_size, 1, 1]), tf.zeros((batch_size, self.smpl_res, 1), dtype=tf.int32)), axis=-1)
|
||||
# y1_ind = tf.concat((tf.tile(self.uv_pixels[:, 0, :][tf.newaxis, :, :], [batch_size, 1, 1]), tf.ones((batch_size, self.smpl_res, 1), dtype=tf.int32)), axis=-1)
|
||||
# z1_ind = tf.concat((tf.tile(self.uv_pixels[:, 0, :][tf.newaxis, :, :], [batch_size, 1, 1]), tf.ones((batch_size, self.smpl_res, 1), dtype=tf.int32) * 2), axis=-1)
|
||||
# x2_ind = tf.concat((tf.tile(self.uv_pixels[:, 1, :][tf.newaxis, :, :], [batch_size, 1, 1]), tf.zeros((batch_size, self.smpl_res, 1), dtype=tf.int32)), axis=-1)
|
||||
# y2_ind = tf.concat((tf.tile(self.uv_pixels[:, 1, :][tf.newaxis, :, :], [batch_size, 1, 1]), tf.ones((batch_size, self.smpl_res, 1), dtype=tf.int32)), axis=-1)
|
||||
# z2_ind = tf.concat((tf.tile(self.uv_pixels[:, 1, :][tf.newaxis, :, :], [batch_size, 1, 1]), tf.ones((batch_size, self.smpl_res, 1), dtype=tf.int32) * 2), axis=-1)
|
||||
|
||||
|
||||
# x1 = tf.gather_nd(uv, x1_ind, batch_dims=1)
|
||||
# y1 = tf.gather_nd(uv, y1_ind, batch_dims=1)
|
||||
# z1 = tf.gather_nd(uv, z1_ind, batch_dims=1)
|
||||
# x2 = tf.gather_nd(uv, x2_ind, batch_dims=1)
|
||||
# y2 = tf.gather_nd(uv, y2_ind, batch_dims=1)
|
||||
# z2 = tf.gather_nd(uv, z2_ind, batch_dims=1)
|
||||
|
||||
# p1 = tf.stack((x1, y1, z1), axis=-1)
|
||||
# p2 = tf.stack((x2, y2, z2), axis=-1)
|
||||
uv = torch.permute(self.resizer(torch.permute(uv, [0,3,1,2])), [0,2,3,1])
|
||||
|
||||
mesh = torch.mean(uv[:, self.uv_pixels[:,:,0], self.uv_pixels[:,:,1]].float(), dim=2)
|
||||
return mesh
|
||||
|
||||
Reference in New Issue
Block a user