Unable to train

13 views
Skip to first unread message

Vedant Shah

unread,
Mar 9, 2018, 11:30:33 AM3/9/18
to OpenCV with Python Blueprints
runfile('C:/Users/Vedant/Desktop/NEW_EMO/chapter7/train_test_mlp.py', wdir='C:/Users/Vedant/Desktop/NEW_EMO/chapter7')
Loading data from datasets/faces_training.pkl
Loaded 7 training samples
Traceback (most recent call last):

  File "<ipython-input-1-f60b72c5efb4>", line 1, in <module>
    runfile('C:/Users/Vedant/Desktop/NEW_EMO/chapter7/train_test_mlp.py', wdir='C:/Users/Vedant/Desktop/NEW_EMO/chapter7')

  File "C:\Users\Vedant\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Users\Vedant\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Vedant/Desktop/NEW_EMO/chapter7/train_test_mlp.py", line 68, in <module>
    main()

  File "C:/Users/Vedant/Desktop/NEW_EMO/chapter7/train_test_mlp.py", line 24, in main
    seed=42)

  File "C:\Users\Vedant\Desktop\NEW_EMO\chapter7\datasets\homebrew.py", line 59, in load_data
    X, V, m = extract_features(samples, num_components=num_components)

  File "C:\Users\Vedant\Desktop\NEW_EMO\chapter7\datasets\homebrew.py", line 139, in extract_features
    m, V = cv2.PCACompute(Xarr)

TypeError: Required argument 'mean' (pos 2) not found

Michael Beyeler

unread,
Mar 13, 2018, 1:09:17 PM3/13/18
to OpenCV with Python Blueprints
Hi Vedant,

Any chance you're running OpenCV 3.1?

In newer version of OpenCV, PCACompute requires a second input argument 'mean'. If you replace

m, V = cv2.PCACompute(Xarr)

with

m, V = cv2.PCACompute(Xarr, mean=None)


the code should work!

Best,
Michael
Reply all
Reply to author
Forward
0 new messages