dusty-nv / jetson-inference

Hello AI World guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and NVIDIA Jetson.
https://developer.nvidia.com/embedded/twodaystoademo
MIT License
7.76k stars 2.97k forks source link

How to train the ssd model using negative dataset #1891

Open mepl432 opened 3 weeks ago

mepl432 commented 3 weeks ago

Hello,

All I read is that dataset for a single object detection in pascal voc format should have labels.txt file containing a single label which is to be identified and that labels.txt should not contain class 0 label of "BACKGROUND" in the dataset. I read that BACKGROUND Label will be generated in the folder where model is stored after training along with the class 1 label for actual object which is detected.

How then do I train the model with my negative samples dataset which does not contain the actual object which is detected in the positive samples with annotated bounding box. Negative samples are used to reduce false positives and there is a major need to train ssd model with it.

@dusty-nv and community could you please guide. Thanks in advance

dusty-nv commented 3 weeks ago

@mepl432 train_ssd.py will automatically add the BACKGROUND class and pull negative training samples from your dataset. Otherwise you can modify the code as needed - mine is just a fork of the upstream repo here - https://github.com/qfgaohao/pytorch-ssd

mepl432 commented 3 weeks ago

Thank you for the prompt response @dusty-nv . When you say pull the negative samples, this is based on their Annotations xml file..correct? so if my negativesample.jpg has corresponding negativesample.xml in Annotations folder as below , then it will be considered negative sample and the model will train on it using the 'BACKGROUND' label automatically?

<annotation>
  <folder>negative_samples</folder>
  <filename>negativesample.jpg</filename>
  <size>
    <width>640</width>
    <height>480</height>
    <depth>3</depth>
  </size>
  <segmented>0</segmented>
  <!-- No object tags -->
</annotation>
dusty-nv commented 2 weeks ago

I think if the image has no bounding box labels, it gets dropped because it has no labels. But you can add a BACKGROUND object? I would recommend digging into the code and modifying it to extract/apply the background examples like you want.


From: mepl432 @.> Sent: Friday, September 13, 2024 12:54:00 PM To: dusty-nv/jetson-inference @.> Cc: Dustin Franklin @.>; Mention @.> Subject: Re: [dusty-nv/jetson-inference] How to train the ssd model using negative dataset (Issue #1891)

Thank you for the prompt response @dusty-nvhttps://github.com/dusty-nv . When you say pull the negative samples, this is based on their Annotations xml file..correct? so if my negativesample.jpg has corresponding negativesample.xml in Annotations folder as below , then it will be considered negative sample and the model will train on it using the 'BACKGROUND' label automatically?

negative_samples negativesample.jpg 640 480 3 0

— Reply to this email directly, view it on GitHubhttps://github.com/dusty-nv/jetson-inference/issues/1891#issuecomment-2349416460, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADVEGKZ7HD27AL47QDXK3I3ZWMKCRAVCNFSM6AAAAABOEQWTZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBZGQYTMNBWGA. You are receiving this because you were mentioned.Message ID: @.***>