OpenCV-Python-Series icon indicating copy to clipboard operation
OpenCV-Python-Series copied to clipboard

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

Open devchacha opened this issue 6 years ago • 29 comments

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?

devchacha avatar Apr 12 '19 08:04 devchacha

@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 avatar Apr 22 '19 13:04 Rohitshrimal

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

ganeshkarthik77 avatar Nov 17 '19 12:11 ganeshkarthik77

same problem

Abderrahmen33 avatar Nov 21 '19 11:11 Abderrahmen33

@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.

georgiakais avatar Nov 21 '19 21:11 georgiakais

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.

Bryson09215 avatar Nov 21 '19 23:11 Bryson09215

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 avatar Nov 22 '19 07:11 Abderrahmen33

@georgiakais thnks alot anyway

Abderrahmen33 avatar Nov 22 '19 07:11 Abderrahmen33

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

AndroidUnissula avatar Nov 22 '19 07:11 AndroidUnissula

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

ZeusThe4th avatar Mar 23 '20 11:03 ZeusThe4th

Same error, how can i fix it?

gusck1997 avatar Apr 21 '20 02:04 gusck1997

Use more than one folder of images

piyush-creator avatar May 11 '20 10:05 piyush-creator

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

kajal86 avatar Jun 12 '20 09:06 kajal86

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 [email protected] 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 .

Abderrahmen33 avatar Jun 12 '20 10:06 Abderrahmen33

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

gauravtak077 avatar Jun 19 '20 08:06 gauravtak077

gauravtak077 contact me in may email [email protected]

Abderrahmen33 avatar Jun 19 '20 09:06 Abderrahmen33

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

Removing minNeighbors and scaleFactor worked.

MiguelCodes avatar Jun 23 '20 19:06 MiguelCodes

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

On Wed, Jun 24, 2020, 12:36 AM MiguelCodes [email protected] 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 .

gauravtak077 avatar Jun 24 '20 04:06 gauravtak077

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

Ruhan123 avatar Aug 09 '20 07:08 Ruhan123

more than one sample means

Neerajms25 avatar Aug 13 '20 14:08 Neerajms25

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

SuatKrky avatar Sep 13 '20 15:09 SuatKrky

What is tha problem ...

On Sun, Sep 13, 2020, 8:45 PM SuatKrky [email protected] 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 .

gauravtak077 avatar Sep 13 '20 15:09 gauravtak077

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?

LazarLeonard avatar Mar 03 '21 21:03 LazarLeonard

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?

mosfiqunnahid avatar Mar 05 '21 13:03 mosfiqunnahid

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

hritikhanda4 avatar Mar 10 '21 20:03 hritikhanda4

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

ghost avatar Jun 10 '21 23:06 ghost

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

mosfiqunnahid avatar Jun 13 '21 04:06 mosfiqunnahid

@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

Karthiktmv avatar Oct 28 '22 08:10 Karthiktmv

@Karthiktmv pleasure to know. Thanks

Rohitshrimal avatar Oct 28 '22 10:10 Rohitshrimal

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?

ameermuhammed7777 avatar Feb 13 '24 09:02 ameermuhammed7777