Comments (4)
Thanks for posting. It is not immediately clear to me what is causing this error. It seems to be caused by the train
function of the OpenCV classifier.
I suspect either X_train
or y_train_bin
on L256 has length 1, and that is causing some issues with the classifier's train
function. Can you add a print statement right before that to see what X_train[data_id, :]
, y_train_bin
, and self.params
look like?
from opencv-python-blueprints.
Thanks, @mbeyeler
The outputs are:
X_train [[ 85. 96. 127. ..., 100. 104. 113.]
[ 19. 18. 17. ..., 71. 103. 132.]
[ 93. 92. 186. ..., 11. 8. 9.]
...,
[ 22. 20. 21. ..., 76. 62. 44.]
[ 30. 29. 30. ..., 28. 28. 29.]
[ 75. 89. 90. ..., 241. 225. 233.]]
- strategy one-vs-one
- train
y_train_bin [0 1 0 ..., 1 1 0]
from opencv-python-blueprints.
Looks all good. I think the problem is that they changed the OpenCV API to train(samples, layout, responses)
, similar to what is explained here.
Try adding a layout
parameter to L256:
self.classifiers[svm_id].train(X_train[data_id, :], cv2.ml.ROW_SAMPLE, y_train_bin)
from opencv-python-blueprints.
Thanks, yes.
It is fine now.
Sorry, @mbeyeler. I wrote this answer before appearing this error.
I already change it to self.classifiers.append(cv2.ml.SVM_create())
but it is still giving error.
Another error:
Traceback (most recent call last):
File "/home/redhwan/Downloads/opencv-python-blueprints-master/chapter6/chapter6.py", line 78, in <module>
main()
File "/home/redhwan/Downloads/opencv-python-blueprints-master/chapter6/chapter6.py", line 49, in main
acc, prec, rec = MCS.evaluate(X_test, y_test)
File "/home/redhwan/Downloads/opencv-python-blueprints-master/chapter6/classifiers.py", line 298, in evaluate
y_hat = self.classifiers[svm_id].predict_all(X_test_id)
AttributeError: 'cv2.ml_SVM' object has no attribute 'predict_all'
from opencv-python-blueprints.
Related Issues (20)
- Test/update code for OpenCV3
- Fix code for Raspberry Pi
- about chapter 7
- Cartoonizer on face with transparent background HOT 2
- cv2.cv.CV_CAP_PROP_FRAME_WIDTH doesn't exist in OpenCV 3 HOT 2
- capture.set(cv2.CV_CAP_PROP_FRAME_HEIGHT, 480) ----> does not work in opencv3 HOT 2
- metaclass error for chapter7 HOT 1
- Bug for mac
- Chapter 2 HOT 1
- chapter7 classifiers.py code is not working HOT 4
- could not align head HOT 8
- Chapter 5: Error too many values to unpack HOT 1
- Chapter 1, filters.py OpenCV error HOT 3
- Could not find data file datasets/faces_preprocessed.pkl HOT 16
- error params order for row and cols in ` plot_power_spectrum` HOT 1
- wxPython blocks on EVT_TIMER (Windows) HOT 1
- Classification label not drawn above bounding box HOT 1
- Move common code out of chapters HOT 1
- wxPython can't be installed on Mac OS X 10.11 El Capitan HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv-python-blueprints.