Package: customVOC
Custom Pascal VOC PyTorch ModuleThis PyTorch module serves as a flexible  dataset reader for custom datasets created using the Pascal VOC format. It is a modified version of the originalPascal VOC dataset readerprovided by PyTorch'storchvisionpackage. The primary enhancement is the removal of folder structure restrictions, allowing users to read datasets organized in any manner while still leveraging the Pascal VOC annotation structure.ClassesThe module includes two classes:VOCDetectionandVOCSegmentation.VOCDetection:This class is designed for reading datasets followingPascal VOCDetection format.VOCDetection(root:str,image_set:str='train',transform:Optional[Callable]=None,target_transform:Optional[Callable]=None,transforms:Optional[Callable]=None)Parameters:root(string): Root directory of the VOC Dataset.image_set(string, optional): Select the image_set to use,"train","val"or"test".transform(callable, optional): A function/transform that takes in a PIL image and returns a transformed version. E.g,transforms.RandomCrop.target_transform(callable, required): A function/transform that takes in the target and transforms it.transforms(callable, optional): A function/transform that takes input sample and its target as entry and returns a transformed version.VOCSegmentationThis class is tailored for reading datasets structured in thePascal VOCSegmentation format.VOCSegmentation(root:str,image_set:str='train',transform:Optional[Callable]=None,target_transform:Optional[Callable]=None,transforms:Optional[Callable]=None)Parameters:root (string): Root directory of the VOC Dataset.image_set (string, optional): Select the image_set to use,"train","val"or"test".transform (callable, optional): A function/transform that  takes in a PIL image and returns a transformed version. E.g,transforms.RandomCrop.target_transform (callable, optional): A function/transform that takes in the target and transforms it.transforms (callable, optional): A function/transform that takes input sample and its target as entry and returns a transformed version.InstallingYou can install the package frompypiusing the following code:pip install --update customVOCUsing customVOCAfter installing the module, you can import either of the two classes: 'VOCDetection' and 'VOCSegmentation'.fromcustomVOCimportVOCDetectionfromcustomVOCimportVOCSegmentationOnce imported, you can use these classes similarly to the ones from the torchvision package, without passing the year. When initializing, provide the root folder containing the dataset with one of the following subfolders:"train","val", or"test"depending on the dataset portion you are using.The following example loads the training dataset and converts the image to a tensor usingToTensor():fromcustomVOCimportVOCDetectionfromtorchvision.transformsimportToTensorfromtorch.utils.dataimportDataLoader# Create an instance of VOCDetection dataset.voc_dataset=VOCDetection(root="datset_path",image_set="train",transform=ToTensor())# Create a DataLoader for the VOCDetection dataset.data_loader=DataLoader(voc_dataset,batch_size=4,shuffle=True,collate_fn=lambdabatch:tuple(zip(*batch)))[!TIP]The collate function is used to customize how batches are created from individual samples in the dataset.[!NOTE]The package is an absolute copy of the original code, with modifications to the way of reading image and annotation files locations.The images and annotations files should be stored in the same folder, either train, val, or test, depending on what part of the dataset you have.OnlyVOCDetectionhas been tested on reading datasets.