clean up tensorflow install process
parent
0eac960171
commit
08bba843a6
|
|
@ -1,2 +1,3 @@
|
|||
conf.json
|
||||
cascades
|
||||
dist
|
||||
models
|
||||
|
|
|
|||
|
|
@ -5,22 +5,17 @@ echo "You can run this installer again to change it."
|
|||
echo "(y)es or (N)o"
|
||||
read nodejsinstall
|
||||
echo "Getting Tensorflow Node.js module..."
|
||||
npm install dotenv@8.2.0 --unsafe-perm
|
||||
npm uninstall @tensorflow/tfjs-node-gpu --unsafe-perm
|
||||
npm uninstall @tensorflow/tfjs-node --unsafe-perm
|
||||
npm install @tensorflow/tfjs-core@1.7.3 --unsafe-perm --force
|
||||
npm install @tensorflow/tfjs-converter@1.7.3 --unsafe-perm --force
|
||||
npm install @tensorflow/tfjs-layers@1.7.3 --unsafe-perm --force
|
||||
npm install yarn -g --unsafe-perm --force
|
||||
npm install @tensorflow/tfjs-node@1.7.3 --unsafe-perm
|
||||
GPU_INSTALL="0"
|
||||
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
|
||||
GPU_INSTALL="1"
|
||||
npm install @tensorflow/tfjs-node-gpu@1.7.0 --unsafe-perm
|
||||
npm install @tensorflow/tfjs-node-gpu@1.7.3 --unsafe-perm
|
||||
else
|
||||
npm install @tensorflow/tfjs-node@1.7.3 --unsafe-perm
|
||||
fi
|
||||
echo "Getting Coco SSD Model..."
|
||||
npm install @tensorflow-models/coco-ssd --unsafe-perm
|
||||
|
||||
npm install --unsafe-perm
|
||||
if [ ! -e "./conf.json" ]; then
|
||||
echo "Creating conf.json"
|
||||
sudo cp conf.sample.json conf.json
|
||||
|
|
|
|||
|
|
@ -3,20 +3,21 @@ module.exports = function(config){
|
|||
switch(config.tfjsBuild){
|
||||
case'gpu':
|
||||
tfjsSuffix = '-gpu'
|
||||
var tf = require('@tensorflow/tfjs-node-gpu')
|
||||
break;
|
||||
case'cpu':
|
||||
var tf = require('@tensorflow/tfjs-node')
|
||||
break;
|
||||
default:
|
||||
try{
|
||||
require(`@tensorflow/tfjs-node-gpu`)
|
||||
tfjsSuffix = '-gpu'
|
||||
var tf = require('@tensorflow/tfjs-node-gpu')
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var tf = require(`@tensorflow/tfjs-node${tfjsSuffix}`)
|
||||
const cocossd = require('@tensorflow-models/coco-ssd');
|
||||
// const mobilenet = require('@tensorflow-models/mobilenet');
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "shinobi-tensorflow",
|
||||
"author": "Shinob Systems, Moinul Alam",
|
||||
"version": "1.0.0",
|
||||
"description": "Object Detection plugin based on @tensorflow/tfjs-node",
|
||||
"main": "shinobi-tensorflow.js",
|
||||
"dependencies": {
|
||||
"@tensorflow-models/coco-ssd": "^2.0.3",
|
||||
"@tensorflow/tfjs-converter": "^1.7.3",
|
||||
"@tensorflow/tfjs-core": "^1.7.3",
|
||||
"@tensorflow/tfjs-layers": "^1.7.3",
|
||||
"@tensorflow/tfjs-node": "^1.7.3",
|
||||
"@tensorflow/tfjs-node-gpu": "^1.7.3",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.16.2",
|
||||
"moment": "^2.19.2",
|
||||
"socket.io": "^2.0.4",
|
||||
"socket.io-client": "^1.7.4"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"bin": "shinobi-tensorflow.js",
|
||||
"scripts": {
|
||||
"package": "pkg package.json -t linux,macos,win --out-path dist",
|
||||
"package-x64": "pkg package.json -t linux-x64,macos-x64,win-x64 --out-path dist/x64",
|
||||
"package-x86": "pkg package.json -t linux-x86,macos-x86,win-x86 --out-path dist/x86",
|
||||
"package-armv6": "pkg package.json -t linux-armv6,macos-armv6,win-armv6 --out-path dist/armv6",
|
||||
"package-armv7": "pkg package.json -t linux-armv7,macos-armv7,win-armv7 --out-path dist/armv7",
|
||||
"package-all": "npm run package && npm run package-x64 && npm run package-x86 && npm run package-armv6 && npm run package-armv7"
|
||||
},
|
||||
"pkg": {
|
||||
"targets": [
|
||||
"node12"
|
||||
],
|
||||
"scripts": [
|
||||
"../pluginBase.js"
|
||||
],
|
||||
"assets": [
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -33,11 +33,6 @@ s.detectObject=function(buffer,d,tx,frameLocation){
|
|||
if(results[0]){
|
||||
var mats = []
|
||||
results.forEach(function(v){
|
||||
// [xmin ymin xmax ymax]
|
||||
// [x y width height]
|
||||
// [xmin, ymin, xmax-xmin+1, ymax-ymin+1]
|
||||
// var width = v.bbox[2] - v.bbox[0]
|
||||
// var height = v.bbox[3] - v.bbox[1]
|
||||
mats.push({
|
||||
x: v.bbox[0],
|
||||
y: v.bbox[1],
|
||||
|
|
@ -66,67 +61,4 @@ s.detectObject=function(buffer,d,tx,frameLocation){
|
|||
})
|
||||
}
|
||||
})
|
||||
// var detectStuff = function(frame,callback){
|
||||
// detector.detect(frame)
|
||||
// .then(detections => {
|
||||
// matrices = []
|
||||
// detections.forEach(function(v){
|
||||
// matrices.push({
|
||||
// x:v.box.x,
|
||||
// y:v.box.y,
|
||||
// width:v.box.w,
|
||||
// height:v.box.h,
|
||||
// tag:v.className,
|
||||
// confidence:v.probability,
|
||||
// })
|
||||
// })
|
||||
// if(matrices.length > 0){
|
||||
// tx({
|
||||
// f:'trigger',
|
||||
// id:d.id,
|
||||
// ke:d.ke,
|
||||
// details:{
|
||||
// plug:config.plug,
|
||||
// name:'yolo',
|
||||
// reason:'object',
|
||||
// matrices:matrices,
|
||||
// imgHeight:parseFloat(d.mon.detector_scale_y),
|
||||
// imgWidth:parseFloat(d.mon.detector_scale_x)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// fs.unlink(frame,function(){
|
||||
//
|
||||
// })
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.log(error)
|
||||
//
|
||||
// // here you can handle the errors. Ex: Out of memory
|
||||
// })
|
||||
// }
|
||||
// if(frameLocation){
|
||||
// detectStuff(frameLocation)
|
||||
// }else{
|
||||
// d.tmpFile=s.gid(5)+'.jpg'
|
||||
// if(!fs.existsSync(s.dir.streams)){
|
||||
// fs.mkdirSync(s.dir.streams);
|
||||
// }
|
||||
// d.dir=s.dir.streams+d.ke+'/'
|
||||
// if(!fs.existsSync(d.dir)){
|
||||
// fs.mkdirSync(d.dir);
|
||||
// }
|
||||
// d.dir=s.dir.streams+d.ke+'/'+d.id+'/'
|
||||
// if(!fs.existsSync(d.dir)){
|
||||
// fs.mkdirSync(d.dir);
|
||||
// }
|
||||
// fs.writeFile(d.dir+d.tmpFile,buffer,function(err){
|
||||
// if(err) return s.systemLog(err);
|
||||
// try{
|
||||
// detectStuff(d.dir+d.tmpFile)
|
||||
// }catch(error){
|
||||
// console.error('Catch: ' + error);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue