0
$\begingroup$

I am doing an object detecton task and I have an issue with my mean average precision metric (mAP). The problem is that the value is a perfect 1.0000 from the first epoch. My guess is that it has something to do with the targets (xmin,ymin,xmax,ymax).

The code below simply reads the image data and the target values which I then scale according to the image dimensions and append to a list. After that, I then convert to numpy array, this all works smooth.

for index, row in train_labels_csv_3.iterrows():
    (filename, width, height, class_name, xmin, ymin, xmax, ymax) = row

    pic = cv2.imread(os.path.join(train_path2,filename))
    
    x = pic.shape[0]
    y = pic.shape[1]

    img_Target_size = 224
    x_scale = img_Target_size / x
    y_scale = img_Target_size / y

    pic = cv2.resize(pic, (img_Target_size, img_Target_size))

    xmin = int(xmin * x_scale)
    ymin = int(ymin * y_scale)
    xmax = int(xmax * x_scale)
    ymax = int(ymax * y_scale)
    
    train_images.append(pic)
    train_targets.append((xmin, ymin, xmax, ymax))

train_images = np.array(train_images).astype('float32')
train_targets = np.array(train_targets).astype('float32')

This is my train targets value for the first image after running the previous code:

array([ 97.,  76., 105.,  81.], dtype=float32

After that, I then normalize my images as such:

train_images /= 255

My results:

375/375 [==============================] - ETA: 0s - loss: 15.2983 - mean_average_precision_metric: 1.00002022-08-21 17:52:07.236506: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 1618920000 exceeds 10% of free system memory.
375/375 [==============================] - 148s 245ms/step - loss: 15.2684 - mean_average_precision_metric: 1.0000 - val_loss: 0.4173 - val_mean_average_precision_metric: 1.0000
Epoch 2/5
375/375 [==============================] - 12s 31ms/step - loss: 0.3889 - mean_average_precision_metric: 1.0000 - val_loss: 0.2865 - val_mean_average_precision_metric: 1.0000
Epoch 3/5
375/375 [==============================] - 12s 33ms/step - loss: 0.2904 - mean_average_precision_metric: 1.0000 - val_loss: 0.2642 - val_mean_average_precision_metric: 1.0000
Epoch 4/5
375/375 [==============================] - 12s 32ms/step - loss: 0.2774 - mean_average_precision_metric: 1.0000 - val_loss: 0.2384 - val_mean_average_precision_metric: 1.0000
Epoch 5/5
375/375 [==============================] - 12s 31ms/step - loss: 0.2550 - mean_average_precision_metric: 1.0000 - val_loss: 0.2525 - val_mean_average_precision_metric: 1.0000

My model is made using the Functional API of Keras: https://hastebin.com/igeketajus.apache

$\endgroup$

1 Answer 1

0
$\begingroup$

I would make sure that the the classifier does not expect bounding boxes in the centroid format of (xmid, ymid, width, height). Dig more into the IoU calculation code to find which format the classifier expects.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.