code: def create_xml(
      labels: list, img_root: str, img_path: str, save_root: str
  ) -> bool:
      source_dict = {
          "database": "The WIDERFACE2017 Database",
          "annotation": "WIDERFACE 2017",
          "image": "WIDERFACE",
      }
  
      img_full_path = os.path.join(img_root, img_path)
      if os.path.exists(img_full_path):
          im = cv2.imread(img_full_path)
          im_shape = im.shape
      else:
          print(
              f"Warning: {img_path} does not exist, can't read image shape."
          )
          im_shape = (0, 0, 0)
  
      ob_list = []
      for ob in labels:
          if ob[7] == "1":
              # invalid face image, skip
              continue
  
          if int(ob[2]) <= 0 or int(ob[3]) <= 0:
              print(
                  f"Warning: find bbox w or h <= 0, in {img_path}, skip."
              )
              continue
  
          ob_dict = {
              "name": "face",
              "truncated": "0" if ob[8] == "0" else "1",
              "difficult": "1" if ob[4] == "2" or ob[8] == "2" else "0",
              "xmin": ob[0],
              "ymin": ob[1],
              "xmax": str(int(ob[0]) + int(ob[2])),
              "ymax": str(int(ob[1]) + int(ob[3])),
              "blur": ob[4],
              "expression": ob[5],
              "illumination": ob[6],
              "invalid": ob[7],
              "occlusion": ob[8],
              "pose": ob[9],
          }
  
          # if ob[7] == '1':
          #     cv2.rectangle(im, (int(ob_dict['xmin']), int(ob_dict['ymin'])),
          #                   (int(ob_dict['xmax']), int(ob_dict['ymax'])),
          #                   (0, 0, 255))
          #     cv2.imshow("s", im)
          #     cv2.waitKey(0)
  
          ob_list.append(ob_dict)
  
      if len(ob_list) == 0:
          print(f"in {img_path}, no object, skip.")
          return False
  
      create_pascal_voc_xml(
          filename=img_path,
          years="WIDERFACE2017",
          source_dict=source_dict,
          objects_list=ob_list,
          im_shape=im_shape,
          save_root=save_root,
      )
  
      return True
  
imports: import os
  from tqdm import tqdm
  import cv2
  from create_xml import create_pascal_voc_xml
label_desc: Use image node_id 1 for calling a global function with example usage: create_xml(labels, img_root, img_path, save_root) and returns: True, False