Tag Archives: Tensorflow learning

“Could not import PIL.Image . The use of array_ to_ The solution of img requires PIL. “

Based on dataset training_ According to the structure provided, CNN model is established to identify the cat / dog in the picture and calculate the prediction accuracy:
1_ Set test data prediction accuracy
2

When building CNN model to identify the cat / dog in the picture, through the load in keras under the framework of tensorflow_ Img() encountered the following error when loading the picture:

ImportError: Could not import PIL.Image. The use of array_to_img requires PIL.Image

Find solutions through the Internet and try them in person. The solutions are as follows:
the main reason is that pilot is not installed because load is used_ The img() function requires pilot

(base) C:\Users\Administrator>activate tensorflow
(tensorflow) C:\Users\Administrator>pip3 install pillow
Collecting pillow
  Downloading Pillow-7.2.0-cp36-cp36m-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 7.4 kB/s
Installing collected packages: pillow
Successfully installed pillow-7.2.0

The problem has been solved.

Refer to
1. Importerror: could not import PIL.Image . The use of array_ to_ img requires PIL.
2.ImportError: Could not import PIL.Image . The use of array_ to_ img requires PIL.