Trying to upload everything to git to be able to share it easily, not working yet as my project is too big. Here the keras model:

# Define the model
inputs = tf.keras.Input(shape=(99))
# embedding = landmarks_to_embedding(inputs)

layer = keras.layers.Dense(128, activation=tf.nn.relu6)(inputs)
layer = keras.layers.Dropout(0.5)(layer)
layer = keras.layers.Dense(64, activation=tf.nn.relu6)(layer)
layer = keras.layers.Dropout(0.5)(layer)
outputs = keras.layers.Dense(5, activation="softmax")(layer)

model = keras.Model(inputs, outputs)
model.summary()

import pandas as pd

model.compile(
    optimizer='adam',
    loss='categorical_crossentropy',
    metrics=['accuracy']
)

# Add a checkpoint callback to store the checkpoint that has the highest
# validation accuracy.
checkpoint_path = "weights.best.hdf5"
checkpoint = keras.callbacks.ModelCheckpoint(checkpoint_path,
                             monitor='val_accuracy',
                             verbose=1,
                             save_best_only=True,
                             mode='max')
earlystopping = keras.callbacks.EarlyStopping(monitor='val_accuracy', 
                                              patience=20)


pose_embedder = FullBodyPoseEmbedder()
# # Calling DataFrame constructor on list
# df = pd.DataFrame(X_train)
# # print(df.shape)
# df.astype('float64')
# print(df.shape)
booly = 0
landmarks = X_train.to_numpy()
validation = X_val.to_numpy()
val_landmarks = []
norm_landmarks = []
for x in landmarks:
  if(booly==0):
    print(x)
  y = np.reshape(x,[-1,3])
  # print(y.shape)
  embedding = pose_embedder(y)
  if(booly==0):
    print(embedding)
    booly=1
  # print(embedding)
  norm_landmarks.append(embedding)

for z in validation:
  p = np.reshape(z,[-1,3])
  # print(p.shape)
  embedding = pose_embedder(p)
  # print(embedding)
  val_landmarks.append(embedding)

# embedding = landmarks_to_embedding(X_train)
# embedding_val = landmarks_to_embedding(X_val)
norm_landmarks = np.array(norm_landmarks)
norm_landmarks = np.reshape(norm_landmarks, [-1,99])
val_landmarks = np.array(val_landmarks)
val_landmarks = np.reshape(val_landmarks, [-1,99])
print(norm_landmarks)
print(y_train)
# Start training
# estimator = KerasClassifier(build_fn=baseline_model, epochs=200, batch_size=5, verbose=0)
# history = model.fit(norm_landmarks, y_train, epochs = 200, batch_size=5, verbose=0, validation_data = (val_landmarks, y_val))
history = model.fit(norm_landmarks, y_train,
                    epochs=200,
                    batch_size=16,
                    shuffle = True,
                    validation_data=(val_landmarks, y_val),
                    callbacks=[checkpoint, earlystopping],
                    verbose = 2)

Used ‘new → other → tensorflow lite model’ to add it to androidStudio
Using this code to run inference:

            Jupyter1 dlClassifier = Jupyter1.newInstance(context);
            // Creates inputs for reference.
            TensorBuffer inputFeature0 = TensorBuffer.createFixedSize(new int[]{1, 99}, DataType.FLOAT32);
            List<PointF3D> landmarks = extractPoseLandmarks(pose);
            System.out.println(landmarks);
            if (landmarks.isEmpty()) {
                return getStringFromResult(history.getResult());
            }
            List<PointF3D> embedding = getPoseEmbedding(landmarks);
            ByteBuffer buf = ByteBuffer.allocateDirect(99 * 4);
            boolean justOnce = true;

            for (PointF3D landmark : embedding) {
                if (justOnce) {
                    System.out.println("landmark X: " + landmark.getX() + " landmark Y: " + landmark.getY() + " landmark Z: " + landmark.getZ());
                }
                buf.putFloat(landmark.getX());
                buf.putFloat(landmark.getY());
                buf.putFloat(landmark.getZ());
            }
            buf.rewind();
            inputFeature0.loadBuffer(buf);

            // Runs model inference and gets result.
            Jupyter1.Outputs outputs = dlClassifier.process(inputFeature0);
            TensorBuffer outputFeature0 = outputs.getOutputFeature0AsTensorBuffer();
            float[] data = outputFeature0.getFloatArray();
            System.out.println("output: " + Arrays.toString(data));

When i have everything on git, i’ll share the complete code!