Loading Image datasets in custom data loader

shubz_308: <p>Hello<br>
I read up the pytorch tutorials on custom dataloaders but most of them are written considering the dataset is in a csv format.<br>
I found a few datasets like Leed Sports Database.They just have images in zip file as data and visualized folder.I do not understand how to load these in a custom dataloader.Same goes for MNIST and FashionMNIST.I found their ubyte files on their website but i have totally no clue on how to access them via the customdataloader.<br>
Can anyone explain this in more detail,I am not familiar with all python commands so it might be possible i am missing out an obvious command for this thati should be knowing</p>

eqy: <p>If the dataset has images in folders/directories corresponding to classes, it might map nicely to an ImageFolder:<br>
<a href="http://pytorch.org/vision/main/generated/torchvision.datasets.ImageFolder.html" rel="noopener nofollow ugc">ImageFolder — Torchvision main documentation (pytorch.org)</a></p>

Eta_C: <p>Try <code>torchvision</code> .</p>
<p><a href="https://pytorch.org/vision/stable/datasets.html#torchvision.datasets.FashionMNIST" rel="noopener nofollow ugc">torchvision.datasets.FashionMNIST</a><br>
<a href="https://pytorch.org/vision/stable/datasets.html#torchvision.datasets.MNIST" rel="noopener nofollow ugc">torchvision.datasets.MNIST</a><br>
<a href="https://github.com/bmartacho/UniPose/blob/a8a101ab64ee6066189814b2ca3669b5f19cd877/utils/lsp_lspet_data.py#L180-L249" rel="noopener nofollow ugc">LSP(Leed Sports Pose) Dataset</a></p>

shubz_308: <p>Thanks i understood it</p>

shubz_308: <p>The leed sports database looks very complicated to understand.The dataset on ther website has images,visualized and a mat file.Are the training and test samples in the mat file?<br>
Can you give a small summary of what to do when doing it with a customdataloader</p>

Eta_C: <pre><code class="lang-auto">class CustomDataset(Dataset):
    def __init__(self, some_args):
        # We can do anything here. For example:
        # 1. list files
        # 2. load all data (not recommended for big data)
        # 3. define transforms
        # ... 
    
    def __getitem__(self, item):
        # load one sample, apply transforms, return image, and label 

    def __len__(self):
        # return len(data)
</code></pre>
<p>Here are some examples:</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/utkuozbulak/pytorch-custom-dataset-examples">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/utkuozbulak/pytorch-custom-dataset-examples" target="_blank" rel="noopener nofollow ugc">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/345;"><img src="https://opengraph.githubassets.com/c64476b5b109d00aad6d94e640ccb4ba5813a1f0569b80193729ee71cb775fe4/utkuozbulak/pytorch-custom-dataset-examples" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/utkuozbulak/pytorch-custom-dataset-examples" target="_blank" rel="noopener nofollow ugc">GitHub - utkuozbulak/pytorch-custom-dataset-examples: Some custom dataset...</a></h3>

  <p>Some custom dataset examples for PyTorch. Contribute to utkuozbulak/pytorch-custom-dataset-examples development by creating an account on GitHub.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


shubz_308: <p>Thanks i will try to experiment writing it and figure it out</p>