codingforentrepreneurs / OpenCV-Python-Series

An OpenCV & Python Tutorial Series and Reference.
399 stars 550 forks source link

recognizer.train(x_train, np.array(y_labels)) cv2.error #10

Open devchacha opened 5 years ago

devchacha commented 5 years ago

recognizer.train(x_train, np.array(y_labels)) cv2.error: OpenCV(4.0.1) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

How can I fix it?

Rohitshrimal commented 5 years ago

@devchacha it worked for me when i removed the "scaleFactor=1.5" from the below line . faces = face_cascade.detectMultiScale(image_array, scaleFactor=1.5, minNeighbors=5)

ganeshkarthik77 commented 4 years ago

recognizer.train(x_train, np.array(y_labels)) cv2.error: OpenCV(4.0.1) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

How can I fix it

Abderrahmen33 commented 4 years ago

same problem

georgiakais commented 4 years ago

@ganeshkarthik77 and @Abderrahmen33
hello guys..i had the same problem and it worked with this: recognition=cv2.face.LBPHFaceRecognizer_create()

p.s: in the file face-train change the recognicer to recognition.

brysonnoble commented 4 years ago

Neither of these solutions worked for me. I will try to find another solution but if anyone found another fix, please help.

Edit: After further testing, I have found that large images will not work. I do not know the limit, but keeping each image under 200kb seems to work.

Abderrahmen33 commented 4 years ago

i change the plan in using library face_recognition but problem in cmake always we find problem lol but i think with importing face_recognition its easy

Abderrahmen33 commented 4 years ago

@georgiakais thnks alot anyway

AndroidUnissula commented 4 years ago

cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

How can I fix it

ZeusThe4th commented 4 years ago

Hey Abderrahmen33. I see from the thread that you managed to solve the error. Mind helping? same error.

gusck1997 commented 4 years ago

Same error, how can i fix it?

piyush-creator commented 4 years ago

Use more than one folder of images

kajal86 commented 4 years ago

Traceback (most recent call last): File "c:/Users/Kajal/Visual studio/Automated-Attendance-System-By-Real-Time-Face-Reccognition-master/scripts/train.py", line 54, in recognizer.train(faces,np.array(faceid)) cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

having same error tried all the solutions above. plz help

Abderrahmen33 commented 4 years ago

https://www.youtube.com/watch?v=TOUMUzVy24A this a video that i made

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& Sender notified by Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& 12/06/20 à 12:04:41

On Fri, Jun 12, 2020 at 11:46 AM kajal86 notifications@github.com wrote:

Traceback (most recent call last): File "c:/Users/Kajal/Visual studio/Automated-Attendance-System-By-Real-Time-Face-Reccognition-master/scripts/train.py", line 54, in recognizer.train(faces,np.array(faceid)) cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/10#issuecomment-643181838, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIR5OQMRUMJ6ZFUUB7BGZHDRWH2ONANCNFSM4HFOTZ4A .

gauravtak077 commented 4 years ago

Abderrahmen plzzz help me i have save code as u but still i face this problem TypeError: Expected Ptr for argument 'labels'

Abderrahmen33 commented 4 years ago

gauravtak077 contact me in may email abderrahmen.melliti@esprit.tn

MiguelCodes commented 4 years ago

I looked closely at the error, and I found the solution. (probably)

Removing minNeighbors and scaleFactor worked.

gauravtak077 commented 4 years ago

I was try that but....error remain same...

On Wed, Jun 24, 2020, 12:36 AM MiguelCodes notifications@github.com wrote:

I looked closely at the error, and I found the solution. (probably)

Removing minNeighbors and scaleFactor worked.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/10#issuecomment-648359247, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXCTIW57UIGJHHGYB2HQOTRYD4LXANCNFSM4HFOTZ4A .

Ruhan123 commented 4 years ago

OpenCV(4.3.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train' i am also facing this problem any one can help me

Neerajms25 commented 4 years ago

more than one sample means

SuatKrky commented 4 years ago

recognizer.train(x_train, np.array(y_labels))

Traceback (most recent call last): File "C:\Users\LENOVO\Desktop\OpenCV\faces-train.py", line 47, in recognizer.train(x_train, np.array(y_labels)) cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-rwld3ghi\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

please help me I tried all the solutions but it's not working

gauravtak077 commented 4 years ago

What is tha problem ...

On Sun, Sep 13, 2020, 8:45 PM SuatKrky notifications@github.com wrote:

recognizer.train(x_train, np.array(y_labels))

Traceback (most recent call last): File "C:\Users\LENOVO\Desktop\OpenCV\faces-train.py", line 47, in recognizer.train(x_train, np.array(y_labels)) cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-rwld3ghi\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

please help me I tried all the solutions but it's not working

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/10#issuecomment-691684116, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXCTIX26UHEMQ4U3KL2STLSFTOZLANCNFSM4HFOTZ4A .

LazarLeonard commented 3 years ago

line 48, in recognizer.train(x_train, np.array(y_labels))

cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-5rb_9df3\opencv_contrib\modules\face\src\lbph_faces.cpp:265: error: (-213:The function/feature is not implemented) Using Original Local Binary Patterns for feature extraction only works on single-channel images (given 16). Please pass the image data as a grayscale image! in function 'cv::face::elbp'

How can I fix this problem?

mosfiqunnahid commented 3 years ago

recognizer.train(faces, np.array(Ids)) cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-r2ue8w6k\opencv_contrib\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

How can I fix this problem?

hritikhanda4 commented 3 years ago

The problem is rising because the classifier is getting more than one channel image(even you are using gray images) Solution is to again convert your image into Gray before training

Ex: def trainData( ): face_recognizer = cv2.face.LBPHFaceRecognizer_create() img=cv2.imread("data/1.jpg") face_recognizer.train([img],np.array([1])) return face_recognizer

Above code is giving error

Fix: def trainData( ): face_recognizer = cv2.face.LBPHFaceRecognizer_create() img=cv2.imread("data/1.jpg") img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # use this line to convert images into gray face_recognizer.train([img],np.array([1])) return face_recognizer

ghost commented 3 years ago

fix 'cv::face::LBPH::train' change size photo to "910x1137"

mosfiqunnahid commented 3 years ago

Thank You

On Fri, Jun 11, 2021 at 5:58 AM Zakaria Karim @.***> wrote:

fix 'cv::face::LBPH::train' change size photo to "910x1137"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/10#issuecomment-859162486, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQUQPIPXNFEXBCL4BJHMT3TSFGSPANCNFSM4HFOTZ4A .

-- Mosfiqun Nahid Hassan Phone:+880 15213 31607 E-mail: @.*** Web: www.mosfiqun.com

Karthiktmv commented 1 year ago

@devchacha it worked for me when i removed the "scaleFactor=1.5" from the below line . faces = face_cascade.detectMultiScale(image_array, scaleFactor=1.5, minNeighbors=5)

@Rohitshrimal Thanks, It worked for me as well

Rohitshrimal commented 1 year ago

@Karthiktmv pleasure to know. Thanks

ameermuhammed7777 commented 7 months ago

when i run this code "face_recognizer=cv2.face.LBPHFaceRecognizer_create()" i get an error "AttributeError: module 'cv2' has no attribute 'face'",how to fix it?