keras-ocr icon indicating copy to clipboard operation
keras-ocr copied to clipboard

Correct way to freeze detector model

Open Asad-Raza opened this issue 3 years ago • 1 comments

Im working on fine tuning detector model. I am freezing the detector in the following way before initiating the training:

for Layer in detector.model.layers: Layer.trainable = False

detector.model.compile()

If I do not freeze the model , the model performance after training is very bad in terms of detecting the text. That means when I am not freezing , the training is overwriting the pretrained model weights.

My question in this regard is that if the way Im doing the freeze of pretrained model is correct? Or I should do freeze on VGG 16 backbone model only? Should I freeze only specific layers? Which specific layers should I freeze ? Please advise.

Asad-Raza avatar Mar 30 '22 15:03 Asad-Raza

In my experimentation Im able to train some of the layers while freezing others in the following way :

detector = keras_ocr.detection.Detector(weights= 'clovaai_general') convLayer = "conv_cls" for Layer in detector.model.layers: if Layer.name.find(convLayer) != -1: Layer.trainable = True else: Layer.trainable = False detector.model.compile('adam','mse')

Asad-Raza avatar Apr 07 '22 10:04 Asad-Raza