code: def text_visual(
      texts, scores, font_file, img_h=400, img_w=600, threshold=0.0
  ):
      """
      create new blank img and draw txt on it
      args:
          texts(list): the text will be draw
          scores(list|None): corresponding score of each txt
          img_h(int): the height of blank img
          img_w(int): the width of blank img
      return(array):
      """
      if scores is not None:
          assert len(texts) == len(
              scores
          ), "The number of txts and corresponding scores must match"
  
      def create_blank_img():
          blank_img = np.ones(shape=[img_h, img_w], dtype=np.int8) * 255
          blank_img[:, img_w - 1 :] = 0
          blank_img = Image.fromarray(blank_img).convert("RGB")
          draw_txt = ImageDraw.Draw(blank_img)
          return blank_img, draw_txt
  
      blank_img, draw_txt = create_blank_img()
  
      font_size = 20
      txt_color = (0, 0, 0)
      font = ImageFont.truetype(font_file, font_size, encoding="utf-8")
  
      gap = font_size + 5
      txt_img_list = []
      count, index = 1, 0
      for idx, txt in enumerate(texts):
          index += 1
          if scores[idx] < threshold or math.isnan(scores[idx]):
              index -= 1
              continue
          first_line = True
          while str_count(txt) >= img_w // font_size - 4:
              tmp = txt
              txt = tmp[: img_w // font_size - 4]
              if first_line:
                  new_txt = str(index) + ": " + txt
                  first_line = False
              else:
                  new_txt = "    " + txt
              draw_txt.text(
                  (0, gap * count), new_txt, txt_color, font=font
              )
              txt = tmp[img_w // font_size - 4 :]
              if count >= img_h // gap - 1:
                  txt_img_list.append(np.array(blank_img))
                  blank_img, draw_txt = create_blank_img()
                  count = 0
              count += 1
          if first_line:
              new_txt = (
                  str(index)
                  + ": "
                  + txt
                  + "   "
                  + "%.3f" % (scores[idx])
              )
          else:
              new_txt = "  " + txt + "  " + "%.3f" % (scores[idx])
          draw_txt.text((0, gap * count), new_txt, txt_color, font=font)
          # whether add new blank img or not
          if count >= img_h // gap - 1 and idx + 1 < len(texts):
              txt_img_list.append(np.array(blank_img))
              blank_img, draw_txt = create_blank_img()
              count = 0
          count += 1
      txt_img_list.append(np.array(blank_img))
      if len(txt_img_list) == 1:
          blank_img = np.array(txt_img_list[0])
      else:
          blank_img = np.concatenate(txt_img_list, axis=1)
      return np.array(blank_img)
  
file_path: PaddleHub/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import base64
  import math
  from io import BytesIO
  import cv2
  import numpy
  from PIL import Image
  from PIL import ImageDraw
  from PIL import ImageFont
label_desc: Use image node_id 2 for calling a global function with example usage: text_visual(texts, scores, font_file, img_h, img_w, threshold) and returns: np, blank_img,  draw_txt