Priyanka
Priyanka

Reputation: 51

ModuleNotFoundError: No module named 'keras_preprocessing'

I'm trying to implement YOLO3 object detection using tensorflow 2.0 on google colab : https://github.com/theAIGuysCode/Object-Detection-API

And for this particular line:

!python3 /content/Object-Detection-API/load_weights.py

I'm facing this error:

ModuleNotFoundError: No module named 'keras_preprocessing'

I tried installing 'keras_preprocessing' using this command:

!conda install keras_preprocessing

and then I'm facing this error:

Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - keras_preprocessing

Current channels:

  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Please help me solve the same! Thank you!

Upvotes: 4

Views: 48735

Answers (5)

ajinzrathod
ajinzrathod

Reputation: 940

N.B: This answer is for those who are facing this error recently due to version change


The error ModuleNotFoundError: No module named 'keras.preprocessing.text' usually occurs because recent versions of TensorFlow have moved keras.preprocessing.text to tensorflow.keras.preprocessing.text

Steps to solve:

  1. Change keras.preprocessing.text to from tensorflow.keras.preprocessing.text import Tokenizer
  2. Install TensorFlow’s Text Module (if required): pip install tensorflow-text

Upvotes: 1

Jonny_92
Jonny_92

Reputation: 159

From the PyPI documentation You can install the keras-preprocessing package by using the shell command pip install keras-preprocessing. Otherwise, you can call the preprocessing module directly from keras by this line to be inserted in your Python code from keras import preprocessing. You can also call Keras from Tensorflow.

Upvotes: 1

Anudeep Adiraju
Anudeep Adiraju

Reputation: 1

Use from tensorflow.keras.preprocessing.image import ImageDataGenerator

Upvotes: -1

Sihat Afnan
Sihat Afnan

Reputation: 872

Try this

pip install Keras-Preprocessing

Upvotes: 2

Léonard
Léonard

Reputation: 2630

From the Anaconda repository of the Keras Preprocessing package, you can install it with

conda install -c conda-forge keras-preprocessing

that is, with an - instead of _ and with selecting the conda-forge channel.

Upvotes: 3

Related Questions