question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

torchvision.io.read_image() fails to read image

See original GitHub issue

🐛 Describe the bug

import torch
import torchvision.io as io
image = io.read_image('./1.png')

This minimal example does not work. I have tried many different versions of torch with different versions of python. It was working previously, and now it fails after doing the update.

Some of the errors that I got are: RuntimeError: No such operator image::read_file

I also tried the same in python3.7.11 and torchvision 0.8 and got RuntimeError: Non RGB images are not supported.

Versions

Collecting environment information… PyTorch version: 1.10.0 Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A

OS: macOS 11.6 (x86_64) GCC version: Could not collect Clang version: 13.0.0 (clang-1300.0.29.3) CMake version: Could not collect Libc version: N/A

Python version: 3.8.8 (default, Apr 13 2021, 12:59:45) [Clang 10.0.0 ] (64-bit runtime) Python platform: macOS-10.16-x86_64-i386-64bit Is CUDA available: False CUDA runtime version: No CUDA GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A

Versions of relevant libraries: [pip3] mypy-extensions==0.4.3 [pip3] numpy==1.20.1 [pip3] numpydoc==1.1.0 [pip3] torch==1.10.0 [pip3] torchaudio==0.10.0 [pip3] torchvision==0.11.1 [conda] blas 1.0 mkl
[conda] ffmpeg 4.3 h0a44026_0 pytorch [conda] mkl 2021.2.0 hecd8cb5_269
[conda] mkl-service 2.3.0 py38h9ed2024_1
[conda] mkl_fft 1.3.0 py38h4a7008c_2
[conda] mkl_random 1.2.1 py38hb2f4e1b_2
[conda] mypy_extensions 0.4.3 py38_0
[conda] numpy 1.20.1 py38hd6e1bb9_0
[conda] numpy-base 1.20.1 py38h585ceec_0
[conda] numpydoc 1.1.0 pyhd3eb1b0_1
[conda] pytorch 1.10.0 py3.8_0 pytorch [conda] torchaudio 0.10.0 py38_cpu pytorch [conda] torchvision 0.11.1 py38_cpu pytorch

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
cainiaoupcommented, Dec 2, 2021

you can use opencv to load your image .

  1. pip install opencv-python
  2. let cv.imread(img_path) instand of read_image(img_path)
1reaction
malfetcommented, Nov 1, 2021

@NicolasHug we don’t build publish M1 binaries to conda, although we probably should

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error with torchvision.io.read_image with models #2788 - GitHub
Since torchvision.io.read_image will read normalized images only. # from PIL import Image, ImageDraw import torch from torchvision.models.
Read more >
torchvision.io's read_image does not work - Stack Overflow
I'm trying to make a NN do the training over a dataset that I have. I'm creating a CustomDataset, using more or less...
Read more >
Reading/Writing images and videos - PyTorch
The torchvision.io package provides functions for performing IO operations. They are currently specific to reading and writing video and images.
Read more >
The Devil lives in the details | capeblog
read_image and the torchvision.transforms.Resize . This transform can accept PIL.Image.Image or Tensors, in short, the resizing does not produce ...
Read more >
torchvision.io.read_image_取个名字真难呐的博客
输出张量的值是uint8,在0到255之间torchvision.io.read_image(path: str, mode: torchvision.io.image.ImageReadMode = <ImageReadMode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found