class_docstr: Load your own video classification dataset.
class_docstr_tok: ["Load","your","own","video","classification","dataset","."]
code: def __init__(
      self,
      anno_path,
      data_path,
      mode="train",
      clip_len=8,
      frame_sample_rate=2,
      crop_size=224,
      short_side_size=256,
      new_height=256,
      new_width=340,
      keep_aspect_ratio=False,
      num_segment=1,
      num_crop=1,
      test_num_segment=10,
      test_num_crop=3,
      use_multigrid=False,
  ):
      self.anno_path = anno_path
      self.data_path = data_path
      self.mode = mode
      self.clip_len = clip_len
      self.frame_sample_rate = frame_sample_rate
      self.crop_size = crop_size
      self.short_side_size = short_side_size
      self.new_height = new_height
      self.new_width = new_width
      self.keep_aspect_ratio = keep_aspect_ratio
      self.num_segment = num_segment
      self.test_num_segment = test_num_segment
      self.num_crop = num_crop
      self.test_num_crop = test_num_crop
      self.use_multigrid = use_multigrid and (mode == "train")
      if VideoReader is None:
          raise ImportError(
              "Unable to import `decord` which is required to read videos."
          )
  
      import pandas as pd
  
      cleaned = pd.read_csv(self.anno_path, header=None, delimiter=" ")
      self.dataset_samples = list(cleaned.values[:, 0])
      self.label_array = list(cleaned.values[:, 2])
  
      if mode == "train":
          if self.use_multigrid:
              self.mg_helper = multiGridHelper()
              self.data_transform = []
              for alpha in range(self.mg_helper.mod_long):
                  tmp = []
                  for beta in range(self.mg_helper.mod_short):
                      info = self.mg_helper.get_resize(alpha, beta)
                      scale_s = info[1]
                      tmp.append(
                          video_transforms.Compose(
                              [
                                  video_transforms.Resize(
                                      int(
                                          self.short_side_size / scale_s
                                      ),
                                      interpolation="bilinear",
                                  ),
                                  # TODO: multiscale corner cropping
                                  video_transforms.RandomResize(
                                      ratio=(1, 1.25),
                                      interpolation="bilinear",
                                  ),
                                  video_transforms.RandomCrop(
                                      size=(
                                          int(self.crop_size / scale_s),
                                          int(self.crop_size / scale_s),
                                      )
                                  ),
                              ]
                          )
                      )
                  self.data_transform.append(tmp)
          else:
              self.data_transform = video_transforms.Compose(
                  [
                      video_transforms.Resize(
                          int(self.short_side_size),
                          interpolation="bilinear",
                      ),
                      video_transforms.RandomResize(
                          ratio=(1, 1.25), interpolation="bilinear"
                      ),
                      video_transforms.RandomCrop(
                          size=(
                              int(self.crop_size),
                              int(self.crop_size),
                          )
                      ),
                  ]
              )
  
          self.data_transform_after = video_transforms.Compose(
              [
                  video_transforms.RandomHorizontalFlip(),
                  volume_transforms.ClipToTensor(),
                  video_transforms.Normalize(
                      mean=[0.485, 0.456, 0.406],
                      std=[0.229, 0.224, 0.225],
                  ),
              ]
          )
      elif mode == "validation":
          self.data_transform = video_transforms.Compose(
              [
                  video_transforms.Resize(
                      self.short_side_size, interpolation="bilinear"
                  ),
                  video_transforms.CenterCrop(
                      size=(self.crop_size, self.crop_size)
                  ),
                  volume_transforms.ClipToTensor(),
                  video_transforms.Normalize(
                      mean=[0.485, 0.456, 0.406],
                      std=[0.229, 0.224, 0.225],
                  ),
              ]
          )
      elif mode == "test":
          self.data_resize = video_transforms.Compose(
              [
                  video_transforms.Resize(
                      size=(short_side_size), interpolation="bilinear"
                  )
              ]
          )
          self.data_transform = video_transforms.Compose(
              [
                  volume_transforms.ClipToTensor(),
                  video_transforms.Normalize(
                      mean=[0.485, 0.456, 0.406],
                      std=[0.229, 0.224, 0.225],
                  ),
              ]
          )
          self.test_seg = []
          self.test_dataset = []
          self.test_label_array = []
          for ck in range(self.test_num_segment):
              for cp in range(self.test_num_crop):
                  for idx in range(len(self.label_array)):
                      sample_label = self.label_array[idx]
                      self.test_label_array.append(sample_label)
                      self.test_dataset.append(
                          self.dataset_samples[idx]
                      )
                      self.test_seg.append((ck, cp))
  
file_path: gluon-cv/gluoncv/torch/data/video_cls/dataset_classification.py
imports: import os
  import warnings
  import numpy
  import torch
  from torch.utils.data import Dataset
  from ..transforms.videotransforms import video_transforms, volume_transforms
  from .multigrid_helper import multiGridHelper, MultiGridBatchSampler
label_desc: Use image node_id 1 to create a new VideoClsDataset object from inherited base classes: Dataset with example: obj = VideoClsDataset(anno_path, data_path, mode, clip_len, frame_sample_rate, crop_size, short_side_size, new_height, new_width, keep_aspect_ratio, num_segment, num_crop, test_num_segment, test_num_crop, use_multigrid)