Pycharm vs CoLab

Hello,
I am trying to practice the course exercises on Pycharm in addition to doing them in CoLab to get hands-on for the exam.

In Pycharm, I am facing an issue where I train the model and when I try to run the model on a new test image .
When I submit only the piece of code that calls the model and not the entire training code in a separate window (Submit selection of code and not entire program) it is erroring out saying “model” is not defined.
In colab this is not a problem since each individual cell can be run independently.
However in Pycharm, I am forced to run the entire program just to test one new image and it is training the model again.

Not sure what I am missing here.

Any inputs to over come this issue?

Thank you

Hello @DD4

Working in Colab every breakpoint is saved as you run the cell means that you don’t need to rerun the whole notebook to test your trained model.

In Pycharm we have plain code and the code is executed line by line from top to bottom and that’s why you are requested to rerun the training processes.

To use the model without training again you need to save it on your disk and load it at the testing phase.

You can refer to this documentation on how to save models for future use. https://www.tensorflow.org/guide/keras/save_and_serialize

2 Likes

Thank you,
This is very helpful. Will try to save the model locally and call it from there.

1 Like