How to show Metrics in Custom Object Detection Model?

Hi! I’ve trained a custom model following the Re-training SSD-Mobilenet tutorial. It works fine, but now I’d like to show metrics like F1 score, Accuracy and Loss.

For example, in others projects I use this code:

acc = historial.history['accuracy']
val_acc = historial.history['val_accuracy']
historial = modelo.fit(
data_gen_entrenamiento, epochs=50, batch_size=32,
validation_data=data_gen_pruebas)

But, in the Re-training SSD-Mobilenet tutorial, for training use a diference code:

!python3 train_ssd.py --dataset-type=voc --data=./ --model-dir=models/Orange --batch-size=4 --workers=2 --epochs=50

So, I don’t know how to call ‘accuracy’ and ‘loss’ in order to show them into a graphic. By the way, I used Colab for training 'cause I have only a 2GB Jetson Nano.

Hi @juanpalaciosvargas, you can use the --validation-mean-ap flag to train_ssd.py to calculate the mean average precision (mAP) of each class during the validation phase of each training epoch.

Can you give me an example please? I’ve used this flag without any success. By the way, what I want to do is to show the results of training (“loss” and “accuracy”) into a graphic (“loss” vs" epochs" / “accuracy” vs “epochs”) and create a" confusion matrix".

Do you mean that it fails to run with that flag? If so, perhaps you are running an older version of train_ssd.py - in that case, try running this:

cd jetson-inference/python/training/detection/ssd
git pull

There is support for TensorBoard in train_ssd.py, it will output to your model’s tensorboard/ directory. You can then run TensorBoard from another terminal like tensorboard --log-dir=models/your_model/tensorboard and navigate your browser to it to see the Loss vs Epochs graphs and MeanAP vs Epochs graphs.

1 Like

This is me again. Regarding the flag, yes it fails when I run the code.
First, I used this code:

!python3 train_ssd.py --dataset-type=voc --data=./ --model-dir=models/Orange --batch-size=4 --workers=2 --epochs=50

But, I tried adding the flag:

!python3 train_ssd.py --dataset-type=voc --data=./ --model-dir=models/Orange --batch-size=4 --workers=2 --epochs=50 --validation-mean-ap

So, I tried adding the indicated lines code:

cd jetson-inference/python/training/detection/ssd
git pull

But I got this error:
You are not currently on a branch.
Please apecify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

Any idea? By the way, I’m currently training the model using Google COLAB.

Hi @juanpalaciosvargas, can you try running git checkout master and git pull origin master instead?

If you are on Google COLAB, you can just clone pytorch-ssd repo directly (and it will be the latest master) - git clone https://github.com/dusty-nv/pytorch-ssd

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.