saraz
October 11, 2018, 12:02pm
1
To be concise, the following works:
import imageio
img = imageio.imread('myimage.jpg')
print(img.shape)
which returns
(400, 640, 3)
However, when I run the following:
import tensorrt
import imageio
img = imageio.imread('myimage.jpg')
I get the following error
ValueError: Could not load “”
Reason: “broken data stream when reading image file”
Please see documentation at: Installation - Pillow (PIL Fork) 9.3.0.dev0 documentation
It is also the case with other jpeg readers like scipy.misc.imread.
Any thoughts on that?
PS: below is the version of some (possibly) relevant packages:
Tensorrt: 4.0.0.3
uff: 0.2.0
tensorflow: 1.7.0 (GPU)
PIL: 5.2.0
imageio: 2.4.1
Ubuntu 16.04
x86_64
Tesla P100
Try changing the order of imports
NVES
October 11, 2018, 5:38pm
3
Hello,
I’m not able to repro your error.
root@02db90da60f1:/mnt# dpkg -l | grep nvinfer
ii libnvinfer-dev 4.1.2-1+cuda9.0 amd64 TensorRT development libraries and headers
ii libnvinfer-samples 4.1.2-1+cuda9.0 amd64 TensorRT samples and documentation
ii libnvinfer4 4.1.2-1+cuda9.0 amd64 TensorRT runtime libraries
ii python3-libnvinfer 4.1.2-1+cuda9.0 amd64 Python 3 bindings for TensorRT
ii python3-libnvinfer-dev 4.1.2-1+cuda9.0 amd64 Python 3 development package for TensorRT
ii python3-libnvinfer-doc 4.1.2-1+cuda9.0 amd64 Documention and samples of python bindings for TensorRT
root@02db90da60f1:/mnt# cat working.py
import imageio
img = imageio.imread('source.jpg')
print(img.shape)root@02db90da60f1:/mnt# cat not.working.py
import tensorrt
import imageio
img = imageio.imread('source.jpg')
print(img.shape)root@02db90da60f1:/mnt# python working.py
(810, 1080, 3)
root@02db90da60f1:/mnt# python not.working.py
(810, 1080, 3)
saraz
October 12, 2018, 7:43am
4
Yes, this solved it. Thank you.
With the previous import order (first tensorrt and then imageio) I could read other image formats (like png) but not jpg.