Git Product home page Git Product logo

Comments (9)

aymericdamien avatar aymericdamien commented on May 16, 2024

Hey, can you please send me the error message?
PIL is used for some pre-processing and utility functions in TFLearn.

from tflearn.

DongjunLee avatar DongjunLee commented on May 16, 2024

i test it on jupyter notebook.

import tflearn
import numpy as np
from PIL import Image

img_path = "...img_path..."
Image.open(img_path)

Error log:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.pyc in __call__(self, obj)
    341             method = _safe_get_formatter_method(obj, self.print_method)
    342             if method is not None:
--> 343                 return method()
    344             return None
    345         else:

/usr/local/lib/python2.7/dist-packages/PIL/Image.pyc in _repr_png_(self)
    617         from io import BytesIO
    618         b = BytesIO()
--> 619         self.save(b, 'PNG')
    620         return b.getvalue()
    621 

/usr/local/lib/python2.7/dist-packages/PIL/Image.pyc in save(self, fp, format, **params)
   1656 
   1657         # may mutate self!
-> 1658         self.load()
   1659 
   1660         save_all = False

/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.pyc in load(self)
    233         if not self.map and not LOAD_TRUNCATED_IMAGES and e < 0:
    234             # still raised if decoder fails to return anything
--> 235             raise_ioerror(e)
    236 
    237         # post processing

/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.pyc in raise_ioerror(error)
     57     if not message:
     58         message = "decoder error %d" % error
---> 59     raise IOError(message + " when reading image file")
     60 
     61 

IOError: broken data stream when reading image file

Out[1] : <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=84x256 at 0x7FDF4DA8EC10>
import numpy as np
from PIL import Image

img_path = "...img_path..."
Image.open(img_path)

Out[1] : display image

from tflearn.

aymericdamien avatar aymericdamien commented on May 16, 2024

I think this is an issue with PIL, maybe try to update pillow.

from tflearn.

DongjunLee avatar DongjunLee commented on May 16, 2024

pillow version is 3.2.0.(latest)
so.. i reinstall pillow but, result is same.

from tflearn.

aymericdamien avatar aymericdamien commented on May 16, 2024

You can try to

sudo apt-get install libjpeg8-dev

And reinstall pillow

from tflearn.

DongjunLee avatar DongjunLee commented on May 16, 2024

libjpeg8-dev is already the newest version.

I also reinstall libjpeg8-dev and Pillow.
result is same.

My desktop's os is Ubuntu 14.04 LTS.
I will debug this problem.
When i figure it out, i'll tell you.

from tflearn.

aymericdamien avatar aymericdamien commented on May 16, 2024

Ok thanks!

from tflearn.

DongjunLee avatar DongjunLee commented on May 16, 2024

This problem is tensorflow's Issue.

TensorFlow_0.8.0 somehow breaks PIL ? #2101
scikit-image/scikit-image#2000

Simple solution is

from PIL import Image
import tensorflow as tf

or
Use TensorFlow 0.7.1 version. (It is the 0.8.0 version's problem)

from tflearn.

panovr avatar panovr commented on May 16, 2024

I can confirm this error when running alexnet.py with TensorFlow 0.8:
Starting to parse images... Traceback (most recent call last): File "alexnet.py", line 27, in <module> X, Y = oxflower17.load_data(one_hot=True) File "/usr/local/lib/python2.7/dist-packages/tflearn/datasets/oxflower17.py", line 34, in load_data categorical_Y=one_hot) File "/usr/local/lib/python2.7/dist-packages/tflearn/data_utils.py", line 227, in build_image_dataset_from_dir X, Y = image_dirs_to_samples(directory, resize, convert_gray, filetypes) File "/usr/local/lib/python2.7/dist-packages/tflearn/data_utils.py", line 210, in image_dirs_to_samples samples[i] = resize_image(samples[i], resize[0], resize[1]) File "/usr/local/lib/python2.7/dist-packages/tflearn/data_utils.py", line 184, in resize_image img = in_image.resize((new_width, new_height), resize_mode) File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1538, in resize self.load() File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 235, in load raise_ioerror(e) File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 59, in raise_ioerror raise IOError(message + " when reading image file") IOError: broken data stream when reading image file
And import PIL before TensorFlow fixed this error.

from tflearn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.