3

I can’t reach exactly the output I want in the Android application. I decorated the layers with a model inspired by a repository. I started training with my own data. I reviewed the original model on netron.app. When I examined mine, the difference I saw was the names of the outputs. For my output variable “class_layer7”, I have the random output name StatefulPartitionedCall:0. However, I think the model should have StatefulPartitionedCall:1. Can I rename it or is it enough to just change the name?

The layer code inspired by a repository:


#Creating the model
input_layer = keras.Input((384, 384, 3))
base_model = tf.keras.applications.MobileNetV3Small(
input_tensor=input_layer, include_top=False, weights=‘imagenet’)

#outputs
…
class_layer7 = tf.keras.layers.Dense(16)(class_layer6)
bbox_layer4 = tf.keras.layers.Softmax()(bbox_layer3)

model = Model(inputs=input_layer, outputs=[class_layer7, bbox_layer4])
#BTW I swapped the places of outputs here but it didn’t work.

model.compile(optimizer=tf.keras.optimizers.Adam(),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
metrics=[‘accuracy’])

#Train
model.fit(x_train, y_train, epochs=10, validation_data=(x_val, y_val))

converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
open(“mymodel.tflite”, “wb”).write(tflite_model)

What I want

What I reach

On android I looked the outputs it gives me negative result for locator. My expectation is change the output names(if it works)

0 Answers0