예제 #1
0
def tf_wrapper(beta, pose, trans):
    beta = tf.constant(beta, dtype=tf.float64)
    trans = tf.constant(trans, dtype=tf.float64)
    pose = tf.constant(pose, dtype=tf.float64)
    output, _ = smpl_tf.smpl_model('./model.pkl', beta, pose, trans)
    sess = tf.Session()
    result = sess.run(output)
    return result
예제 #2
0
# Load model
# encoder = Encoder()
#encoder.train_step(random_sample.reshape((1, *random_sample.shape, 1)), parameters.reshape(1, *parameters.shape))
# encoder.load_weights(args.model)
encoder_inputs, encoder_outputs = SimpleEncoderArchitecture((256, 256, 1))
encoder = Model(inputs=encoder_inputs, outputs=encoder_outputs)
encoder.summary()

encoder.load_weights(einfo['model_weights_path'])
# Predict the parameters from the silhouette and generate a mesh
prediction = encoder.predict(silhouette.reshape(1, 256, 256, 1))
prediction = tf.cast(prediction, tf.float64)
print("Shape of predictions:'" + str(prediction.shape))
print(prediction[0, 82:85])

pred_pc, faces = smpl_model("../model.pkl", prediction[0, 72:82] * 0 + 1,
                            prediction[0, :72], prediction[0, 82:85] * 0)
# Render the mesh
pred_mesh = Mesh(pointcloud=pred_pc.numpy())
pred_mesh.faces = faces

if mesh is not None:
    mesh.render3D()

print("Rendering prediction")
pred_mesh.render3D()

# Now render their silhouettes
# cv2.imshow("True silhouette", silhouette)
# pred_mesh.render_silhouette(title="Predicted silhouette")