@@ -39,7 +39,7 @@ This is the skeleton that you have to fill to have a custom dataset. A dataset m
39
39
* ` __init__() ` function is where the initial logic happens like reading a csv, assigning transforms etc.
40
40
* ` __getitem__() ` function returns the data and labels. This function is called from dataloader like this:
41
41
``` python
42
- img, label = CustomDataset .__getitem__ (99 ) # For 99th item
42
+ img, label = MyCustomDataset .__getitem__ (99 ) # For 99th item
43
43
```
44
44
So, the index parameter is the ** n** th data/image (as tensor) you are going to return.
45
45
@@ -60,14 +60,14 @@ class MyCustomDataset(Dataset):
60
60
def __init__ (self , ..., transforms = None ):
61
61
# stuff
62
62
...
63
- self .transform = transform
63
+ self .transforms = transforms
64
64
65
65
def __getitem__ (self , index ):
66
66
# stuff
67
67
...
68
68
data = # Some data read from a file or image
69
- if self .transform is not None :
70
- data = self .transform (data)
69
+ if self .transforms is not None :
70
+ data = self .transforms (data)
71
71
# If the transform variable is not empty
72
72
# then it applies the operations in the transforms with the order that it is created.
73
73
return (img, label)
@@ -114,8 +114,8 @@ class MyCustomDataset(Dataset):
114
114
data = self .center_crop(data) # (2)
115
115
data = self .to_tensor(data) # (2)
116
116
117
- # (3) Or you can call the composed version
118
- data = self .trasnformations(data)
117
+ # Or you can call the composed version
118
+ data = self .trasnformations(data) # (3)
119
119
120
120
# Note that you only need one of the implementations, (2) or (3)
121
121
return (img, label)
0 commit comments