2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Tensorflowで"DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01)."が表示された時の回避策

Posted at

フレームワークを作っているのですが、ちょっと前から以下の警告文が出るようになりました。

\lib\site-packages\flatbuffers\compat.py:19: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
\lib\site-packages\keras\utils\image_utils.py:36: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.
  'nearest': pil_image.NEAREST,
\lib\site-packages\keras\utils\image_utils.py:37: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILI  'bilinear': pil_image.BILINEAR,
\lib\site-packages\keras\utils\image_utils.py:38: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.
  'bicubic': pil_image.BICUBIC,
\lib\site-packages\keras\utils\image_utils.py:39: DeprecationWarning: HAMMING is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.HAMMING instead.
  'hamming': pil_image.HAMMING,
\lib\site-packages\keras\utils\image_utils.py:40: DeprecationWarning: BOX is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BOX instead.
  'box': pil_image.BOX,
\lib\site-packages\keras\utils\image_utils.py:41: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
  'lanczos': pil_image.LANCZOS,

今回回避策が分かったので備忘録として記事にしたいと思います。

再現コード

  • version
Python 3.9.13
gym                          0.24.1
tensorflow-gpu               2.9.1
Pillow                       9.1.1
flatbuffers                  1.12
  • コード
import gym
import tensorflow
# 警告が表示される

なお、これは警告を非表示にしても表示されます。

import warnings

warnings.simplefilter("ignore")

import gym
import tensorflow
# 警告が表示される

回避策

根本原因は分かりません。
ただ、gymをimportした後にtensorflowをimportをすると表示されるようです。
順番を逆にすると表示されません。

import tensorflow
import gym
# 警告は表示されなくなる

isortを使っているとgymが上にくるのでちょっと厄介です…。
警告内容的にそのうち解決しそうな気もします。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?