1

I get an error when accessing

{ "error": "Generic conv implementation does not support grouped convolutions for now.\n\t [[{{node model_1/conv2d_1/Conv2D}}]]" }

I translate the model to TF server

import tensorflow as tf


tf.keras.backend.set_learning_phase(0)   

model = tf.keras.models.load_model(r'model.h5')
export_path = 'my_image_classifier/1'

with tf.keras.backend.get_session() as sess:
    tf.saved_model.simple_save(
        sess,
        export_path,
        inputs={'input_image': model.input},
        outputs={t.name: t for t in model.outputs})

What do i do? I need a model on the server

System Ubuntu 18.04

TF server 1.12(Docker)

Keras 1.2.4

1
  • I faced this issue with tf 1.14. Downgrading it to 1.13.1 solved it. Sep 19, 2019 at 8:16

1 Answer 1

0
from tensorflow.python.saved_model import builder as saved_model_builder
from tensorflow.python.saved_model import tag_constants
from tensorflow.python.saved_model.signature_def_utils_impl import predict_signature_def
from tensorflow.keras import backend as K
import tensorflow as tf


export_path = 'model'
sess = tf.Session()

K.set_session(sess)
K.set_learning_phase(0)

json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()

model = tf.keras.models.model_from_json(loaded_model_json)
model.load_weights('01.h5')

model.summary()

builder = saved_model_builder.SavedModelBuilder(export_path)

signature = predict_signature_def(inputs={'input_image': model.get_layer(name='the_input').input},
                                  outputs={'out': model.get_layer(name='the_output').output})

with K.get_session() as sess:
    builder.add_meta_graph_and_variables(sess=sess,
                                         tags=[tag_constants.SERVING],
                                         signature_def_map={'predict': signature},
                                         strip_default_attrs=True)
    builder.save()

The main thing is to include

strip_default_attrs=True

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.