I have made a model to classify different categories of ships(yacht,catamaran,rubber boat) in Python and i hit a 70% accuracy in training so now i have my weights.hdf5 file.Now i need to object detection the images i used with boundaries boxes and rectangles to find the different ships in each image, like a Yolo pretrained model but with my own weights that i trained for classes,so that the detector is going to find the ship in the image and display is's label with is's probability, etc yacht(70.0% )rubber boat(65.0%)... Can anyone with some more experience drive me to achieving this task?
1 Answer
$\begingroup$
$\endgroup$
2
You should be able to use keras.models.load_model
to load the hdf5
model file. See also the tensorflow documentation.
# saving the model
model = ... # Get model (Sequential, Functional Model, or Model subclass)
model.save('weights.hdf5')
# loading the model
from tensorflow import keras
model = keras.models.load_model('weights.hdf5')
-
$\begingroup$ tensorflow has the option for object detection but with weights from other known pretrained datasets.My problem is that i have the weights from my model and i want to object detect with my model.I suppose your referink to (github.com/tensorflow/hub/blob/master/examples/colab/…) $\endgroup$– scoute21Commented Mar 3, 2021 at 17:44
-
$\begingroup$ The code above works the same when using a custom model. You first have to save the model and it's weights to a file using the
.save()
method, which you can then load in other scripts using theload_model
function. $\endgroup$ Commented Mar 3, 2021 at 18:27