work on body segmentation

pull/356/head
Vladimir Mandic 2021-06-04 20:22:05 -04:00
parent 5800461d79
commit 5c6ba688c9
6 changed files with 20 additions and 11 deletions

View File

@ -11,9 +11,7 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
### **HEAD -> main** 2021/06/04 mandic00@live.com
### **update for tfjs 3.7.0** 2021/06/04 mandic00@live.com
- add meet and selfie models
- add live hints to demo
- switch worker from module to iife importscripts
- release candidate

View File

@ -11,7 +11,7 @@ N/A
## In Progress
- Switch to TypeScript 4.3
- Implement segmentation model
- Add backgrounds to segmentation
## Known Issues

View File

@ -50,9 +50,7 @@ const userConfig = {
hand: { enabled: false },
body: { enabled: false },
// body: { enabled: true, modelPath: 'posenet.json' },
// body: { enabled: true, modelPath: 'blazepose.json' },
// segmentation: { enabled: true, modelPath: 'meet.json' },
// segmentation: { enabled: true, modelPath: 'selfie.json' },
segmentation: { enabled: true },
*/
};
@ -211,8 +209,8 @@ async function drawResults(input) {
// draw fps chart
await menu.process.updateChart('FPS', ui.detectFPS);
// get updated canvas
if (ui.buffered || !result.canvas) {
// get updated canvas if missing or if we want buffering, but skip if segmentation is enabled
if (!result.canvas || (ui.buffered && !human.config.segmentation.enabled)) {
const image = await human.image(input);
result.canvas = image.canvas;
human.tf.dispose(image.tensor);
@ -489,6 +487,7 @@ async function processImage(input, title) {
image.onload = async () => {
if (ui.hintsThread) clearInterval(ui.hintsThread);
ui.interpolated = false; // stop interpolating results if input is image
ui.buffered = false; // stop buffering result if input is image
status(`processing image: ${title}`);
const canvas = document.getElementById('canvas');
image.width = image.naturalWidth;
@ -676,6 +675,8 @@ function setupMenu() {
menu.models.addHTML('<hr style="border-style: inset; border-color: dimgray">');
menu.models.addBool('gestures', human.config.gesture, 'enabled', (val) => human.config.gesture.enabled = val);
menu.models.addHTML('<hr style="border-style: inset; border-color: dimgray">');
menu.models.addBool('body segmentation', human.config.segmentation, 'enabled', (val) => human.config.segmentation.enabled = val);
menu.models.addHTML('<hr style="border-style: inset; border-color: dimgray">');
menu.models.addBool('object detection', human.config.object, 'enabled', (val) => human.config.object.enabled = val);
menu.models.addHTML('<hr style="border-style: inset; border-color: dimgray">');
menu.models.addBool('face compare', compare, 'enabled', (val) => {

View File

@ -198,6 +198,8 @@ export interface Config {
},
/** Controlls and configures all body segmentation module
* if segmentation is enabled, output result.canvas will be augmented with masked image containing only person output
*
* - enabled: true/false
* - modelPath: object detection model, can be absolute path or relative to modelBasePath
*/
@ -349,7 +351,8 @@ const config: Config = {
},
segmentation: {
enabled: false,
enabled: false, // if segmentation is enabled, output result.canvas will be augmented
// with masked image containing only person output
modelPath: 'selfie.json', // experimental: object detection model, can be absolute path or relative to modelBasePath
// can be 'selfie' or 'meet'
},

View File

@ -39,3 +39,10 @@ export function mergeDeep(...objects) {
return prev;
}, {});
}
// helper function: return min and max from input array
export const minmax = (data) => data.reduce((acc, val) => {
acc[0] = (acc[0] === undefined || val < acc[0]) ? val : acc[0];
acc[1] = (acc[1] === undefined || val > acc[1]) ? val : acc[1];
return acc;
}, []);

2
wiki

@ -1 +1 @@
Subproject commit 8e898a636f5254a3fe451b097c633c9965a8a680
Subproject commit a69870f5763ae3fddd1243df10559aaf32c8f0da