0

I am currently trying to build an Object Detector using the the Tensorflow Object Detection API with python. I have managed to retrain the faster-rcnn model by following the instructions posted here and here

However, training time is considerably long as I understand that I am. I understand that I am using transfer learning as opposed to training a faster-rcnn model from scratch. I am wondering if there is anyway to download an untrained faster-rcnn model and train it from scratch (end-to-end) instead of having to recourse to transfer-learning.

I am familiar with the advantages of transfer learning, however, my object detector is aimed at being quickly trainable, narrow in scope, and trained on letters as opposed to objects, so I do not think transfer learning is the best route.

I beleive solving this will have something to do with the pipeline.config file, particulary in this part:

fine_tune_checkpoint: "PATH/TO/PRETRAINED/model.ckpt"
from_detection_checkpoint: true
num_steps: 200000

But I am not sure how to specify that there is no fine_tune_checkpoint

marco
  • 656
  • 2
  • 6
  • 22
  • Even with transfer learning, you can choose the number of steps (`num_steps`). You cna for example set it to 20000 or even less depending on the amount of data you have. Training from scratch would take days using performant hardware. – singrium Jul 31 '19 at 13:53
  • Hello, do you mind explaining what you mean by this? Wouldn't changing the `num_steps` variable result in decreased accuracy? – marco Jul 31 '19 at 14:03
  • What I meant is that: you can adjust the number of steps according to your dataset. For example if your dataset has 5000 images, you don't need to train your model for 200000 steps. When you start training your model, you will get the loss displayed during every iteration. If the loss is close to zero (i.e loss < 0.1), it means that your model converged and so you can stop the training. In other words, you don't need to train further once your model has converged (loss is very low). – singrium Jul 31 '19 at 14:12
  • So that's what I was thinking, and this is achievable, but again the issue is that it takes too long. I beleive this is because my data set (letters) is vastly different than the pre-training dataset (coco). – marco Jul 31 '19 at 15:53
  • 1- Do you want to detect letters/writing (alphabet letters and numbers)?, If so, you should use [text-detection-CTPN](https://github.com/eragonruan/text-detection-ctpn) 2- It is true that Transfer Learning is not fully adapted to the new training, but the pre-trained model is not loaded in total when you use Transfer Learning.. Only some parts of it are loaded when you retrain it using your own dataset. And that's what makes Transfer Learning possible. You can fine tune the pre-trained model to fit more with your needs.. – singrium Jul 31 '19 at 16:05
  • Hello, unfortunetely the text-detection-CTPN does not work as I am not looking to detect words but the indivual letters within each word. – marco Jul 31 '19 at 16:48
  • Hmm, may be Tesseract will give you the bounding boxes of letters. Check the ansewers [here](https://stackoverflow.com/questions/20831612/getting-the-bounding-box-of-the-recognized-words-using-python-tesseract) – singrium Jul 31 '19 at 16:54

1 Answers1

0

To train your own model from scratch do the following:

  1. Comment out the following lines
    # fine_tune_checkpoint: <YOUR PATH>
    # from_detection_checkpoint: true
  1. Remove your downloaded pretrained model or rename its path in case you followed the tutorial.

You don't have to download an "empty" model. Instead you can specify your own weight initialization in the config file, e.g., as done here: How to initialize weight for convolution layers in Tensorflow Object Detection API?

Nyps
  • 831
  • 1
  • 14
  • 26