code: def base64_to_cv2(b64str):
      data = base64.b64decode(b64str.encode("utf8"))
      data = np.fromstring(data, np.uint8)
      data = cv2.imdecode(data, cv2.IMREAD_COLOR)
      if data is None:
          buf = BytesIO()
          image_decode = base64.b64decode(b64str.encode("utf8"))
          image = BytesIO(image_decode)
          im = Image.open(image)
          rgb = im.convert("RGB")
          rgb.save(buf, "jpeg")
          buf.seek(0)
          image_bytes = buf.read()
          data_base64 = str(
              base64.b64encode(image_bytes), encoding="utf-8"
          )
          image_decode = base64.b64decode(data_base64)
          img_array = np.frombuffer(image_decode, np.uint8)
          data = cv2.imdecode(img_array, cv2.IMREAD_COLOR)
      return data
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import ast
  import base64
  import math
  import os
  import time
  from io import BytesIO
  import cv2
  import numpy
  from paddle.inference import Config
  from paddle.inference import create_predictor
  from PIL import Image
  from paddlehub.module.module import moduleinfo
  from paddlehub.module.module import runnable
  from paddlehub.module.module import serving
  from paddlehub.utils.log import logger
label_desc: Use image node_id 1 for calling a global function with example usage: base64_to_cv2(b64str) and returns: data