120
120
121
121
import os
122
122
import pandas as pd
123
- from torchvision .io import read_image
123
+ from torchvision .io import decode_image
124
124
125
125
class CustomImageDataset (Dataset ):
126
126
def __init__ (self , annotations_file , img_dir , transform = None , target_transform = None ):
@@ -134,7 +134,7 @@ def __len__(self):
134
134
135
135
def __getitem__ (self , idx ):
136
136
img_path = os .path .join (self .img_dir , self .img_labels .iloc [idx , 0 ])
137
- image = read_image (img_path )
137
+ image = decode_image (img_path )
138
138
label = self .img_labels .iloc [idx , 1 ]
139
139
if self .transform :
140
140
image = self .transform (image )
@@ -184,7 +184,7 @@ def __len__(self):
184
184
# ^^^^^^^^^^^^^^^^^^^^
185
185
#
186
186
# The __getitem__ function loads and returns a sample from the dataset at the given index ``idx``.
187
- # Based on the index, it identifies the image's location on disk, converts that to a tensor using ``read_image ``, retrieves the
187
+ # Based on the index, it identifies the image's location on disk, converts that to a tensor using ``decode_image ``, retrieves the
188
188
# corresponding label from the csv data in ``self.img_labels``, calls the transform functions on them (if applicable), and returns the
189
189
# tensor image and corresponding label in a tuple.
190
190
0 commit comments