INNER CODE UNIT · Python
main
idealo/image-quality-assessment · contrib/tf_serving/save_tfs_model.py:13
def main(base_model_name, weights_file, export_path):
# Load model and weights
nima = Nima(base_model_name, weights=None)
nima.build()
nima.nima_model.load_weights(weights_file)
# Tell keras that this will be used for making predictions
K.set_learning_phase(0)
# CustomObject required by MobileNet
with CustomObjectScope({'relu6': relu6, 'DepthwiseConv2D': DepthwiseConv2D}):
builder = saved_model_builder.SavedModelBuilder(export_path)
signature = predict_signature_def(
inputs={'input_image': nima.nima_model.input},
outputs={'quality_prediction': nima.nima_model.output}
)
builder.add_meta_graph_and_variables(