vardanagarwal / Proctoring-AI

Creating a software for automatic monitoring in online proctoring
MIT License
540 stars 329 forks source link

eye_tracker: IndexError: list index (0) out of range. #34

Closed AbhayVAshokan closed 3 years ago

AbhayVAshokan commented 3 years ago

I have encountered the following error when I tried to run python3 eye_tracker.py. Am I missing something?

2020-12-15 19:15:53.573760: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2020-12-15 19:15:53.573788: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "eye_tracker.py", line 154, in <module>
    landmark_model = get_landmark_model()
  File "/home/abhayvashokan/Downloads/Proctoring-AI/face_landmarks.py", line 30, in get_landmark_model
    model = keras.models.load_model(saved_model)
  File "/home/abhayvashokan/Downloads/venv/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 212, in load_model
    return saved_model_load.load(filepath, compile, options)
  File "/home/abhayvashokan/Downloads/venv/lib/python3.8/site-packages/tensorflow/python/keras/saving/saved_model/load.py", line 130, in load
    _read_legacy_metadata(object_graph_def, metadata)
  File "/home/abhayvashokan/Downloads/venv/lib/python3.8/site-packages/tensorflow/python/keras/saving/saved_model/load.py", line 179, in _read_legacy_metadata
    node_paths = _generate_object_paths(object_graph_def)
  File "/home/abhayvashokan/Downloads/venv/lib/python3.8/site-packages/tensorflow/python/keras/saving/saved_model/load.py", line 204, in _generate_object_paths
    for reference in object_graph_def.nodes[current_node].children:
IndexError: list index (0) out of range

This is the set of commands that I have executed after cloning the repo.

Executed the set of commands in the virtual environment.

pip install tensorflow
pip install opencv-python
pip install numpy==1.18.5

The version of tensorflow that is installed is 2.4.0 and that of opencv is 4.4.0.46.

If it is not too much to ask, could you provide your output to pip freeze command? I am facing dependency version issues in other codes as well.

vardanagarwal commented 3 years ago

In this, you are most probably facing an error due to the landmark model. Please have a look in the face_landmarks.py in the get_landmark_model() and see if the file path to the landmark model is correct or not.

I did not add the requirements.txt because I had used an existing environment and just added all the new frameworks in that itself, unfortunately, the things you can expect from a novice college student. However, I had used TensorFlow 2.2 along with opencv>4 and numpy=1.18.5 itself. The dependency issues comes in if you try to run the face spoofing code as well, especially the scikit-learn version required for that. If you skip that then you won't face any issues with your current settings.

44mkashif commented 3 years ago

Try downgrading your Tensorflow version to 2.2, it worked for me...

vardanagarwal commented 3 years ago

@AbhayVAshokan let me know if it works for you.

AbhayVAshokan commented 3 years ago

Try downgrading your Tensorflow version to 2.2, it worked for me...

Thanks, this works perfectly. Closing #34. It's much easier in the end than I thought it would be. Thank you #44mkashif.

pip install opencv-python
pip install tensorflow==2.2
aspnair commented 3 years ago

@vardanagarwal Found the same error. Fixed it by modifying face_landmarks.py line 30 Used tensorflow saved model instead of keras load model.

model = keras.models.load_model(saved_model)

model = tf.saved_model.load(saved_model)

Debian Unstable with python 3.9.2 pip list | egrep 'tensorflow|keras|opencv|numpy' keras-nightly 2.5.0.dev2021032900 numpy 1.19.5 opencv-python 4.5.2.52 tensorflow 2.5.0 tensorflow-estimator 2.5.0

vardanagarwal commented 3 years ago

@aspnair if you want you can create a pull request for this.

aspnair commented 3 years ago

@vardanagarwal Thank You. That's fine.  It is just a single line, so feel free to fix it in any way.