anand498 / Face-Liveness-Detection

Application to detect between actual faces and fake faces in realtime with Computer Vision and Deep Learning
113 stars 20 forks source link

Error on execute predictor.py #2

Closed dan-developer closed 2 years ago

dan-developer commented 4 years ago

python facepredictor.py Using TensorFlow backend. Traceback (most recent call last): File "facepredictor.py", line 61, in model = load_model("models/anandfinal.hdf5") File "C:\workspace\spoofing-detection\venv\lib\site-packages\keras\models.py", line 239, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "C:\workspace\spoofing-detection\venv\lib\site-packages\keras\models.py", line 313, in model_from_config return layer_module.deserialize(config, custom_objects=custom_objects) File "C:\workspace\spoofing-detection\venv\lib\site-packages\keras\layers__init__.py", line 54, in deserialize printable_module_name='layer') File "C:\workspace\spoofing-detection\venv\lib\site-packages\keras\utils\generic_utils.py", line 139, in deserialize_keras_object list(custom_objects.items()))) File "C:\workspace\spoofing-detection\venv\lib\site-packages\keras\models.py", line 1208, in from_config if 'class_name' not in config[0] or config[0]['class_name'] == 'Merge': KeyError: 0

anand498 commented 4 years ago

The issue arises because you might be using a version of Keras which might be incompatible with the model. Try using Keras -version 2.2.4/2.2.5. Let me know if the problem was resolved.

dan-developer commented 4 years ago

I managed to run, but nothing happens. It always looks like this:

image

anand498 commented 3 years ago

hi so i think the issue might be with the values of the square boxes we use as a region of interest for predicting the face in the frame cv2.rectangle(frame, (400, 100), (900, 550), (255,0,0), 2) Please try to tweak these values according to your window size and see if it helps. If it worked, please close the issue.

gauravbhandari7 commented 3 years ago

hi so i think the issue might be with the values of the square boxes we use as a region of interest for predicting the face in the frame cv2.rectangle(frame, (400, 100), (900, 550), (255,0,0), 2) Please try to tweak these values according to your window size and see if it helps. If it worked, please close the issue.

Does the change of rectangle size affect the rest of the process? I have done that and i think change of value affect the process following that line i have assigned cv2.rectangle(frame, (100, 100), (900, 600), (255, 0, 0), 2) Changing the size of blue box affect whole process(recognition as well as labelling of fake and real faces)

face
anand498 commented 3 years ago

The entire motive for adding a specific area or a window is to define ROI in our image so that we can limit the unwanted noise in an image frame as best as possible. I think from the above image, you can try to decrease the frame size(the blue one), that might help you to remove a lot of unwanted pixels to process and predict. And yes the size of the rectangle frame does affect predict results, because that is the region which goes to the model for prediction.

Abhishek010397 commented 2 years ago

Hi i too found out the same approach as the above image when i stand in-front of the camera(at a particular angle) it either says fake or does nothing, can you elaborate more on this, i see that the fake and real images would get store at some directories namely fake and real but i don't see them appearing, how are we training the model?

anand498 commented 2 years ago

the model has been pre trained with around 3-3.5k images. You'll need to do some changes in the code and the training data and retrain your model that fits your requirement.