code: def __init__(
      self, voc_root, year="2012", txt_name: str = "train.txt"
  ):
      assert year in [
          "2007",
          "2012",
      ], "year must be in ['2007', '2012']"
      self.root = os.path.join(voc_root, "VOCdevkit", f"VOC{year}")
      self.annotations_root = os.path.join(self.root, "Annotations")
  
      # read train.txt or val.txt file
      txt_path = os.path.join(self.root, "ImageSets", "Main", txt_name)
      assert os.path.exists(txt_path), "not found {} file.".format(
          txt_name
      )
  
      with open(txt_path) as read:
          self.xml_list = [
              os.path.join(self.annotations_root, line.strip() + ".xml")
              for line in read.readlines()
              if len(line.strip()) > 0
          ]
  
      # check file
      assert (
          len(self.xml_list) > 0
      ), "in '{}' file does not find any information.".format(txt_path)
      for xml_path in self.xml_list:
          assert os.path.exists(
              xml_path
          ), "not found '{}' file.".format(xml_path)
  
file_path: deep-learning-for-image-processing/others_project/kmeans_anchors/read_voc.py
imports: import os
  from tqdm import tqdm
  from lxml import etree
label_desc: Use image node_id 1 to create a new VOCDataSet object from inherited base classes: object with example: obj = VOCDataSet(voc_root, year, txt_name)