prevent validation failed on some model combinations

pull/280/head
Vladimir Mandic 2021-09-17 14:30:57 -04:00
parent d5d2afee0f
commit 22827eafe2
5 changed files with 35 additions and 19 deletions

View File

@ -9,11 +9,19 @@
## Changelog ## Changelog
### **HEAD -> main** 2021/09/17 mandic00@live.com
### **2.2.2** 2021/09/17 mandic00@live.com
- experimental webgl status monitoring
### **release: 2.2.1** 2021/09/16 mandic00@live.com
### **2.2.1** 2021/09/16 mandic00@live.com ### **2.2.1** 2021/09/16 mandic00@live.com
- add vr model demo
### **origin/main** 2021/09/16 mandic00@live.com
- all tests passing - all tests passing
- redefine draw helpers interface - redefine draw helpers interface
- add simple webcam and webrtc demo - add simple webcam and webrtc demo

View File

@ -34,7 +34,6 @@ let userConfig = {
warmup: 'none', warmup: 'none',
backend: 'humangl', backend: 'humangl',
debug: true, debug: true,
filter: { enabled: false },
/* /*
wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.9.0/dist/', wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.9.0/dist/',
async: false, async: false,
@ -106,6 +105,7 @@ const ui = {
lastFrame: 0, // time of last frame processing lastFrame: 0, // time of last frame processing
viewportSet: false, // internal, has custom viewport been set viewportSet: false, // internal, has custom viewport been set
background: null, // holds instance of segmentation background image background: null, // holds instance of segmentation background image
exceptionHandler: true, // should capture all unhandled exceptions
// webrtc // webrtc
useWebRTC: false, // use webrtc as camera source instead of local webcam useWebRTC: false, // use webrtc as camera source instead of local webcam
@ -920,6 +920,7 @@ async function pwaRegister() {
} }
async function main() { async function main() {
if (ui.exceptionHandler) {
window.addEventListener('unhandledrejection', (evt) => { window.addEventListener('unhandledrejection', (evt) => {
if (ui.detectThread) cancelAnimationFrame(ui.detectThread); if (ui.detectThread) cancelAnimationFrame(ui.detectThread);
if (ui.drawThread) cancelAnimationFrame(ui.drawThread); if (ui.drawThread) cancelAnimationFrame(ui.drawThread);
@ -930,6 +931,7 @@ async function main() {
status(`exception: ${msg}`); status(`exception: ${msg}`);
evt.preventDefault(); evt.preventDefault();
}); });
}
log('demo starting ...'); log('demo starting ...');
@ -985,7 +987,8 @@ async function main() {
// create instance of human // create instance of human
human = new Human(userConfig); human = new Human(userConfig);
log('human version:', human.version); log('human version:', human.version);
userConfig = { ...human.config, ...userConfig }; // we've merged human defaults with user config and now lets store it back so it can be accessed by methods such as menu
userConfig = human.config;
if (typeof tf !== 'undefined') { if (typeof tf !== 'undefined') {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
log('TensorFlow external version:', tf.version); log('TensorFlow external version:', tf.version);

View File

@ -66,7 +66,7 @@
"@tensorflow/tfjs-layers": "^3.9.0", "@tensorflow/tfjs-layers": "^3.9.0",
"@tensorflow/tfjs-node": "^3.9.0", "@tensorflow/tfjs-node": "^3.9.0",
"@tensorflow/tfjs-node-gpu": "^3.9.0", "@tensorflow/tfjs-node-gpu": "^3.9.0",
"@types/node": "^16.9.1", "@types/node": "^16.9.2",
"@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1", "@typescript-eslint/parser": "^4.31.1",
"@vladmandic/build": "^0.4.1", "@vladmandic/build": "^0.4.1",

View File

@ -90,8 +90,13 @@ export async function validate(instance) {
for (const defined of Object.keys(instance.models)) { for (const defined of Object.keys(instance.models)) {
if (instance.models[defined]) { // check if model is loaded if (instance.models[defined]) { // check if model is loaded
let models: GraphModel[] = []; let models: GraphModel[] = [];
if (Array.isArray(instance.models[defined])) models = instance.models[defined].map((model) => ((model && model.executor) ? model : model.model)); if (Array.isArray(instance.models[defined])) {
else models = [instance.models[defined]]; models = instance.models[defined]
.filter((model) => (model !== null))
.map((model) => ((model && model.executor) ? model : model.model));
} else {
models = [instance.models[defined]];
}
for (const model of models) { for (const model of models) {
if (!model) { if (!model) {
if (instance.config.debug) log('model marked as loaded but not defined:', defined); if (instance.config.debug) log('model marked as loaded but not defined:', defined);

View File

@ -52,7 +52,7 @@ async function warmupCanvas(instance) {
resolve({}); resolve({});
} else { } else {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0); if (ctx) ctx.drawImage(img, 0, 0);
// const data = ctx?.getImageData(0, 0, canvas.height, canvas.width); // const data = ctx?.getImageData(0, 0, canvas.height, canvas.width);
const tensor = await instance.image(canvas); const tensor = await instance.image(canvas);
const res = await instance.detect(tensor.tensor, instance.config); const res = await instance.detect(tensor.tensor, instance.config);