class_docstr: Dataset which reads images from a local filesystem. Implements ClassyDataset.
class_docstr_tok: ["Dataset","which","reads","images","from","a","local","filesystem",".","Implements","ClassyDataset","."]
docstr: Constructor for ImagePathDataset.
  
  Only one of image_folder or image_files should be passed to specify the images.
  
  Args:
      batchsize_per_replica: Positive integer indicating batch size for each
          replica
      shuffle: Whether we should shuffle between epochs
      transform: Transform to be applied to each sample
      num_samples: When set, this restricts the number of samples provided by
          the dataset
      image_folder: A directory with one of the following structures -
          - A directory containing sub-directories with images for each target,
              which is the format expected by
              :class:`torchvision.datasets.ImageFolder` -
  
              dog/xxx.png
              dog/xxy.png
              cat/123.png
              cat/nsdf3.png
  
              In this case, the targets are inferred from the sub-directories.
          - A directory containing images -
  
              123.png
              xyz.png
  
              In this case, the targets are not returned (useful for inference).
      image_files: A list of image files -
  
          [
              "123.png",
              "dog/xyz.png",
              "/home/cat/aaa.png"
          ]
  
          In this case, the targets are not returned (useful for inference).
docstr_tok: ["Constructor","for","ImagePathDataset",".","Only","one","of","image_folder","or","image_files","should","be","passed","to","specify","the","images",".","Args",":","batchsize_per_replica",":","Positive","integer","indicating","batch","size","for","each","replica","shuffle",":","Whether","we","should","shuffle","between","epochs","transform",":","Transform","to","be","applied","to","each","sample","num_samples",":","When","set",",","this","restricts","the","number","of","samples","provided","by","the","dataset","image_folder",":","A","directory","with","one","of","the","following","structures","-","-","A","directory","containing","sub-directories","with","images","for","each","target",",","which","is","the","format","expected","by",":","class",":","`","torchvision.datasets.ImageFolder","`","-","dog\/xxx.png","dog\/xxy.png","cat\/123.png","cat\/nsdf3.png","In","this","case",",","the","targets","are","inferred","from","the","sub-directories",".","-","A","directory","containing","images","-","123.png","xyz.png","In","this","case",",","the","targets","are","not","returned","(","useful","for","inference",")",".","image_files",":","A","list","of","image","files","-","[","``","123.png","''",",","``","dog\/xyz.png","''",",","``","\/home\/cat\/aaa.png","''","]","In","this","case",",","the","targets","are","not","returned","(","useful","for","inference",")","."]
code: def __init__(
      self,
      batchsize_per_replica: int,
      shuffle: bool,
      transform: Optional[Union[ClassyTransform, Callable]] = None,
      num_samples: Optional[int] = None,
      image_folder: Optional[str] = None,
      image_files: Optional[List[str]] = None,
  ):
      """Constructor for ImagePathDataset.
  
      Only one of image_folder or image_files should be passed to specify the images.
  
      Args:
          batchsize_per_replica: Positive integer indicating batch size for each
              replica
          shuffle: Whether we should shuffle between epochs
          transform: Transform to be applied to each sample
          num_samples: When set, this restricts the number of samples provided by
              the dataset
          image_folder: A directory with one of the following structures -
              - A directory containing sub-directories with images for each target,
                  which is the format expected by
                  :class:`torchvision.datasets.ImageFolder` -
  
                  dog/xxx.png
                  dog/xxy.png
                  cat/123.png
                  cat/nsdf3.png
  
                  In this case, the targets are inferred from the sub-directories.
              - A directory containing images -
  
                  123.png
                  xyz.png
  
                  In this case, the targets are not returned (useful for inference).
          image_files: A list of image files -
  
              [
                  "123.png",
                  "dog/xyz.png",
                  "/home/cat/aaa.png"
              ]
  
              In this case, the targets are not returned (useful for inference).
      """
      if (image_folder is None) == (image_files is None):
          raise ValueError(
              "One of image_folder and image_files should be provided"
          )
      dataset, preproc_transform = _load_dataset(
          image_folder, image_files
      )
      super().__init__(
          dataset,
          batchsize_per_replica,
          shuffle,
          transform,
          num_samples,
      )
      # Some of the base datasets from _load_dataset have different
      # sample formats, the preproc_transform should map them all to
      # the dict {"input": img, "target": label} format
      if preproc_transform is not None:
          self.transform = transforms.Compose(
              [preproc_transform, self.transform]
          )
  
file_path: ClassyVision/classy_vision/dataset/image_path_dataset.py
imports: import os.path
  from typing import Any, Callable, Dict, List, Optional, Union
  from torchvision import datasets, transforms
  from .None import ClassyDataset, register_dataset
  from .core import ListDataset
  from .transforms import build_transforms, ClassyTransform, TupleToMapTransform
label_desc: Use image node_id 1 to create a new ImagePathDataset object from inherited base classes: ClassyDataset with example: obj = ImagePathDataset(batchsize_per_replica, shuffle, transform, num_samples, image_folder, image_files)