Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning thrown in utils.image_utils #582

Closed
johnthagen opened this issue Jun 2, 2022 · 11 comments
Closed

DeprecationWarning thrown in utils.image_utils #582

johnthagen opened this issue Jun 2, 2022 · 11 comments
Assignees

Comments

@johnthagen
Copy link

johnthagen commented Jun 2, 2022

System information.

  • Have I written custom code (as opposed to using a stock example script provided in Keras): Yes, simple.
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 11.6
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): v2.9.0-18-gd8ce9f9c301 2.9.1
  • Python version: 3.19.13
  • Bazel version (if compiling from source): N/A
  • GPU model and memory: AMD Radeon Pro 5500M 4 GB
  • Exact command to reproduce:
import tensorflow.lite as tflite
python -Werror main.py

Describe the problem.

Teras is using a deprecated feature of Pillow.

https://github.com/keras-team/keras/blob/3613c3defc39c236fb1592c4f7ba1a9cc887343a/keras/utils/image_utils.py#L38

Describe the current behavior.

    import tensorflow.lite as tflite
python3.9/site-packages/tensorflow/__init__.py:473: in <module>
    keras._load()
python3.9/site-packages/tensorflow/python/util/lazy_loader.py:41: in _load
    module = importlib.import_module(self.__name__)
/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
python3.9/site-packages/keras/__init__.py:24: in <module>
    from keras import models
python3.9/site-packages/keras/models/__init__.py:18: in <module>
    from keras.engine.functional import Functional
python3.9/site-packages/keras/engine/functional.py:23: in <module>
    from keras import backend
python3.9/site-packages/keras/backend.py:43: in <module>
    from keras.engine import keras_tensor
python3.9/site-packages/keras/engine/keras_tensor.py:17: in <module>
    from keras.utils import object_identity
python3.9/site-packages/keras/utils/__init__.py:20: in <module>
    from keras.utils.image_dataset import image_dataset_from_directory
python3.9/site-packages/keras/utils/image_dataset.py:22: in <module>
    from keras.utils import image_utils
python3.9/site-packages/keras/utils/image_utils.py:36: in <module>
    'nearest': pil_image.NEAREST,
python3.9/site-packages/PIL/Image.py:67: in __getattr__
    warnings.warn(
E   DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.

I am testing with Pillow 9.1.1.

Describe the expected behavior.

No DeprecationWarnings are raised when using keras.

Contributing.

  • Do you want to contribute a PR? (yes/no):
  • If yes, please read this page for instructions
  • Briefly describe your candidate solution(if contributing):
@gadagashwini
Copy link
Contributor

Hi @johnthagen, Could you share the minimal reproducible code snippet to investigate the reported issue. Thank you!

@johnthagen
Copy link
Author

@gadagashwini Please see the code and command under "Exact command to reproduce:" in the original post.

@gadagashwini
Copy link
Contributor

Hi @johnthagen, I executed import tensorflow.lite as tflite on colab I didn’t get any error. Request you to try again. Thank you!

@johnthagen
Copy link
Author

@gadagashwini Did you execute the Python script with -Werror?

python -Werror main.py

@gadagashwini
Copy link
Contributor

Hi @johnthagen, Could you share the main.py file. Thank you

@johnthagen
Copy link
Author

johnthagen commented Jun 10, 2022

  1. pip install tensorflow into a Python virtual environment
  2. Create a file named main.py
  3. Within this file, add the contents:
import tensorflow
  1. Execute the script with -Werror
python -Werror main.py

This will show the DeprecationWarning noted in the original comment. I also linked to the line of code in this repo where the deprecated usage is in the original comment.

My exact environment (tested on macOS x86_64):

Package                      Version
---------------------------- -----------
absl-py                      1.1.0
astunparse                   1.6.3
cachetools                   5.2.0
certifi                      2022.5.18.1
charset-normalizer           2.0.12
flatbuffers                  1.12
gast                         0.4.0
google-auth                  2.7.0
google-auth-oauthlib         0.4.6
google-pasta                 0.2.0
grpcio                       1.46.3
h5py                         3.7.0
idna                         3.3
importlib-metadata           4.11.4
keras                        2.9.0
Keras-Preprocessing          1.1.2
libclang                     14.0.1
Markdown                     3.3.7
numpy                        1.22.4
oauthlib                     3.2.0
opt-einsum                   3.3.0
packaging                    21.3
pip                          22.1.2
protobuf                     3.19.4
pyasn1                       0.4.8
pyasn1-modules               0.2.8
pyparsing                    3.0.9
requests                     2.28.0
requests-oauthlib            1.3.1
rsa                          4.8
setuptools                   62.3.3
six                          1.16.0
tensorboard                  2.9.1
tensorboard-data-server      0.6.1
tensorboard-plugin-wit       1.8.1
tensorflow                   2.9.1
tensorflow-estimator         2.9.0
tensorflow-io-gcs-filesystem 0.26.0
termcolor                    1.1.0
typing_extensions            4.2.0
urllib3                      1.26.9
Werkzeug                     2.1.2
wheel                        0.37.1
wrapt                        1.14.1
zipp                         3.8.0

@gadagashwini
Copy link
Contributor

Hi @johnthagen, You can safely ignore these deprecated warnings.
Suppress these warnings by turning off

import logging, os
logging.disable(logging.WARNING)
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
import tensorflow as tf

Thank you!

@johnthagen
Copy link
Author

@gadagashwini Yes, we are suppressing them, but since this will eventually cause breakage with a future Pillow release, it seemed like something that should be addressed in keras?

@leonardschneider
Copy link

This shows up in pytest warnings as well :(

@haifeng-jin
Copy link
Contributor

It is fixed by keras-team/keras#16746 on master.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@fchollet fchollet transferred this issue from keras-team/keras Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants