diff --git a/res/eyes_svm_burns_model.json b/res/eyes_svm_burns_model.json index 48be182..e05a29e 100644 Binary files a/res/eyes_svm_burns_model.json and b/res/eyes_svm_burns_model.json differ diff --git a/src/classifier/svm.rs b/src/classifier/svm.rs index 15d397e..931b1ce 100644 --- a/src/classifier/svm.rs +++ b/src/classifier/svm.rs @@ -5,7 +5,7 @@ use object_detector_rust::{ classifier::Classifier, predictable::Predictable, trainable::Trainable, window_generator::PyramidWindow, }; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use svm_burns::{svm::SVM, Parameters, RBFKernel, SVC}; use crate::HogDetector; @@ -50,7 +50,10 @@ impl Trainable for SVMClassifier { .map(|row| row.iter().map(|&elem| elem as f64).collect()) .collect(); - let y_vec: Vec = y.iter().map(|&elem| elem as i32).collect(); + let y_vec: Vec = y + .iter() + .map(|&elem| if elem > 0 { 1 } else { -1 }) + .collect(); let mut parameters = Parameters::default(); parameters.with_kernel(Box::new(RBFKernel::new(0.7))); diff --git a/src/wasm/hogdetector_js.rs b/src/wasm/hogdetector_js.rs index 6958e93..3a3c282 100644 --- a/src/wasm/hogdetector_js.rs +++ b/src/wasm/hogdetector_js.rs @@ -1,5 +1,5 @@ -use crate::classifier::BayesClassifier; use crate::classifier::svm::SVMClassifier; +use crate::classifier::BayesClassifier; use crate::detection_filter::{DetectionFilter, TrackerFilter}; use crate::detector::visualize_detections; use crate::hogdetector::HogDetectorTrait; @@ -98,8 +98,7 @@ impl HogDetectorJS { pub fn init_svm_classifier(&self) { let hog = { - let mut model: HogDetector = - HogDetector::default(); + let mut model: HogDetector = HogDetector::default(); let file = Cursor::new(include_bytes!("../../res/eyes_svm_burns_model.json")); model.load(file).unwrap(); model