Retraining Trafficcamnet with custom vehicle dataset

@Morganh I’ll try out more epochs using the above settings.

I have shared the annotated dataset as a google drive link to you via private message. Please check and let me know if you need any other file from my side.

Thanks for the info. I will check further as well.

Firstly, I just use the ngc tracfficcamnet pretrianed model and run evaluation with above way, get below precision for car class.
car’s AP : 16.4506%

This is the baseline.

Then, I ran training for 60 epochs and get below AP.

class name      average precision (in %)
------------  --------------------------
car                             87.2646
two-wheelers                     78.641

More, the annotation does not cover remote cars. So, the new training model will not learn about it.

And some of remote car objects are less than 16x16. This is the limitation of trafficcamnet(i.e, detectnet_v2 nework). YOLO_v4_tiny network in TAO can be used to train from scratch.


Thanks for sharing your results. According to you what is the best thing we can do to keep the detection accuracy high for the similar images and related videos that I shared (because our objective is to run it of from the camera streams set at that angle and height). ?

Will training in yolo_v4_tiny network help? By training from scratch you meant with my own custom annotated dataset or can also use the features of the pretrained model there?

It is better to annotate more remote small cars/two-wheelers. I find that in your label file, lots of small objects are not labelled. Thus, the new training tlt model cannot learn these objects and miss them when run inference.

Then, run detectnet_v2 network again.
Or use YOLOv4_tiny network. YOLOv4_tiny network can train for smaller objects. Please train against your own custom annotated dataset, with ngc object detection pretrained model(hdf5 format) .



Thanks for your suggestion, i’ll try it out.

One more doubt regarding the secondary vehicle classifier training for detecting vehicle types I am planning to use the same dataset that I shared earlier with you. For that I have to follow the classification notebook file right?

In that i saw a pretrained model is downloaded as base i.e pretrained_classification_vresnet18. Should I continue to use the pretrained_classification_vresnet18 model or can I use the resnet18_vehicletypenet.tlt unpruned one available on the NGC? Which one would you suggest for my dataset?

For vehicle classifier, it is a classification model. It is described in , please check if the existing model meets your requirement.

The model described in this card is a classification network which aims to classify car images into 6 vehicle types:

  • coupe
  • sedan
  • SUV
  • van
  • large vehicle
  • truck

If yes, you can use the .etlt file directly as the econdary vehicle classifier.

If not, you can use the unpruned tlt model to train.
More, your sharing dataset is not good for classification training. For the data structure, please see
Image Classification (TF1) - NVIDIA Docs .
For example, you can find and crop the “van” type objects in your current dataset, then put them into a folder “van”. The same as other kinds of vehicle types.
After preparation done, then trigger tao classification training.

Hi @Morganh

I have trained the vehicle classifier model using the custom dataset based on the vehicle types mentioned in the document.

After training the model I ran the application with the trained model but all the vehicles are detected as truck
and it is not classifying the other vehicle type.

Custom Model Screenshot

The custom model is not able to detect the vehicle type as sedan, coupe, suv, etc., it is detecting only truck

As per the document I have used the pretrained_classification_vresnet18/resnet_18.hdf5 model as a base and added custom dataset to increase the accuracy of vehicle type detection.

But here it is only detecting only one vehicle type.

The spec file are
nvdsanalytics_sgie_config_resnet18.txt (2.5 KB)
labels_secondary.txt (52 Bytes)
classification_retrain_spec.cfg (1.1 KB)
classification_spec.cfg (1.2 KB)
classification.ipynb (698.8 KB)

Could you please help on this

Is it running well when using “tao classification inference”?

More, the parameters seems to be not correct. Should be as below.

Please check others according to Image Classification — TAO Toolkit 3.22.05 documentation
or Issue with image classification tutorial and testing with deepstream-app - #21 by Morganh

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