python - decode_predictions on a saved keras model -
i using keras train model on images , saving .h5 file.
i use predict()
predictions model works fine. when try decode predictions labels , probability using decode_predictions
throws error:
`decode_predictions` expects batch of predictions (i.e. 2d array of shape (samples, 1000)). found array shape: (1, 2) ]
this use load model:
model = load_model(self._model_path) model.load_weights(self._model_weights)
and features , decode them:
img = image.load_img(image_path, target_size=self._target_size) x = image.img_to_array(img) x = x.transpose(1, 0, 2) x = np.expand_dims(x, axis=0) x = preprocess_input(x) features = model.predict(x) predictions = decode_predictions(features, top=3)
is not possible decode_predictions on models not pre_trained on imagenet? model load vgg16 model top layer removed , retrained on new images.
is there way labels such models? thanks
Comments
Post a Comment