Refactored shinobi-tensorflow.js (by moe and thellamafarm)

fix-non-showing-inputs
Levent K 2020-10-28 15:02:53 +00:00
parent 18b3ae1c45
commit db13c16260
1 changed files with 77 additions and 63 deletions

View File

@ -24,17 +24,23 @@ try{
return console.log(config.plug, 'Plugin start has failed. pluginBase.js was not found.')
}
}
// Base Init />>
var spawn = require('child_process').spawn;
var child = spawn('python3', ['-u', 'detect_image.py']);
var ready = false;
const spawn = require('child_process').spawn;
var child = null
function respawn() {
console.log("respawned python",(new Date()))
const theChild = spawn('python3', ['-u', 'detect_image.py']);
var lastStatusLog = new Date();
child.on('close', function() {
child = spawn('python3', ['-u', 'detect_image.py']);
theChild.on('exit', () => {
child = respawn();
});
child.stdout.on('data', function (data) {
theChild.stdout.on('data', function (data) {
var rawString = data.toString('utf8');
if (new Date() - lastStatusLog > 5000) {
lastStatusLog = new Date();
@ -59,6 +65,14 @@ child.stdout.on('data', function (data) {
}
})
})
return theChild
}
// Base Init />>
child = respawn();
const emptyDataObject = { data: [], type: undefined, time: 0 };