aerial_pedestrian_detection
aerial_pedestrian_detection copied to clipboard
Tensorflow serving throws error
@priya-dwivedi When I train the model by using default config file, and convert it to tensorflow serving using this script:
from keras import backend as K
import tensorflow as tf
from tensorflow.python import saved_model
from tensorflow.python.saved_model.signature_def_utils_impl import (
build_signature_def, predict_signature_def
)
from keras_retinanet import models
import shutil
import os
export_path = 'retinanet_savedmodel'
model = models.convert_model(
model=models.backbone(backbone_name='resnet101').retinanet(num_classes=8),
nms=True,
class_specific_filter=True,
anchor_params=None
)
model.load_weights('model.h5')
print('Output layers', [o.name[:-2] for o in model.outputs])
print('Input layer', model.inputs[0].name[:-2])
if os.path.isdir(export_path):
shutil.rmtree(export_path)
builder = saved_model.builder.SavedModelBuilder(export_path)
signature = predict_signature_def(
inputs={'images': model.input},
outputs={
'output1': model.outputs[0],
'output2': model.outputs[1],
'output3': model.outputs[2]
}
)
sess = K.get_session()
builder.add_meta_graph_and_variables(sess=sess,
tags=[saved_model.tag_constants.SERVING],
signature_def_map={'predict': signature})
builder.save()
I am able to get successful prediction. But the successful predictions are observed only for default anchor parameters. In your code you have changed the anchor parameters.
But, I do not know a correct way to pass anchor_params
to above script.
How do I pass anchor_params
correctly to above script ?