smallcorgi / Faster-RCNN_TF

Faster-RCNN in Tensorflow
MIT License
2.34k stars 1.12k forks source link

how to continue to train model #163

Open aa642531 opened 7 years ago

aa642531 commented 7 years ago

I have trained my model.I want to continue to train it.How to do change the code?

cemysf commented 7 years ago

In the train_model function of SolverWrapper class in lib/fast_rcnn/train.py: Initialize variables with "self.saver.restore(sess, \<path of ckpt file>), instead of "self.net.load" Also, you may want to set the "iter" count down below to its new correct value

You can add the path of ckpt file in SolverWrapper class as a parameter and pass it from tools/train_net.py

xinboli commented 7 years ago

@aa642531 I have the same question with you, do you solve the problem? @cemysf I tried the method as you said, like this in the train.py:

iintialize variables

    sess.run(tf.global_variables_initializer())
    if self.pretrained_model is not None:
        print ('Loading pretrained model '
               'weights from {:s}').format(self.pretrained_model)
        #self.net.load(self.pretrained_model, sess, self.saver, True)
        self.saver.restore(sess, VGGnet_fast_rcnn_iter_10.ckpt) #this ismy new ckpt file

but I got this error: File "/home/xinboli/work_code/tmp/Faster-RCNN_TF/tools/../lib/fast_rcnn/train.py", line 157, in train_model self.saver.restore(sess, VGGnet_fast_rcnn_iter_10.ckpt) NameError: global name 'VGGnet_fast_rcnn_iter_10' is not defined

Would you like to help me? thank you very much!

cemysf commented 7 years ago

@xinboli you should give the path as a string, like this: self.saver.restore(sess, 'VGGnet_fast_rcnn_iter_10.ckpt')

xinboli commented 7 years ago

@cemysf ahhhhhh! I know!! Now i can use it, thank you :)