Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
add neural net options for switching out classifier in future
Browse files Browse the repository at this point in the history
  • Loading branch information
harthur committed Mar 22, 2013
1 parent 9e869f2 commit 0e45725
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kittydar.js
Expand Up @@ -6,19 +6,19 @@ if (process.arch) { // in node
var Canvas = (require)('canvas');
}

var network = require("./network.json");
var network = require("./network.js");
var net = new brain.NeuralNetwork().fromJSON(network);

var params = {
patchSize: 48, // size of training images in px
minSize: 48, // starting window size
resize: 360, // initial image resize size in px
scaleStep: 6, // scaling step size in px
shiftBy: 4, // px to slide window by
shiftBy: 6, // px to slide window by
overlapThresh: 0.5, // min overlap ratio to classify as an overlap
minOverlaps: 8, // minumum overlapping rects to classify as a head
minOverlaps: 2, // minumum overlapping rects to classify as a head
HOGparams: { // parameters for HOG descriptor
cellSize: 4, // must divide evenly into shiftBy
cellSize: 6, // must divide evenly into shiftBy
blockSize: 2,
blockStride: 1,
bins: 6,
Expand All @@ -33,7 +33,7 @@ var params = {
// override if using another classifier
var output = net.runInput(features)[0];
return {
isCat: output > 0.995,
isCat: output > 0.999,
value: output
};
}
Expand Down
1 change: 1 addition & 0 deletions network.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions nn-classifier.js
@@ -0,0 +1,29 @@
/*
Running kittydar with these options will use the neural network backend:
var options = require("./nn-options");
kittydar.detectCats(canvas, options);
*/
var brain = require("brain");

var network = require("./network.js");
var net = new brain.NeuralNetwork().fromJSON(network);

module.exports = {
shiftBy: 6, // px to slide window by
minOverlaps: 2, // minumum overlapping rects to classify as a head
HOGparams: { // parameters for HOG descriptor
cellSize: 6, // must divide evenly into shiftBy
blockSize: 2,
blockStride: 1,
bins: 6,
norm: "L2"
},
classify: function(features) {
var output = net.runInput(features)[0];
return {
isCat: output > 0.999,
value: output
};
}
}

0 comments on commit 0e45725

Please sign in to comment.