class_docstr: 自定义数据集
class_docstr_tok: ["\u81ea\u5b9a\u4e49\u6570\u636e\u96c6"]
code: def __init__(
      self, root_dir: str, csv_name: str, json_path: str, transform=None
  ):
      images_dir = os.path.join(root_dir, "images")
      assert os.path.exists(images_dir), "dir:'{}' not found.".format(
          images_dir
      )
  
      assert os.path.exists(json_path), "file:'{}' not found.".format(
          json_path
      )
      self.label_dict = json.load(open(json_path, "r"))
  
      csv_path = os.path.join(root_dir, csv_name)
      assert os.path.exists(csv_path), "file:'{}' not found.".format(
          csv_path
      )
      csv_data = pd.read_csv(csv_path)
      self.total_num = csv_data.shape[0]
      self.img_paths = [
          os.path.join(images_dir, i)
          for i in csv_data["filename"].values
      ]
      self.img_label = [
          self.label_dict[i][0] for i in csv_data["label"].values
      ]
      self.labels = set(csv_data["label"].values)
  
      self.transform = transform
  
file_path: deep-learning-for-image-processing/pytorch_classification/mini_imagenet/my_dataset.py
imports: import os
  import json
  from PIL import Image
  import pandas
  import torch
  from torch.utils.data import Dataset
label_desc: Use image node_id 1 to create a new MyDataSet object from inherited base classes: Dataset with example: obj = MyDataSet(root_dir, csv_name, json_path, transform)