120120
121121import os
122122import pandas as pd
123- from torchvision .io import read_image
123+ from torchvision .io import decode_image
124124
125125class CustomImageDataset (Dataset ):
126126 def __init__ (self , annotations_file , img_dir , transform = None , target_transform = None ):
@@ -134,7 +134,7 @@ def __len__(self):
134134
135135 def __getitem__ (self , idx ):
136136 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 )
138138 label = self .img_labels .iloc [idx , 1 ]
139139 if self .transform :
140140 image = self .transform (image )
@@ -184,7 +184,7 @@ def __len__(self):
184184# ^^^^^^^^^^^^^^^^^^^^
185185#
186186# 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
188188# corresponding label from the csv data in ``self.img_labels``, calls the transform functions on them (if applicable), and returns the
189189# tensor image and corresponding label in a tuple.
190190
0 commit comments