Skip to content

Commit 20bf27e

Browse files
authored
Replacing obsolete function in data tutorials (#3371)
Replacing obsolete function read_image with its up-to-date equivalent decode_image in data tutorials
1 parent ddd40ec commit 20bf27e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

beginner_source/basics/data_tutorial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120

121121
import os
122122
import pandas as pd
123-
from torchvision.io import read_image
123+
from torchvision.io import decode_image
124124

125125
class 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

Comments
 (0)