February 2020
Intermediate to advanced
372 pages
9h 26m
English
A final piece of advice on SVMs: you do not need to train a detector every time you want to use it – and, indeed, you should avoid doing so because training is slow. You can use code such as the following to save a trained SVM model to an XML file:
svm = cv2.ml.SVM_create()svm.train(np.array(training_data), cv2.ml.ROW_SAMPLE, np.array(training_labels))svm.save('my_svm.xml')
Subsequently, you can reload the trained SVM, using code such as the following:
svm = cv2.ml.SVM_create()svm.load('my_svm.xml')
Typically, you might have one script that trains and saves your SVM model, and other scripts that load and use it for various detection problems.