oarriaga / face_classification

Real-time face detection and emotion/gender classification using fer2013/imdb datasets with a keras CNN model and openCV.
MIT License
5.61k stars 1.59k forks source link

Outdated dependencies [FIXED] #160

Closed Hyrtsi closed 1 year ago

Hyrtsi commented 2 years ago

Greetings,

I noticed the following problems when running pip install -r REQUIREMENTS.txt

ERROR: Could not find a version that satisfies the requirement tensorflow==1.1.0 (from versions: 1.13.1, 1.13.2, 1.14.0, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 1.15.5, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1)
ERROR: No matching distribution found for tensorflow==1.1.0

Here is a solution how to get that exact version. Alternatively, you can just use a more recent version of tensorflow. If you plan on installing the software in REQUIREMENTS.txt I strongly suggest you to use venv or conda.

Then, after fixing that, another error:

ERROR: Ignored the following versions that require a different python version: 1.22.0 Requires-Python >=3.8; 1.22.0rc1 Requires-Python >=3.8; 1.22.0rc2 Requires-Python >=3.8; 1.22.0rc3 Requires-Python >=3.8; 1.22.1 Requires-Python >=3.8; 1.22.2 Requires-Python >=3.8; 1.22.3 Requires-Python >=3.8; 1.22.4 Requires-Python >=3.8; 1.23.0 Requires-Python >=3.8; 1.23.0rc1 Requires-Python >=3.8; 1.23.0rc2 Requires-Python >=3.8; 1.23.0rc3 Requires-Python >=3.8; 1.23.1 Requires-Python >=3.8; 1.4.0 Requires-Python >=3.8; 1.4.0rc0 Requires-Python >=3.8; 1.4.1 Requires-Python >=3.8; 1.4.2 Requires-Python >=3.8; 1.4.3 Requires-Python >=3.8
ERROR: Could not find a version that satisfies the requirement opencv-python==3.4.0 (from versions: 3.4.0.14, 3.4.2.17, 3.4.3.18, 3.4.4.19, 3.4.5.20, 3.4.6.27, 3.4.7.28, 3.4.8.29, 3.4.9.31, 3.4.9.33, 3.4.10.35, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.14.53, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25, 4.1.1.26, 4.1.2.30, 4.2.0.32, 4.2.0.34, 4.3.0.36, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.2.54, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66)
ERROR: No matching distribution found for opencv-python==3.4.0

then, a handful of errors for numpy

  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [2431 lines of output]
      Collecting numpy==1.11.3
        Downloading numpy-1.11.3.zip (4.7 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.7/4.7 MB 11.0 MB/s eta 0:00:00
        Preparing metadata (setup.py): started
        Preparing metadata (setup.py): finished with status 'done'
      Using legacy 'setup.py install' for numpy, since package 'wheel' is not installed.
      Installing collected packages: numpy
        Running setup.py install for numpy: started
        Running setup.py install for numpy: finished with status 'error'
        error: subprocess-exited-with-error

        × Running setup.py install for numpy did not run successfully.
        │ exit code: 1
        ╰─> [2386 lines of output]
            Running from numpy source directory.

(tons of lines omitted for readability)

All of these simply come from outdated packages.

Solution

I used the following versions

h5py==3.7.0
keras==2.9.0
numpy==1.22.4
opencv-python==4.5.5.64
pandas==1.4.2
tensorflow==2.9.1

I didn't need statistics for image_emotion_gender_demo.py.

I used the following command

python3 src/image_emotion_gender_demo.py images/12_angry_men.jpg

Note that I should have ran the script from src folder. But it didn't require much work to do it this way.

I got a lot of errors like this

2022-07-12 10:27:38.354341: I tensorflow/core/util/util.cc:169] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
Traceback (most recent call last):
  File "src/image_emotion_gender_demo.py", line 14, in <module>
    from utils.preprocessor import preprocess_input
  File "/face_classification/src/utils/preprocessor.py", line 2, in <module>
    from scipy.misc import imread, imresize
ImportError: cannot import name 'imread' from 'scipy.misc' (/.local/lib/python3.8/site-packages/scipy/misc/__init__.py)

It's because it has been removed from scipy. The solution is to replace the scipy imread function calls with another library such as PIL or lycon or opencv or anything. As long as the library reads the frames in desired format (rgb, grayscale) it's alright.