How to add new class to existing dataset?

I am trying to add 1 new class to existing 20 classes of VOC dataset. I am new to tensorflow and following this tutorial: TensorFlow Object Detection API tutorial — TensorFlow Object Detection API tutorial documentation. Unfortunately total loss never was less than around 10 and after 30000 steps it started increasing. I also tried to train with 20 original classes but result was the same.

log is here: https://paste2.org/Ax8jZFLO

My setup:

  • AMD Radeon RX570 GPU
  • Windows 10
  • DirectML
  • Tensorflow 1.15
  • TensorFlow Model v.1.13.0

Any help will be highly appreciated.

@Manoson Welcome to Tensorflow Forum!

Adding a new class to an existing dataset in TensorFlow Object Detection API involves several steps. Here’s a breakdown of the process:

1. Prepare the Data:

  • Download the VOC dataset : Download the VOC dataset that contains the 20 existing classes.
  • Add your new class images : Add the labeled images for your new class to the appropriate folder within the VOC dataset. Ensure the images follow the same naming convention and annotation format as the existing data.
  • Generate TFRecords : Convert your images and annotations into TFRecord format. This optimizes training by reading and parsing the data efficiently.

2. Modify the Label Map:

  • Update the label map : Open the existing label map file and add a new entry for your new class, specifying its unique ID and name.
  • Update the training config : Modify the training configuration file (e.g., pipeline.config) to include your new class ID in the relevant sections like num_classes and label_map_path .

3. Train the Model:

  • Choose a pre-trained model : Select a pre-trained model as the starting point for fine-tuning. Consider models like SSD or Faster R-CNN that perform well for object detection tasks.
  • Fine-tune the model : Train the pre-trained model on your combined dataset. Adjust training parameters like learning rate and number of training steps based on your specific hardware and dataset size.

Here are some potential reasons why your total loss remains high and increases after 30,000 steps:

  • Data imbalance : The number of images for your new class might be significantly smaller than the existing classes, leading to imbalanced training. Consider using techniques like oversampling or class weighting to address this.
  • Insufficient training : 30,000 steps might be insufficient for training with a new class. Increase the number of training steps and monitor the loss to see if it improves.
  • Learning rate : The learning rate might be too high, causing the loss to diverge. Try reducing the learning rate and see if it stabilizes the training process.
  • Model complexity : The chosen pre-trained model might be too complex for your dataset and data augmentation techniques. Consider using a simpler model or reducing the augmentation complexity.

Here are some additional tips for adding a new class:

  • Start with a small number of images for your new class and gradually increase the size as you achieve better results.
  • Use visualization tools like TensorBoard to monitor the training process and identify potential issues like inaccurate bounding boxes or misclassified objects.
  • Consider using transfer learning by freezing the pre-trained model’s layers except for the last few layers, which you fine-tune on your combined dataset.
  • Validate your model on a separate validation dataset to assess its generalization performance.

Remember, training object detection models requires careful data preparation, configuration adjustments, and monitoring the training process. By addressing potential issues and experimenting with different settings, you can successfully add a new class to your existing dataset and achieve good object detection results.

Let us know if this helps!