Mjrovai / OpenCV-Face-Recognition

Real-time face recognition project with OpenCV and Python
1.18k stars 1.02k forks source link

Value Error: Face Training #11

Open IndrajeetDevale opened 4 years ago

IndrajeetDevale commented 4 years ago

id = int(os.path.split(imagePath)[-1].split(".")[1]) ValueError: invalid literal for int() with base 10: 'Shubham'

Getting an invalid literal issue while using trying to implement face training. Could not find a solution on stackoverflow. Will be greatful if you help. Thank You!

aniiketdongare07 commented 4 years ago

I have the same error, pl someone let me know if you find anything

lasupernova commented 3 years ago

I changed that line and used regex to extract the ids: id = re.search(r'(?:face-)(\d+)(?:.*)', imagePath).group(1) (see below)

you also need import re at the beginning in order to use the re library

EDIT:

IDs need to be integers, but the solution above returns strings, so instead use: id = int(re.search(r'(?:face-)(\d+)(?:.*)', imagePath).group(1))