docstr: API for image style transfer.
  
  Args:
      images (list): list of dict objects, each dict contains key:
          content(str): value is a numpy.ndarry with shape [H, W, C], content data.
          styles(str): value is a list of numpy.ndarray with shape [H, W, C], styles data.
          weights(str, optional): value is the interpolation weights correspond to styles.
      paths (list): list of dict objects, each dict contains key:
          content(str): value is the path to content.
          styles(str): value is the paths to styles.
          weights(str, optional): value is the interpolation weights correspond to styles.
      alpha (float): The weight that controls the degree of stylization. Should be between 0 and 1.
      use_gpu (bool): whether to use gpu.
      output_dir (str): the path to store output images.
      visualization (bool): whether to save image or not.
  
  Returns:
      im_output (list[dict()]): list of output images and save path of images.
docstr_tok: ["API","for","image","style","transfer",".","Args",":","images","(","list",")",":","list","of","dict","objects",",","each","dict","contains","key",":","content","(","str",")",":","value","is","a","numpy.ndarry","with","shape","[","H",",","W",",","C","]",",","content","data",".","styles","(","str",")",":","value","is","a","list","of","numpy.ndarray","with","shape","[","H",",","W",",","C","]",",","styles","data",".","weights","(","str",",","optional",")",":","value","is","the","interpolation","weights","correspond","to","styles",".","paths","(","list",")",":","list","of","dict","objects",",","each","dict","contains","key",":","content","(","str",")",":","value","is","the","path","to","content",".","styles","(","str",")",":","value","is","the","paths","to","styles",".","weights","(","str",",","optional",")",":","value","is","the","interpolation","weights","correspond","to","styles",".","alpha","(","float",")",":","The","weight","that","controls","the","degree","of","stylization",".","Should","be","between","0","and","1.","use_gpu","(","bool",")",":","whether","to","use","gpu",".","output_dir","(","str",")",":","the","path","to","store","output","images",".","visualization","(","bool",")",":","whether","to","save","image","or","not",".","Returns",":","im_output","(","list","[","dict","(",")","]",")",":","list","of","output","images","and","save","path","of","images","."]
code: def style_transfer(
      self,
      images=None,
      paths=None,
      alpha=1,
      use_gpu=False,
      output_dir="transfer_result",
      visualization=False,
  ):
      """
      API for image style transfer.
  
      Args:
          images (list): list of dict objects, each dict contains key:
              content(str): value is a numpy.ndarry with shape [H, W, C], content data.
              styles(str): value is a list of numpy.ndarray with shape [H, W, C], styles data.
              weights(str, optional): value is the interpolation weights correspond to styles.
          paths (list): list of dict objects, each dict contains key:
              content(str): value is the path to content.
              styles(str): value is the paths to styles.
              weights(str, optional): value is the interpolation weights correspond to styles.
          alpha (float): The weight that controls the degree of stylization. Should be between 0 and 1.
          use_gpu (bool): whether to use gpu.
          output_dir (str): the path to store output images.
          visualization (bool): whether to save image or not.
  
      Returns:
          im_output (list[dict()]): list of output images and save path of images.
      """
      if use_gpu:
          try:
              _places = os.environ["CUDA_VISIBLE_DEVICES"]
              int(_places[0])
          except:
              raise RuntimeError(
                  "Environment Variable CUDA_VISIBLE_DEVICES is not set correctly. If you wanna use gpu, please set CUDA_VISIBLE_DEVICES as cuda_device_id."
              )
  
      predictor_enc = (
          self.gpu_predictor_enc if use_gpu else self.cpu_predictor_enc
      )
      input_names_enc = predictor_enc.get_input_names()
      input_handle_enc = predictor_enc.get_input_handle(
          input_names_enc[0]
      )
      output_names_enc = predictor_enc.get_output_names()
      output_handle_enc = predictor_enc.get_output_handle(
          output_names_enc[0]
      )
  
      predictor_dec = (
          self.gpu_predictor_dec if use_gpu else self.cpu_predictor_dec
      )
      input_names_dec = predictor_dec.get_input_names()
      input_handle_dec = predictor_dec.get_input_handle(
          input_names_dec[0]
      )
      output_names_dec = predictor_dec.get_output_names()
      output_handle_dec = predictor_dec.get_output_handle(
          output_names_dec[0]
      )
  
      im_output = []
      for component, w, h in reader(images, paths):
          input_handle_enc.copy_from_cpu(component["content_arr"])
          predictor_enc.run()
          content_feats = output_handle_enc.copy_to_cpu()
          accumulate = np.zeros((3, 512, 512))
          for idx, style_arr in enumerate(component["styles_arr_list"]):
              # encode
              input_handle_enc.copy_from_cpu(style_arr)
              predictor_enc.run()
              style_feats = output_handle_enc.copy_to_cpu()
              fr_feats = fr(content_feats, style_feats, alpha)
              # decode
              input_handle_dec.copy_from_cpu(fr_feats)
              predictor_dec.run()
              predict_outputs = output_handle_dec.copy_to_cpu()
              # interpolation
              accumulate += (
                  predict_outputs[0]
                  * component["style_interpolation_weights"][idx]
              )
          # postprocess
          save_im_name = "ndarray_{}.jpg".format(time.time())
          result = postprocess(
              accumulate,
              output_dir,
              save_im_name,
              visualization,
              size=(w, h),
          )
          im_output.append(result)
      return im_output
  
imports: from __future__ import absolute_import
  from __future__ import division
  import argparse
  import ast
  import copy
  import os
  import time
  import numpy
  import paddle
  from paddle.inference import Config
  from paddle.inference import create_predictor
  from stylepro_artistic.data_feed import reader
  from stylepro_artistic.processor import base64_to_cv2
  from stylepro_artistic.processor import cv2_to_base64
  from stylepro_artistic.processor import fr
  from stylepro_artistic.processor import postprocess
  import paddlehub
  from paddlehub.module.module import moduleinfo
  from paddlehub.module.module import runnable
  from paddlehub.module.module import serving
label_desc: Use image node_id 3 for calling the StyleProjection obj's underlying member method code with example usage: obj.style_transfer(images, paths, alpha, use_gpu, output_dir, visualization) and returns: im_output