class_docstr: 读取解析PASCAL VOC2007/2012数据集
class_docstr_tok: ["\u8bfb\u53d6\u89e3\u6790PASCAL","VOC2007\/2012\u6570\u636e\u96c6"]
docstr: 该方法是专门为pycocotools统计标签信息准备，不对图像和标签作任何处理
  由于不用去读取图片，可大幅缩减统计时间
  
  Args:
      idx: 输入需要获取图像的索引
docstr_tok: ["\u8be5\u65b9\u6cd5\u662f\u4e13\u95e8\u4e3apycocotools\u7edf\u8ba1\u6807\u7b7e\u4fe1\u606f\u51c6\u5907\uff0c\u4e0d\u5bf9\u56fe\u50cf\u548c\u6807\u7b7e\u4f5c\u4efb\u4f55\u5904\u7406","\u7531\u4e8e\u4e0d\u7528\u53bb\u8bfb\u53d6\u56fe\u7247\uff0c\u53ef\u5927\u5e45\u7f29\u51cf\u7edf\u8ba1\u65f6\u95f4","Args",":","idx",":","\u8f93\u5165\u9700\u8981\u83b7\u53d6\u56fe\u50cf\u7684\u7d22\u5f15"]
code: def coco_index(self, idx):
      """
      该方法是专门为pycocotools统计标签信息准备，不对图像和标签作任何处理
      由于不用去读取图片，可大幅缩减统计时间
  
      Args:
          idx: 输入需要获取图像的索引
      """
      # read xml
      xml_path = self.xml_list[idx]
      with open(xml_path) as fid:
          xml_str = fid.read()
      xml = etree.fromstring(xml_str)
      data = self.parse_xml_to_dict(xml)["annotation"]
      data_height = int(data["size"]["height"])
      data_width = int(data["size"]["width"])
      height_width = [data_height, data_width]
      # img_path = os.path.join(self.img_root, data["filename"])
      # image = Image.open(img_path)
      # if image.format != "JPEG":
      #     raise ValueError("Image format not JPEG")
      boxes = []
      labels = []
      iscrowd = []
      for obj in data["object"]:
          # 将所有的gt box信息转换成相对值0-1之间
          xmin = float(obj["bndbox"]["xmin"]) / data_width
          xmax = float(obj["bndbox"]["xmax"]) / data_width
          ymin = float(obj["bndbox"]["ymin"]) / data_height
          ymax = float(obj["bndbox"]["ymax"]) / data_height
          boxes.append([xmin, ymin, xmax, ymax])
          labels.append(self.class_dict[obj["name"]])
          iscrowd.append(int(obj["difficult"]))
  
      # convert everything into a torch.Tensor
      boxes = torch.as_tensor(boxes, dtype=torch.float32)
      labels = torch.as_tensor(labels, dtype=torch.int64)
      iscrowd = torch.as_tensor(iscrowd, dtype=torch.int64)
      height_width = torch.as_tensor(height_width, dtype=torch.int64)
      image_id = torch.tensor([idx])
      area = (boxes[:, 3] - boxes[:, 1]) * (boxes[:, 2] - boxes[:, 0])
  
      target = {}
      target["boxes"] = boxes
      target["labels"] = labels
      target["image_id"] = image_id
      target["area"] = area
      target["iscrowd"] = iscrowd
      target["height_width"] = height_width
  
      return target
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/ssd/my_dataset.py
imports: from torch.utils.data import Dataset
  import os
  import torch
  import json
  from PIL import Image
  from lxml import etree
label_desc: Use image node_id 6 for calling the VOCDataSet obj's underlying member method code with example usage: obj.coco_index(idx) and returns: target