"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "6028613226e6048c3bee1f306678fca61565f20d"
Unverified Commit 744e37d7 authored by Aditya Oke's avatar Aditya Oke Committed by GitHub
Browse files

Add Docs for `VisionDataset` (#3863)



* fix

* add docs for VisionDataset

* add getitem

* add deprecated note to transform

* Update torchvision/datasets/vision.py
Co-authored-by: default avatarPhilip Meier <github.pmeier@posteo.de>

* fix docs

* Update torchvision/datasets/vision.py

* flake8
Co-authored-by: default avatarNicolas Hug <nicolashug@fb.com>
Co-authored-by: default avatarPhilip Meier <github.pmeier@posteo.de>
Co-authored-by: default avatarVasilis Vryniotis <datumbox@users.noreply.github.com>
parent c6c5a5f5
...@@ -258,3 +258,7 @@ Base classes for custom datasets ...@@ -258,3 +258,7 @@ Base classes for custom datasets
.. autoclass:: ImageFolder .. autoclass:: ImageFolder
:members: __getitem__ :members: __getitem__
:special-members: :special-members:
.. autoclass:: VisionDataset
:members: __getitem__
:special-members:
...@@ -5,6 +5,23 @@ from typing import Any, Callable, List, Optional, Tuple ...@@ -5,6 +5,23 @@ from typing import Any, Callable, List, Optional, Tuple
class VisionDataset(data.Dataset): class VisionDataset(data.Dataset):
"""
Base Class For making datasets which are compatible with torchvision.
It is necessary to override the ``__getitem__`` and ``__len__`` method.
Args:
root (string): Root directory of dataset.
transforms (callable, optional): A function/transforms that takes in
an image and a label and returns the transformed versions of both.
transform (callable, optional): A function/transform that takes in an 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.
.. note::
:attr:`transforms` and the combination of :attr:`transform` and :attr:`target_transform` are mutually exclusive.
"""
_repr_indent = 4 _repr_indent = 4
def __init__( def __init__(
...@@ -33,6 +50,13 @@ class VisionDataset(data.Dataset): ...@@ -33,6 +50,13 @@ class VisionDataset(data.Dataset):
self.transforms = transforms self.transforms = transforms
def __getitem__(self, index: int) -> Any: def __getitem__(self, index: int) -> Any:
"""
Args:
index (int): Index
Returns:
(Any): Sample and meta data, optionally transformed by the respective transforms.
"""
raise NotImplementedError raise NotImplementedError
def __len__(self) -> int: def __len__(self) -> int:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment