Skip to content

Commit ad79607

Browse files
committed
Load image from torchvision.assets (not working yet)
1 parent 5108c1e commit ad79607

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

torchvision/assets/__init__.py

Whitespace-only changes.
72 KB
Loading

torchvision/utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,22 @@ def save_image(tensor, fp, nrow=8, padding=2,
112112

113113

114114
def _sample_image():
115+
"""Private helper function to load a sample PIL image.
116+
117+
This function might change and/or break. Don't depend on it.
118+
"""
119+
import os.path
115120
from PIL import Image
116-
# TODO properly load the image
117-
return Image.open("/tmp/grace_hopper_517x606.jpg")
121+
122+
data_dir = os.path.abspath(os.path.dirname(__file__))
123+
return Image.open(os.path.join(data_dir, "assets", "grace_hopper_517x606.jpg"))
118124

119125

120126
def _plot_images(*imgs):
127+
"""Private helper function to display images in the docs.
128+
129+
This function might change and/or break. Don't depend on it.
130+
"""
121131
import matplotlib.pyplot as plt
122132
import matplotlib
123133

0 commit comments

Comments
 (0)