akshaybahadur21 / Facial-Recognition-using-Facenet

A simple implementation of facial recognition using facenets for humans 🧔 🔍
MIT License
278 stars 143 forks source link

ValueError: invalid literal for int() with base 10: #4

Open CryptoExchangeFR opened 6 years ago

CryptoExchangeFR commented 6 years ago

ops@18:14:[~/Developpement/Facial-Recognition-using-Facenet] python3 rec-feat.py Using TensorFlow backend. 2018-06-08 18:16:23.935963: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/saving.py:270: UserWarning: No training configuration found in save file: the model was not compiled. Compile it manually. warnings.warn('No training configuration found in save file: ' Total Params: 3743280 distance for Pierre9 is 0.05126756 distance for Pierre8 is 0.06121227 distance for Pierre5 is 0.06684167 distance for Pierre4 is 0.068645105 distance for Pierre6 is 0.07133803 distance for Pierre7 is 0.067103155 distance for Pierre3 is 0.071579434 distance for Pierre2 is 0.0652888 distance for Pierre1 is 0.05116783 distance for Pierre10 is 0.049484182 Traceback (most recent call last): File "rec-feat.py", line 112, in recognize() File "rec-feat.py", line 103, in recognize extract_face_info(img, img_rgb, database,ear) File "rec-feat.py", line 59, in extract_face_info name, min_dist = recognize_face(image, database) File "rec-feat.py", line 44, in recognize_face if int(identity) <=4: ValueError: invalid literal for int() with base 10: 'Pierre10'

I run create_face.py to get picture of myself. I copy the picture directly in the images folder I created. (Do I need to keep the subfolder with the ID ?) Then I run rec-feat.py with python3 command.

'PierreX' represent the photo and their associated number.

Do you know how to solve it ?

sarkarsaikat commented 6 years ago

I solved this by renaming my sample photos in /image as 1.jpg , 2.jpg ,...

CryptoExchangeFR commented 6 years ago

Thank you for your answer. This problem seem solved but I have another one.

The script is running well until this error :

Using TensorFlow backend. 2018-06-09 10:19:50.205095: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/saving.py:270: UserWarning: No training configuration found in save file: the model was not compiled. Compile it manually. warnings.warn('No training configuration found in save file: ' Total Params: 3743280 distance for 8 is 0.05880815 distance for 9 is 0.058217797 distance for 4 is 0.06353997 distance for 5 is 0.059023313 distance for 7 is 0.056130935 distance for 6 is 0.056679048 distance for 2 is 0.060995225 distance for 3 is 0.06437977 distance for 1 is 0.05674781 distance for 0 is 0.057453062 distance for 8 is 0.06155078 distance for 9 is 0.06023829 distance for 4 is 0.065031365 distance for 5 is 0.06051247 distance for 7 is 0.058396123 distance for 6 is 0.057917174 distance for 2 is 0.06269057 distance for 3 is 0.06579694 distance for 1 is 0.05870841 Traceback (most recent call last): File "rec-feat.py", line 112, in recognize() File "rec-feat.py", line 103, in recognize extract_face_info(img, img_rgb, database,ear) File "rec-feat.py", line 59, in extract_face_info name, min_dist = recognize_face(image, database) TypeError: 'NoneType' object is not iterable

Do you know how to fix this ?

Thanks again :)

sarkarsaikat commented 6 years ago

This has more got to do again with the project has images in the image folder. 1-4 are type A and 5-8 are type B (class or person). But for my use case I would look at identifying individual user per set up I changed the code a little bit in recognize_face: the for loop in my case is like:

for (name, db_enc) in database.items():
        #print(name)
        # Compute L2 distance between the target "encoding" and the current "emb" from the database.
        dist = np.linalg.norm(db_enc - encoding)

        print('distance for' + str(name) + ' is  ' + str(dist))

        # If this distance is less than the min_dist, then set min_dist to dist, and identity to name

        if min_dist < dist:
            min_dist = dist
            name = 'User_Name'

and the return looks like:

if dist < 0.1:
        min_dist = dist
        return name, dist
    else:
        return str('Unknown'), dist

You can adapt as per your need .

SaravananJaichandar commented 5 years ago

Traceback (most recent call last): File "rec-feat.py", line 112, in recognize() File "rec-feat.py", line 82, in recognize database = initialize() File "rec-feat.py", line 77, in initialize database[identity] = fr_utils.img_path_to_encoding(file, FRmodel) File "/Users/saravananjaichandar/Downloads/Facial-Recognition-using-Facenet-master/fr_utils.py", line 194, in img_path_to_encoding return img_to_encoding(img1, model) File "/Users/saravananjaichandar/Downloads/Facial-Recognition-using-Facenet-master/fr_utils.py", line 198, in img_to_encoding image = cv2.resize(image, (96, 96)) cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/resize.cpp:3718: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

Assertion error resize function ! Can anyone help regarding this ? @sarkarsaikat @CryptoExchangeFR @akshaybahadur21

mswipedata commented 5 years ago

Check the value of 'image', most likely it has not been able to read the image.

hsm4703 commented 5 years ago

if i want set two people name sean and leo What program do you want to write? if dist < 0.1: min_dist=dist return name,dist else: return str('Unknown'),dist