code: def convert_label(label_dir, mode="gt", save_dir="./save_results/"):
      if not os.path.exists(label_dir):
          raise ValueError(f"The file {label_dir} does not exist!")
  
      assert label_dir != save_dir, "hahahhaha"
  
      label_file = open(label_dir, "r")
      data = label_file.readlines()
  
      gt_dict = {}
  
      for line in data:
          try:
              tmp = line.split("\t")
              assert len(tmp) == 2, ""
          except:
              tmp = line.strip().split("    ")
  
          gt_lists = []
  
          if tmp[0].split("/")[0] is not None:
              img_path = tmp[0]
              anno = json.loads(tmp[1])
              gt_collect = []
              for dic in anno:
                  # txt = dic['transcription'].replace(' ', '')  # ignore blank
                  txt = dic["transcription"]
                  if "score" in dic and float(dic["score"]) < 0.5:
                      continue
                  if "\u3000" in txt:
                      txt = txt.replace("\u3000", " ")
                  # while ' ' in txt:
                  #    txt = txt.replace(' ', '')
                  poly = np.array(dic["points"]).flatten()
                  if txt == "###":
                      txt_tag = 1  ## ignore 1
                  else:
                      txt_tag = 0
                  if mode == "gt":
                      gt_label = (
                          poly_to_string(poly)
                          + "\t"
                          + str(txt_tag)
                          + "\t"
                          + txt
                          + "\n"
                      )
                  else:
                      gt_label = (
                          poly_to_string(poly) + "\t" + txt + "\n"
                      )
  
                  gt_lists.append(gt_label)
  
              gt_dict[img_path] = gt_lists
          else:
              continue
  
      if not os.path.exists(save_dir):
          os.makedirs(save_dir)
  
      for img_name in gt_dict.keys():
          save_name = img_name.split("/")[-1]
          save_file = os.path.join(save_dir, save_name + ".txt")
          with open(save_file, "w") as f:
              f.writelines(gt_dict[img_name])
  
      print("The convert label saved in {}".format(save_dir))
  
imports: import numpy
  import json
  import os
label_desc: Use image node_id 2 for calling a global function with example usage: convert_label(label_dir, mode, save_dir) without return types