(content_input_,
                          style_input_,
                          mobilenet_trainable=True,
                          style_params_trainable=False,
                          transformer_trainable=False,
                          reuse=None,
                          mobilenet_end_point='layer_19',
                          transformer_alpha=0.25,
                          style_prediction_bottleneck=100,
                          adds_losses=True,
                          content_weights=None,
                          style_weights=None,
                          total_variation_weight=None)
return stylized_images, total_loss, loss_dict, bottleneck_feat
The image stylize function using a MobileNetV2 instead of InceptionV3.

  Args:
    content_input_: Tensor. Batch of content input images.
    style_input_: Tensor. Batch of style input images.
    mobilenet_trainable: bool. Should the MobileNet parameters be trainable?
    style_params_trainable: bool. Should the style parameters be trainable?
    transformer_trainable: bool. Should the style transfer network be
        trainable?
    reuse: bool. Whether to reuse model parameters. Defaults to False.
    mobilenet_end_point: string. Specifies the endpoint to construct the
        MobileNetV2 network up to. This network is used for style prediction.
    transformer_alpha: float. Width multiplier used to reduce the number of
        filters in the model and slim it down.
    style_prediction_bottleneck: int. Specifies the bottleneck size in the
        number of parameters of the style embedding.
    adds_losses: wheather or not to add objectives to the model.
    content_weights: dict mapping layer names to their associated content loss
        weight. Keys that are missing from the dict won't have their content
        loss computed.
    style_weights: dict mapping layer names to their associated style loss
        weight. Keys that are missing from the dict won't have their style
        loss computed.
    total_variation_weight: float. Coefficient for the total variation part of
        the loss.

  Returns:
    Tensor for the output of the transformer network, Tensor for the total loss,
    dict mapping loss names to losses, Tensor for the bottleneck activations of
    the style prediction network.
The image stylize function using a MobileNetV2 instead of InceptionV3.
The image stylize function using a MobileNetV2 instead of InceptionV3 .
def build_mobilenet_model(content_input_,
                          style_input_,
                          mobilenet_trainable=True,
                          style_params_trainable=False,
                          transformer_trainable=False,
                          reuse=None,
                          mobilenet_end_point='layer_19',
                          transformer_alpha=0.25,
                          style_prediction_bottleneck=100,
                          adds_losses=True,
                          content_weights=None,
                          style_weights=None,
                          total_variation_weight=None):
  """The image stylize function using a MobileNetV2 instead of InceptionV3.

  Args:
    content_input_: Tensor. Batch of content input images.
    style_input_: Tensor. Batch of style input images.
    mobilenet_trainable: bool. Should the MobileNet parameters be trainable?
    style_params_trainable: bool. Should the style parameters be trainable?
    transformer_trainable: bool. Should the style transfer network be
        trainable?
    reuse: bool. Whether to reuse model parameters. Defaults to False.
    mobilenet_end_point: string. Specifies the endpoint to construct the
        MobileNetV2 network up to. This network is used for style prediction.
    transformer_alpha: float. Width multiplier used to reduce the number of
        filters in the model and slim it down.
    style_prediction_bottleneck: int. Specifies the bottleneck size in the
        number of parameters of the style embedding.
    adds_losses: wheather or not to add objectives to the model.
    content_weights: dict mapping layer names to their associated content loss
        weight. Keys that are missing from the dict won't have their content
        loss computed.
    style_weights: dict mapping layer names to their associated style loss
        weight. Keys that are missing from the dict won't have their style
        loss computed.
    total_variation_weight: float. Coefficient for the total variation part of
        the loss.

  Returns:
    Tensor for the output of the transformer network, Tensor for the total loss,
    dict mapping loss names to losses, Tensor for the bottleneck activations of
    the style prediction network.
  """

  [activation_names, activation_depths
  ] = transformer_model.style_normalization_activations(alpha=transformer_alpha)

  # Defines the style prediction network.
  style_params, bottleneck_feat = style_prediction_mobilenet(
      style_input_,
      activation_names,
      activation_depths,
      mobilenet_end_point=mobilenet_end_point,
      mobilenet_trainable=mobilenet_trainable,
      style_params_trainable=style_params_trainable,
      style_prediction_bottleneck=style_prediction_bottleneck,
      reuse=reuse
  )

  # Defines the style transformer network
  stylized_images = transformer_model.transform(
      content_input_,
      alpha=transformer_alpha,
      normalizer_fn=ops.conditional_style_norm,
      reuse=reuse,
      trainable=transformer_trainable,
      is_training=transformer_trainable,
      normalizer_params={'style_params': style_params}
  )

  # Adds losses
  loss_dict = {}
  total_loss = []
  if adds_losses:
    total_loss, loss_dict = losses.total_loss(
        content_input_,
        style_input_,
        stylized_images,
        content_weights=content_weights,
        style_weights=style_weights,
        total_variation_weight=total_variation_weight
    )

  return stylized_images, total_loss, loss_dict, bottleneck_feat
def build_mobilenet_model ( content_input_ , style_input_ , mobilenet_trainable = True , style_params_trainable = False , transformer_trainable = False , reuse = None , mobilenet_end_point = 'layer_19' , transformer_alpha = 0.25 , style_prediction_bottleneck = 100 , adds_losses = True , content_weights = None , style_weights = None , total_variation_weight = None ) : [ activation_names , activation_depths ] = transformer_model . style_normalization_activations ( alpha = transformer_alpha ) # Defines the style prediction network. style_params , bottleneck_feat = style_prediction_mobilenet ( style_input_ , activation_names , activation_depths , mobilenet_end_point = mobilenet_end_point , mobilenet_trainable = mobilenet_trainable , style_params_trainable = style_params_trainable , style_prediction_bottleneck = style_prediction_bottleneck , reuse = reuse ) # Defines the style transformer network stylized_images = transformer_model . transform ( content_input_ , alpha = transformer_alpha , normalizer_fn = ops . conditional_style_norm , reuse = reuse , trainable = transformer_trainable , is_training = transformer_trainable , normalizer_params = { 'style_params' : style_params } ) # Adds losses loss_dict = { } total_loss = [ ] if adds_losses : total_loss , loss_dict = losses . total_loss ( content_input_ , style_input_ , stylized_images , content_weights = content_weights , style_weights = style_weights , total_variation_weight = total_variation_weight ) return stylized_images , total_loss , loss_dict , bottleneck_feat