2020-05-03 12:12:26 -04:00
|
|
|
const zmq = require('zeromq');
|
|
|
|
const tf = require('@tensorflow/tfjs-node');
|
|
|
|
const bodyPix = require('@tensorflow-models/body-pix');
|
|
|
|
const {decodeJpeg} = require('./decode_image');
|
|
|
|
|
2020-05-03 21:19:41 -04:00
|
|
|
async function main() {
|
|
|
|
const net = await bodyPix.load({
|
2020-05-03 12:12:26 -04:00
|
|
|
architecture: 'MobileNetV1',
|
|
|
|
outputStride: 16,
|
|
|
|
multiplier: 0.5,
|
|
|
|
quantBytes: 2
|
|
|
|
});
|
|
|
|
const sock = new zmq.Reply;
|
|
|
|
|
|
|
|
await sock.bind('ipc:///tmp/bodypix');
|
|
|
|
console.log("Bounded to ipc:///tmp/bodypix");
|
|
|
|
|
|
|
|
for await (const [msg] of sock) {
|
|
|
|
const image = decodeJpeg(msg)
|
|
|
|
const segmentation = await net.segmentPerson(image);
|
|
|
|
await sock.send(segmentation.data);
|
2020-05-03 16:03:48 -04:00
|
|
|
tf.dispose(image)
|
2020-05-03 12:12:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-03 21:19:41 -04:00
|
|
|
main();
|