- Best AI Text Generators for High Quality Content Writing
- Tensorflow Error on Macbook M1 Pro - NotFoundError: Graph execution error
- How does GPT-like transformers utilize only the decoder to do sequence generation?
- How to set all tensors to cuda device?
- How should I use torch.compile properly?
- How do I check if PyTorch is using the GPU?
- WARNING:tensorflow:Using a while_loop for converting cause there is no registered converter for this op
- How to use OneCycleLR?
- Error in Python script "Expected 2D array, got 1D array instead:"?
- How to save model in .pb format and then load it for inference in Tensorflow?
- Top 6 AI Logo Generator Up Until Now- Smarter Than Midjourney
- Best 9 AI Story Generator Tools
- The Top 6 AI Voice Generator Tools
- Best AI Low Code/No Code Tools for Rapid Application Development
- YOLOV8 how does it handle different image sizes
- Best AI Tools For Email Writing & Assistants
- 8 Data Science Competition Platforms Beyond Kaggle
- Data Analysis Books that You Can Buy
- Robotics Books that You Can Buy
- Data Visualization Books that You can Buy
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.