lot of things
This commit is contained in:
@@ -6,6 +6,11 @@ import scipy.io as sio
|
||||
|
||||
from scipy.spatial import cKDTree
|
||||
from tensorflow_graphics.geometry.representation.mesh.normals import vertex_normals
|
||||
from tensorflow_graphics.geometry.convolution.graph_convolution import edge_convolution_template
|
||||
|
||||
from custom_utils.custom_utils import maskFacesBatch, _maskFaces
|
||||
from custom_utils.graph_utils import sparse_to_tensor
|
||||
|
||||
|
||||
def d_logistic(real_images, generator, discriminator, z_dim, conditions):
|
||||
batch_size = tf.shape(real_images)[0]
|
||||
@@ -202,6 +207,57 @@ def uv_mask_loss(pred, uv_mask):
|
||||
return invalid_count / total_count
|
||||
|
||||
|
||||
|
||||
|
||||
def merge_verts(Vs, batchDim):
|
||||
V = tf.concat(tf.unstack(Vs, num=batchDim), axis=0)
|
||||
return V
|
||||
|
||||
|
||||
def _bend_loss_single(x, F, L, mask):
|
||||
verts = tf.boolean_mask(x, mask, axis=0)
|
||||
VN = vertex_normals(verts, F)
|
||||
bend = edge_convolution_template(
|
||||
VN, L, sizes=None,
|
||||
edge_function=lambda x,y: (x - y)**2,
|
||||
reduction='weighted',
|
||||
edge_function_kwargs={}
|
||||
)
|
||||
loss = tf.reduce_sum(bend)
|
||||
return loss
|
||||
|
||||
def bend_loss(x, F, L, mask):
|
||||
# x: predicted outfits
|
||||
# F: faces
|
||||
# L: laplacian
|
||||
loss = tf.stack([_bend_loss_single(x[i], F[i], L[i], mask[i]) for i in range(x.shape[0])])
|
||||
return loss
|
||||
|
||||
|
||||
# def bend_loss(x, F, L, mask):
|
||||
# # x: predicted outfits
|
||||
# # F: faces
|
||||
# # L: laplacian
|
||||
# # x = x * mask[:,:,tf.newaxis]
|
||||
# batch_size = x.shape[0]
|
||||
# verts, faces = maskFacesBatch(x, F, mask)
|
||||
# nr_valid_verts = [tf.reduce_sum(mask[i]) for i in range(batch_size)]
|
||||
# x = tf.concat(verts, axis=0)
|
||||
# F = tf.concat([faces[i] + tf.reduce_sum(nr_valid_verts[:i]) for i in range(1, batch_size)])
|
||||
# F = tf.concat((faces[0], F), axis=0)
|
||||
# VN = vertex_normals(x, F)
|
||||
# bend = edge_convolution_template(
|
||||
# VN, L, sizes=None,
|
||||
# edge_function=lambda x,y: (x - y)**2,
|
||||
# reduction='weighted',
|
||||
# edge_function_kwargs={}
|
||||
# )
|
||||
# loss = tf.reduce_sum(bend, axis=[1])
|
||||
# loss = tf.reshape(loss, (batch_size, 14475))
|
||||
# loss = tf.reduce_mean(loss, axis=1)
|
||||
# return loss
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
V = tf.ones((4, 14475, 3))
|
||||
B = tf.zeros((4, 14475, 3))
|
||||
|
||||
Reference in New Issue
Block a user