mirror of https://github.com/vladmandic/human
fix centernet box width & height
parent
e90f268cae
commit
bcce8e8872
|
@ -9,7 +9,11 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
|||
|
||||
## 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
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ let userConfig = {
|
|||
hand: { enabled: false },
|
||||
body: { enabled: false },
|
||||
// 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';
|
||||
if (ui.detectThread) cancelAnimationFrame(ui.detectThread);
|
||||
if (ui.drawThread) cancelAnimationFrame(ui.drawThread);
|
||||
|
||||
log('processed image:', title);
|
||||
resolve(true);
|
||||
};
|
||||
image.src = input;
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
"canvas": "^2.8.0",
|
||||
"chokidar": "^3.5.1",
|
||||
"dayjs": "^1.10.5",
|
||||
"esbuild": "^0.12.7",
|
||||
"esbuild": "^0.12.8",
|
||||
"eslint": "^7.28.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.23.4",
|
||||
|
@ -82,7 +82,7 @@
|
|||
"node-fetch": "^2.6.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"seedrandom": "^3.0.5",
|
||||
"simple-git": "^2.39.0",
|
||||
"simple-git": "^2.39.1",
|
||||
"tslib": "^2.2.0",
|
||||
"typedoc": "^0.21.0-beta.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 classVal = detections[0][id][5];
|
||||
const label = labels[classVal].label;
|
||||
const boxRaw = [
|
||||
const [x, y] = [
|
||||
detections[0][id][0] / 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];
|
||||
const box = [
|
||||
Math.trunc(boxRaw[0] * outputShape[0]),
|
||||
|
|
|
@ -10,9 +10,10 @@ export const config = {
|
|||
name: 'humangl',
|
||||
priority: 99,
|
||||
canvas: <null | OffscreenCanvas | HTMLCanvasElement>null,
|
||||
gl: <unknown>null,
|
||||
gl: <null | WebGL2RenderingContext>null,
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
extensions: <string[]> [],
|
||||
webGLattr: { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2
|
||||
alpha: 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 {
|
||||
if (!tf.findBackend(config.name)) {
|
||||
log('backend registration:', config.name);
|
||||
// log('backend registration:', config.name);
|
||||
try {
|
||||
config.canvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(config.width, config.height) : document.createElement('canvas');
|
||||
} catch (err) {
|
||||
|
@ -35,7 +52,7 @@ export function register(): void {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
config.gl = config.canvas.getContext('webgl2', config.webGLattr);
|
||||
config.gl = config.canvas.getContext('webgl2', config.webGLattr) as WebGL2RenderingContext;
|
||||
} catch (err) {
|
||||
log('error: cannot get WebGL2 context:', err);
|
||||
return;
|
||||
|
@ -65,13 +82,11 @@ export function register(): void {
|
|||
}
|
||||
try {
|
||||
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) {
|
||||
log('error: cannot set WebGL backend flags:', err);
|
||||
return;
|
||||
}
|
||||
extensions();
|
||||
log('backend registered:', config.name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue