Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow serving throws error #20

Open
ajinkya933 opened this issue May 16, 2020 · 0 comments
Open

Tensorflow serving throws error #20

ajinkya933 opened this issue May 16, 2020 · 0 comments

Comments

@ajinkya933
Copy link

ajinkya933 commented May 16, 2020

@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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant