mirror of https://github.com/vladmandic/human
fix centernet box width & height
parent
eb6d344560
commit
c07d8c2317
|
@ -9,7 +9,11 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### **HEAD -> main** 2021/06/08 mandic00@live.com
|
### **HEAD -> main** 2021/06/09 mandic00@live.com
|
||||||
|
|
||||||
|
- add body segmentation sample
|
||||||
|
|
||||||
|
### **release: 2.0.1** 2021/06/08 mandic00@live.com
|
||||||
|
|
||||||
- release 2.0
|
- release 2.0
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ let userConfig = {
|
||||||
hand: { enabled: false },
|
hand: { enabled: false },
|
||||||
body: { enabled: false },
|
body: { enabled: false },
|
||||||
// body: { enabled: true, modelPath: 'posenet.json' },
|
// body: { enabled: true, modelPath: 'posenet.json' },
|
||||||
segmentation: { enabled: true },
|
segmentation: { enabled: false },
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ async function processImage(input, title) {
|
||||||
document.getElementById('loader').style.display = 'none';
|
document.getElementById('loader').style.display = 'none';
|
||||||
if (ui.detectThread) cancelAnimationFrame(ui.detectThread);
|
if (ui.detectThread) cancelAnimationFrame(ui.detectThread);
|
||||||
if (ui.drawThread) cancelAnimationFrame(ui.drawThread);
|
if (ui.drawThread) cancelAnimationFrame(ui.drawThread);
|
||||||
|
log('processed image:', title);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
};
|
};
|
||||||
image.src = input;
|
image.src = input;
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
"canvas": "^2.8.0",
|
"canvas": "^2.8.0",
|
||||||
"chokidar": "^3.5.1",
|
"chokidar": "^3.5.1",
|
||||||
"dayjs": "^1.10.5",
|
"dayjs": "^1.10.5",
|
||||||
"esbuild": "^0.12.7",
|
"esbuild": "^0.12.8",
|
||||||
"eslint": "^7.28.0",
|
"eslint": "^7.28.0",
|
||||||
"eslint-config-airbnb-base": "^14.2.1",
|
"eslint-config-airbnb-base": "^14.2.1",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-plugin-import": "^2.23.4",
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"seedrandom": "^3.0.5",
|
"seedrandom": "^3.0.5",
|
||||||
"simple-git": "^2.39.0",
|
"simple-git": "^2.39.1",
|
||||||
"tslib": "^2.2.0",
|
"tslib": "^2.2.0",
|
||||||
"typedoc": "^0.21.0-beta.2",
|
"typedoc": "^0.21.0-beta.2",
|
||||||
"typescript": "4.3.2"
|
"typescript": "4.3.2"
|
||||||
|
|
|
@ -49,11 +49,15 @@ async function process(res: Tensor, inputSize, outputShape, config: Config) {
|
||||||
const score = Math.trunc(100 * detections[0][id][4]) / 100;
|
const score = Math.trunc(100 * detections[0][id][4]) / 100;
|
||||||
const classVal = detections[0][id][5];
|
const classVal = detections[0][id][5];
|
||||||
const label = labels[classVal].label;
|
const label = labels[classVal].label;
|
||||||
const boxRaw = [
|
const [x, y] = [
|
||||||
detections[0][id][0] / inputSize,
|
detections[0][id][0] / inputSize,
|
||||||
detections[0][id][1] / inputSize,
|
detections[0][id][1] / inputSize,
|
||||||
detections[0][id][2] / inputSize,
|
];
|
||||||
detections[0][id][3] / inputSize,
|
const boxRaw = [
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
detections[0][id][2] / inputSize - x,
|
||||||
|
detections[0][id][3] / inputSize - y,
|
||||||
] as [number, number, number, number];
|
] as [number, number, number, number];
|
||||||
const box = [
|
const box = [
|
||||||
Math.trunc(boxRaw[0] * outputShape[0]),
|
Math.trunc(boxRaw[0] * outputShape[0]),
|
||||||
|
|
|
@ -10,9 +10,10 @@ export const config = {
|
||||||
name: 'humangl',
|
name: 'humangl',
|
||||||
priority: 99,
|
priority: 99,
|
||||||
canvas: <null | OffscreenCanvas | HTMLCanvasElement>null,
|
canvas: <null | OffscreenCanvas | HTMLCanvasElement>null,
|
||||||
gl: <unknown>null,
|
gl: <null | WebGL2RenderingContext>null,
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 1024,
|
height: 1024,
|
||||||
|
extensions: <string[]> [],
|
||||||
webGLattr: { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2
|
webGLattr: { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2
|
||||||
alpha: false,
|
alpha: false,
|
||||||
antialias: false,
|
antialias: false,
|
||||||
|
@ -25,9 +26,25 @@ export const config = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function extensions(): void {
|
||||||
|
/*
|
||||||
|
https://www.khronos.org/registry/webgl/extensions/
|
||||||
|
https://webglreport.com/?v=2
|
||||||
|
*/
|
||||||
|
const gl = config.gl;
|
||||||
|
if (!gl) return;
|
||||||
|
config.extensions = gl.getSupportedExtensions() as string[];
|
||||||
|
// gl.getExtension('KHR_parallel_shader_compile');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers custom WebGL2 backend to be used by Human library
|
||||||
|
*
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
export function register(): void {
|
export function register(): void {
|
||||||
if (!tf.findBackend(config.name)) {
|
if (!tf.findBackend(config.name)) {
|
||||||
log('backend registration:', config.name);
|
// log('backend registration:', config.name);
|
||||||
try {
|
try {
|
||||||
config.canvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(config.width, config.height) : document.createElement('canvas');
|
config.canvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(config.width, config.height) : document.createElement('canvas');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -35,7 +52,7 @@ export function register(): void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
config.gl = config.canvas.getContext('webgl2', config.webGLattr);
|
config.gl = config.canvas.getContext('webgl2', config.webGLattr) as WebGL2RenderingContext;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log('error: cannot get WebGL2 context:', err);
|
log('error: cannot get WebGL2 context:', err);
|
||||||
return;
|
return;
|
||||||
|
@ -65,13 +82,11 @@ export function register(): void {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
tf.ENV.set('WEBGL_VERSION', 2);
|
tf.ENV.set('WEBGL_VERSION', 2);
|
||||||
// tf.ENV.set('WEBGL_MAX_TEXTURE_SIZE', config.gl.getParameter(config.gl.MAX_TEXTURE_SIZE));
|
|
||||||
// tf.ENV.set('WEBGL_FORCE_F16_TEXTURES', true);
|
|
||||||
// tf.ENV.set('WEBGL_PACK_DEPTHWISECONV', true);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log('error: cannot set WebGL backend flags:', err);
|
log('error: cannot set WebGL backend flags:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
extensions();
|
||||||
log('backend registered:', config.name);
|
log('backend registered:', config.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue