ipazc / mtcnn

MTCNN face detection implementation for TensorFlow, as a PIP package.
MIT License
2.23k stars 527 forks source link

Cannot import name 'Softmax' #93

Closed jerryOkafor closed 3 weeks ago

jerryOkafor commented 4 years ago

I am trying to use this package in a Jupiter notebook but I am getting the following error shown below:

ImportError                               Traceback (most recent call last)
<ipython-input-27-fc833231e89c> in <module>()
----> 1 import mtcnn
      2 
      3 print(mtcnn.__version__)

/opt/conda/lib/python3.6/site-packages/mtcnn/__init__.py in <module>()
     24 # SOFTWARE.
     25 
---> 26 from mtcnn.mtcnn import MTCNN
     27 
     28 

/opt/conda/lib/python3.6/site-packages/mtcnn/mtcnn.py in <module>()
     35 
     36 from mtcnn.exceptions.invalid_image import InvalidImage
---> 37 from mtcnn.network.factory import NetworkFactory
     38 
     39 

/opt/conda/lib/python3.6/site-packages/mtcnn/network/factory.py in <module>()
     24 # SOFTWARE.
     25 
---> 26 from keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax
     27 from keras.models import Model
     28 

ImportError: cannot import name 'Softmax'
BatuhanGencay commented 4 years ago

What is your keras version, Softmax added in version 2.1.3. Try upgrading your keras version to 2.1.3 or higher

mikaya10 commented 4 years ago

I had a same issue. (keras -2.4.3) I changed "from keras.layers" to "from tensorflow.keras.layers" on factory.py file and the error is gone.