(checkpoint, alpha)
return predict_saved_model_folder, transform_saved_model_folder
Export arbitrary style transfer trained checkpoints to SavedModel format.

  Args:
    checkpoint: str, path to the checkpoint file.
    alpha: Width Multiplier of the transform model.

  Returns:
    (str, str) Path to the exported style predict and style transform
    SavedModel.
Export arbitrary style transfer trained checkpoints to SavedModel format.
Export arbitrary style transfer trained checkpoints to SavedModel format .
def export_to_saved_model(checkpoint, alpha):
  """Export arbitrary style transfer trained checkpoints to SavedModel format.

  Args:
    checkpoint: str, path to the checkpoint file.
    alpha: Width Multiplier of the transform model.

  Returns:
    (str, str) Path to the exported style predict and style transform
    SavedModel.
  """
  saved_model_dir = tempfile.mkdtemp()
  predict_saved_model_folder = os.path.join(saved_model_dir, 'predict')
  transform_saved_model_folder = os.path.join(saved_model_dir, 'transform')

  with tf.Graph().as_default(), tf.Session() as sess:
    # Defines place holder for the style image.
    style_image_tensor = tf.placeholder(
        tf.float32, shape=[None, None, None, 3], name='style_image')

    # Defines place holder for the content image.
    content_image_tensor = tf.placeholder(
        tf.float32, shape=[None, None, None, 3], name='content_image')

    # Defines the model.
    stylized_images, _, _, bottleneck_feat = \
      build_mobilenet_model.build_mobilenet_model(
          content_image_tensor,
          style_image_tensor,
          mobilenet_trainable=False,
          style_params_trainable=False,
          transformer_trainable=False,
          style_prediction_bottleneck=100,
          transformer_alpha=alpha,
          mobilenet_end_point='layer_19',
          adds_losses=False)

    # Load model weights from  checkpoint file
    load_checkpoint(sess, checkpoint)

    # Write SavedModel for serving or conversion to TF Lite
    tf.saved_model.simple_save(
        sess,
        predict_saved_model_folder,
        inputs={style_image_tensor.name: style_image_tensor},
        outputs={'style_bottleneck': bottleneck_feat})
    tf.logging.debug('Export predict SavedModel to', predict_saved_model_folder)

    tf.saved_model.simple_save(
        sess,
        transform_saved_model_folder,
        inputs={
            content_image_tensor.name: content_image_tensor,
            'style_bottleneck': bottleneck_feat
        },
        outputs={'stylized_image': stylized_images})
    tf.logging.debug('Export transform SavedModel to',
                     transform_saved_model_folder)

  return predict_saved_model_folder, transform_saved_model_folder
def export_to_saved_model ( checkpoint , alpha ) : saved_model_dir = tempfile . mkdtemp ( ) predict_saved_model_folder = os . path . join ( saved_model_dir , 'predict' ) transform_saved_model_folder = os . path . join ( saved_model_dir , 'transform' ) with tf . Graph ( ) . as_default ( ) , tf . Session ( ) as sess : # Defines place holder for the style image. style_image_tensor = tf . placeholder ( tf . float32 , shape = [ None , None , None , 3 ] , name = 'style_image' ) # Defines place holder for the content image. content_image_tensor = tf . placeholder ( tf . float32 , shape = [ None , None , None , 3 ] , name = 'content_image' ) # Defines the model. stylized_images , _ , _ , bottleneck_feat = build_mobilenet_model . build_mobilenet_model ( content_image_tensor , style_image_tensor , mobilenet_trainable = False , style_params_trainable = False , transformer_trainable = False , style_prediction_bottleneck = 100 , transformer_alpha = alpha , mobilenet_end_point = 'layer_19' , adds_losses = False ) # Load model weights from  checkpoint file load_checkpoint ( sess , checkpoint ) # Write SavedModel for serving or conversion to TF Lite tf . saved_model . simple_save ( sess , predict_saved_model_folder , inputs = { style_image_tensor . name : style_image_tensor } , outputs = { 'style_bottleneck' : bottleneck_feat } ) tf . logging . debug ( 'Export predict SavedModel to' , predict_saved_model_folder ) tf . saved_model . simple_save ( sess , transform_saved_model_folder , inputs = { content_image_tensor . name : content_image_tensor , 'style_bottleneck' : bottleneck_feat } , outputs = { 'stylized_image' : stylized_images } ) tf . logging . debug ( 'Export transform SavedModel to' , transform_saved_model_folder ) return predict_saved_model_folder , transform_saved_model_folder