Why does my mean average precision metric show as 0.000e+00?

Viewed 36

I have an object detection model with my labels and images. I am trying to use the tensorflow ranking metric for MAP, https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/metrics/MeanAveragePrecisionMetric. The metric is used when I compile the model but this is the result I get:

Epoch 2/220
92/92 [==============================] - 22s 243ms/step - loss: 0.0027 - mean_average_precision_metric: 0.0000e+00 - val_loss: 0.0019 - val_mean_average_precision_metric: 0.0000e+00
Epoch 3/220
92/92 [==============================] - 22s 245ms/step - loss: 0.0014 - mean_average_precision_metric: 0.0000e+00 - val_loss: 7.5579e-04 - val_mean_average_precision_metric: 0.0000e+00
Epoch 4/220
92/92 [==============================] - 23s 247ms/step - loss: 8.7288e-04 - mean_average_precision_metric: 0.0000e+00 - val_loss: 6.7357e-04 - val_mean_average_precision_metric: 0.0000e+00
Epoch 5/220
92/92 [==============================] - 23s 248ms/step - loss: 7.3901e-04 - mean_average_precision_metric: 0.0000e+00 - val_loss: 5.3464e-04 - val_mean_average_precision_metric: 0.0000e+00

My images are 224x224 which have bounding box coordinates of xmin, ymin, xmax and ymax. I have the bbox coords already adjusted according to the image dimensions in the following code. The images are normalized as well.

train_images = np.array(train_images, dtype='float32')
train_targets = np.array(train_targets, dtype='float32')

val_images = np.array(train_images, dtype='float32')
val_targets = np.array(train_targets, dtype='float32')

test_images = np.array(train_images, dtype='float32')
test_targets = np.array(train_targets, dtype='float32')

train_images /= 255
val_images /= 255
test_images /= 255

train_targets /= 224
val_targets /= 224
test_targets /= 224

This is my model:

feature_Extraction_Layers = [
    Conv2D(64, (3, 3), input_shape=(224, 224, 3), padding='same'),
    LeakyReLU(alpha=0.1),
    Conv2D(64, (3, 3), padding='same'),
    MaxPool2D(pool_size=(2, 2), padding='same'),
    LeakyReLU(alpha=0.1),
    Conv2D(128, (3, 3), padding='same'),
    MaxPool2D(pool_size=(2, 2), padding='same'),
    LeakyReLU(alpha=0.1),
    Conv2D(128, (3, 3), padding='same'),
    MaxPool2D(pool_size=(2, 2), padding='same'),
    LeakyReLU(alpha=0.1),
    Conv2D(256, (3, 3), padding='same'),
    MaxPool2D(pool_size=(2, 2), padding='same'),
    LeakyReLU(alpha=0.1),
    Conv2D(512, (3, 3), padding='same'),
    MaxPool2D(pool_size=(2, 2), padding='same'),
    LeakyReLU(alpha=0.1),
    Conv2D(512, (3, 3), padding='same'),
    MaxPool2D(pool_size=(2, 2), padding='same'),
    LeakyReLU(alpha=0.1),
]
fully_Connected_Layers = [
    GlobalAveragePooling2D(),
    Dropout(0.35),
    Dense(2048, kernel_regularizer=regularizers.l2(0.01)),
    LeakyReLU(alpha=0.1),
    Dense(1024, kernel_regularizer=regularizers.l2(0.01)),
    LeakyReLU(alpha=0.1),
    Dropout(0.35),
    Dense(4),
    Activation('sigmoid'),
]
model = Sequential(feature_Extraction_Layers + fully_Connected_Layers)
model.compile(loss='mse', optimizer='adam', metrics=[tfr.keras.metrics.MeanAveragePrecisionMetric()])

Could the metric not be the right way of using it or maybe not meant for my data?

0 Answers
Related