Skip to content

Commit

Permalink
✨🍱 trained svm burns model
Browse files Browse the repository at this point in the history
  • Loading branch information
chriamue committed Jan 7, 2024
1 parent 7a166ec commit 7ffd0d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Binary file modified res/eyes_svm_burns_model.json
Binary file not shown.
7 changes: 5 additions & 2 deletions src/classifier/svm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +50,10 @@ impl Trainable<f32, usize> for SVMClassifier {
.map(|row| row.iter().map(|&elem| elem as f64).collect())
.collect();

let y_vec: Vec<i32> = y.iter().map(|&elem| elem as i32).collect();
let y_vec: Vec<i32> = 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)));
Expand Down
5 changes: 2 additions & 3 deletions src/wasm/hogdetector_js.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -98,8 +98,7 @@ impl HogDetectorJS {

pub fn init_svm_classifier(&self) {
let hog = {
let mut model: HogDetector<f32, usize, SVMClassifier, _> =
HogDetector::default();
let mut model: HogDetector<f32, usize, SVMClassifier, _> = HogDetector::default();
let file = Cursor::new(include_bytes!("../../res/eyes_svm_burns_model.json"));
model.load(file).unwrap();
model
Expand Down

0 comments on commit 7ffd0d9

Please sign in to comment.