- How to train new classes on pretrained yolov4 model in darknet
- How To Import The MNIST Dataset From Local Directory Using PyTorch
- how to split up tf.data.Dataset into x_train, y_train, x_test, y_test for keras
- How to plot confusion matrix for prefetched dataset in Tensorflow
- How to Use Class Weights with Focal Loss in PyTorch for Imbalanced dataset for MultiClass Classification
- How to solve "ValueError: y should be a 1d array, got an array of shape (3, 5) instead." for naive Bayes?
- How to create image of confusion matrix in Python
- What are the numbers in torch.transforms.normalize and how to select them?
- How to assign a name for a pytorch layer?
- How to solve dist.init_process_group from hanging or deadlocks?
- How to use sample weights with tensorflow datasets?
- How to Fine-tune HuggingFace BERT model for Text Classification
- How to Convert Yolov5 model to tensorflow.js
- Machine Learning Project: Airline Tickets Price Prediction
- Machine Learning Project: Hotel Booking Prediction [Part 2]
- Machine Learning Project: Hotel Booking Prediction [Part 1]
- Machine Learning Project Environment Setup
- Computer vision final year project ideas and guidelines
- Build Your First Machine Learning Project in Python(Step by Step Tutorial)
- Virtual assistant final year project ideas and guidelines
How to load a keras model saved as .pb
To load the saved model, you will need to define a function that loads the model and returns it.
How to load a keras model saved as .pb
Solution 1:
The function tf.keras.models.load_model
load a SavedModel
into a tf.keras
-model. The argument of the function is path to a saved model.
So try model = tf.keras.models.load_model('model')
Solution 2:
You should load all model folder instead of loading .pb file.
If you save model to './_models/vgg50_finetune'
(I used this path in my project), you get folder vgg50_finetune with two .pb files (keras_metadata.pb and saved_model.pb) and two subfolders (assets and variables).
The only thing you should do is use this code:
model = tf.keras.models.load_model('./_models/vgg50_finetune')
And you can both train model or use it for prediction.
Thank you for reading the article.