Replies: 3 comments
-
I noticed the same thing. The only thing I can add that might provide further insights is I tried right-clicking on the file and selected "copy path". Here is what I got: |
Beta Was this translation helpful? Give feedback.
-
Hi @MrinalKB and @mrdbourke, |
Beta Was this translation helpful? Give feedback.
-
Hi @AxisMeetsWorld and @MrinalKB , If you're having trouble with displaying the image, see the following code snippet: # Download custom image
import requests
from pathlib import Path
# Setup path to data folder
data_path = Path("data/")
data_path.mkdir(exist_ok=True)
# Setup custom image path
custom_image_path = data_path / "04-pizza-dad.jpeg"
# Download the image if it doesn't already exist
if not custom_image_path.is_file():
with open(custom_image_path, "wb") as f:
# When downloading from GitHub, need to use the "raw" file link
request = requests.get("https://raw.githubusercontent.com/mrdbourke/pytorch-deep-learning/main/images/04-pizza-dad.jpeg")
print(f"Downloading {custom_image_path}...")
f.write(request.content)
else:
print(f"{custom_image_path} already exists, skipping download.")
# Display image
from IPython.display import Image, display
display(Image(custom_image_path)) I can confirm it works in Google Colab, see this attached notebook: https://colab.research.google.com/drive/1eLCCSP38zf6EEgeFI-cdNmrgKwZfSZg8?usp=sharing Getting the raw file from the image directorySince GitHub recently changed their design, the "raw" option isn't a button anymore. So you can now just get the link via going to image and right-clicking and then selecting "Copy Image Address" option. Steps:
![]() See the new code snippet: # You can get this by right clicking on the image at: https://github.com/mrdbourke/pytorch-deep-learning/blob/main/images/04-pizza-dad.jpeg
# And selecting "copy image address"
image_address = "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/images/04-pizza-dad.jpeg?raw=true"
# Download custom image
import requests
from pathlib import Path
# Setup path to data folder
data_path = Path("data/")
data_path.mkdir(exist_ok=True)
# Setup custom image path
custom_image_path = data_path / "04-pizza-dad.jpeg"
# Download the image if it doesn't already exist
if not custom_image_path.is_file():
with open(custom_image_path, "wb") as f:
# When downloading from GitHub, need to use the "raw" file link
request = requests.get(image_address) ### <- CHANGED
print(f"Downloading {custom_image_path}...")
f.write(request.content)
else:
print(f"{custom_image_path} already exists, skipping download.")
# Display image
from IPython.display import Image, display
display(Image(custom_image_path)) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
import torchvision
custom_image_uint8 = torchvision.io.read_image(str(custom_image_path))
custom_image_uint8
error - Unsupported image file. Only jpeg and png are currently supported.
custom_image_path
- PosixPath('data/04-pizza-dad.jpeg')just as instructed in the video yet getting it wrong
Beta Was this translation helpful? Give feedback.
All reactions