edge-impulse-linux 1.16.2 → 1.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli/linux/linux.js +1 -0
- package/build/cli/linux/linux.js.map +1 -1
- package/build/cli/linux/runner-profiling.d.ts +10 -0
- package/build/cli/linux/runner-profiling.js +72 -0
- package/build/cli/linux/runner-profiling.js.map +1 -0
- package/build/cli/linux/runner-utils.d.ts +1 -0
- package/build/cli/linux/runner-utils.js +83 -79
- package/build/cli/linux/runner-utils.js.map +1 -1
- package/build/cli/linux/runner.js +57 -8
- package/build/cli/linux/runner.js.map +1 -1
- package/build/cli/linux/webserver/public/inference-server.js +92 -83
- package/build/cli/linux/webserver/public/inference-server.js.map +1 -1
- package/build/cli/linux/webserver/public/webserver.js +124 -17
- package/build/cli/linux/webserver/public/webserver.js.map +1 -1
- package/build/cli/linux/webserver/views/index.js +5 -3
- package/build/cli/linux/webserver/views/index.js.map +1 -1
- package/build/cli-common/model-monitor.d.ts +1 -2
- package/build/cli-common/model-monitor.js +5 -5
- package/build/cli-common/model-monitor.js.map +1 -1
- package/build/cli-common/remote-mgmt-service.d.ts +1 -1
- package/build/library/async-pool.d.ts +1 -0
- package/build/library/async-pool.js +21 -0
- package/build/library/async-pool.js.map +1 -0
- package/build/library/classifier/image-classifier.d.ts +16 -3
- package/build/library/classifier/image-classifier.js +38 -8
- package/build/library/classifier/image-classifier.js.map +1 -1
- package/build/library/classifier/libcwrapper.d.ts +26 -0
- package/build/library/classifier/libcwrapper.js +37 -0
- package/build/library/classifier/libcwrapper.js.map +1 -0
- package/build/library/classifier/linux-impulse-runner-types.d.ts +177 -0
- package/build/library/classifier/linux-impulse-runner-types.js +28 -0
- package/build/library/classifier/linux-impulse-runner-types.js.map +1 -0
- package/build/library/classifier/linux-impulse-runner.d.ts +15 -125
- package/build/library/classifier/linux-impulse-runner.js +154 -46
- package/build/library/classifier/linux-impulse-runner.js.map +1 -1
- package/build/library/classifier/valgrind-suppression.d.ts +1 -0
- package/build/library/classifier/valgrind-suppression.js +64 -0
- package/build/library/classifier/valgrind-suppression.js.map +1 -0
- package/build/library/moving-average-filter.d.ts +1 -1
- package/build/library/sensors/gstreamer.d.ts +12 -5
- package/build/library/sensors/gstreamer.js +217 -66
- package/build/library/sensors/gstreamer.js.map +1 -1
- package/build/library/sensors/icamera.d.ts +3 -1
- package/build/library/sensors/imagesnap.d.ts +2 -0
- package/build/library/sensors/imagesnap.js +2 -0
- package/build/library/sensors/imagesnap.js.map +1 -1
- package/build/library/sensors/prophesee.d.ts +2 -0
- package/build/library/sensors/prophesee.js +1 -0
- package/build/library/sensors/prophesee.js.map +1 -1
- package/build/library/sensors/sensors-helper.d.ts +1 -0
- package/build/library/sensors/sensors-helper.js +1 -1
- package/build/library/sensors/sensors-helper.js.map +1 -1
- package/build/sdk/studio/sdk/api/classifyApi.d.ts +64 -0
- package/build/sdk/studio/sdk/api/classifyApi.js +128 -0
- package/build/sdk/studio/sdk/api/classifyApi.js.map +1 -1
- package/build/sdk/studio/sdk/api/rawDataApi.d.ts +55 -1
- package/build/sdk/studio/sdk/api/rawDataApi.js +166 -1
- package/build/sdk/studio/sdk/api/rawDataApi.js.map +1 -1
- package/build/sdk/studio/sdk/api/testApi.d.ts +16 -0
- package/build/sdk/studio/sdk/api/testApi.js +90 -0
- package/build/sdk/studio/sdk/api/testApi.js.map +1 -1
- package/build/sdk/studio/sdk/model/batchEditBoundingBoxesRequest.d.ts +32 -0
- package/build/sdk/studio/sdk/model/batchEditBoundingBoxesRequest.js +34 -0
- package/build/sdk/studio/sdk/model/batchEditBoundingBoxesRequest.js.map +1 -0
- package/build/sdk/studio/sdk/model/models.d.ts +2 -0
- package/build/sdk/studio/sdk/model/models.js +6 -0
- package/build/sdk/studio/sdk/model/models.js.map +1 -1
- package/build/sdk/studio/sdk/model/permission.d.ts +1 -1
- package/build/sdk/studio/sdk/model/permission.js +1 -1
- package/build/sdk/studio/sdk/model/permission.js.map +1 -1
- package/build/sdk/studio/sdk/model/uploadVersionArchiveRequest.d.ts +34 -0
- package/build/sdk/studio/sdk/model/uploadVersionArchiveRequest.js +29 -0
- package/build/sdk/studio/sdk/model/uploadVersionArchiveRequest.js.map +1 -0
- package/build/shared/views/project/bounding-box-scaling.d.ts +66 -0
- package/build/shared/views/project/bounding-box-scaling.js +155 -0
- package/build/shared/views/project/bounding-box-scaling.js.map +1 -0
- package/cli/linux/webserver/public/assets/mobileclient.css +31 -3
- package/cli/linux/webserver/public/inference-server.js +100 -89
- package/cli/linux/webserver/public/webserver.js +136 -17
- package/examples/js/classify-camera.js +1 -3
- package/examples/ts/classify-camera.ts +1 -3
- package/package.json +2 -1
- package/test/gstreamer.test.ts +28 -23
- package/examples/ts/classify-custom-from-test.ts +0 -96
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.PermissionValues = void 0;
|
|
15
|
-
exports.PermissionValues = ['admin:infra:disallowedEmailDomains:write', 'admin:infra:featureFlags:read', 'admin:infra:featureFlags:write', 'admin:infra:config:read', 'admin:infra:config:write', 'admin:infra:migrations:read', 'admin:infra:migrations:write', 'admin:metrics:read', 'admin:metrics:write', 'admin:oauth:read', 'admin:oauth:write', 'admin:organizations:read', 'admin:organizations:write', 'admin:organizations:members:write', 'admin:projects:members:write', 'admin:projects:read', 'admin:projects:write', 'admin:trashbin:write', 'admin:trials:read', 'admin:trials:write', 'admin:users:permissions:write', 'admin:users:read', 'admin:users:write', 'admin:jobs:read', 'admin:emails:verification:code:read', 'admin:sso:domainIdps:write', 'projects:limits:write', 'projects:training:keras:write', 'thirdpartyauth:read', 'thirdpartyauth:write', 'users:emails:read', 'whitelabels:read', 'whitelabels:write', 'test:data:write'];
|
|
15
|
+
exports.PermissionValues = ['admin:infra:disallowedEmailDomains:read', 'admin:infra:disallowedEmailDomains:write', 'admin:infra:featureFlags:read', 'admin:infra:featureFlags:write', 'admin:infra:config:read', 'admin:infra:config:write', 'admin:infra:migrations:read', 'admin:infra:migrations:write', 'admin:metrics:read', 'admin:metrics:write', 'admin:oauth:read', 'admin:oauth:write', 'admin:organizations:read', 'admin:organizations:write', 'admin:organizations:members:write', 'admin:projects:members:write', 'admin:projects:read', 'admin:projects:write', 'admin:trashbin:write', 'admin:trials:read', 'admin:trials:write', 'admin:users:permissions:write', 'admin:users:read', 'admin:users:write', 'admin:jobs:read', 'admin:emails:verification:code:read', 'admin:sso:read', 'admin:sso:domainIdps:write', 'projects:limits:write', 'projects:training:keras:write', 'projects:data:versioning:write', 'thirdpartyauth:read', 'thirdpartyauth:write', 'users:emails:read', 'whitelabels:read', 'whitelabels:write', 'test:data:write'];
|
|
16
16
|
//# sourceMappingURL=permission.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.js","sourceRoot":"","sources":["../../../../../sdk/studio/sdk/model/permission.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAKU,QAAA,gBAAgB,GAAa,CAAC,0CAA0C,EAAE,+BAA+B,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,qCAAqC,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"permission.js","sourceRoot":"","sources":["../../../../../sdk/studio/sdk/model/permission.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAKU,QAAA,gBAAgB,GAAa,CAAC,yCAAyC,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,qCAAqC,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,gCAAgC,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge Impulse API
|
|
3
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
/// <reference types="node" />
|
|
13
|
+
/// <reference types="node" />
|
|
14
|
+
export declare class UploadVersionArchiveRequest {
|
|
15
|
+
'zip': {
|
|
16
|
+
fieldname: string;
|
|
17
|
+
originalname: string;
|
|
18
|
+
encoding: string;
|
|
19
|
+
mimetype: string;
|
|
20
|
+
buffer: Buffer;
|
|
21
|
+
size: number;
|
|
22
|
+
}[];
|
|
23
|
+
static discriminator: string | undefined;
|
|
24
|
+
static attributeTypeMap: Array<{
|
|
25
|
+
name: string;
|
|
26
|
+
baseName: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}>;
|
|
29
|
+
static getAttributeTypeMap(): {
|
|
30
|
+
name: string;
|
|
31
|
+
baseName: string;
|
|
32
|
+
type: string;
|
|
33
|
+
}[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Edge Impulse API
|
|
4
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
*
|
|
6
|
+
* The version of the OpenAPI document: 1.0.0
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
10
|
+
* https://openapi-generator.tech
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.UploadVersionArchiveRequest = void 0;
|
|
15
|
+
class UploadVersionArchiveRequest {
|
|
16
|
+
static getAttributeTypeMap() {
|
|
17
|
+
return UploadVersionArchiveRequest.attributeTypeMap;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.UploadVersionArchiveRequest = UploadVersionArchiveRequest;
|
|
21
|
+
UploadVersionArchiveRequest.discriminator = undefined;
|
|
22
|
+
UploadVersionArchiveRequest.attributeTypeMap = [
|
|
23
|
+
{
|
|
24
|
+
"name": "zip",
|
|
25
|
+
"baseName": "zip",
|
|
26
|
+
"type": "RequestFile"
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
//# sourceMappingURL=uploadVersionArchiveRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadVersionArchiveRequest.js","sourceRoot":"","sources":["../../../../../sdk/studio/sdk/model/uploadVersionArchiveRequest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAGH,MAAa,2BAA2B;IAYpC,MAAM,CAAC,mBAAmB;QACtB,OAAO,2BAA2B,CAAC,gBAAgB,CAAC;IACxD,CAAC;;AAdL,kEAeC;AAZU,yCAAa,GAAuB,SAAS,CAAC;AAE9C,4CAAgB,GAA0D;IAC7E;QACI,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,aAAa;KACxB;CAAK,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
type ResizeEnum = 'squash' | 'fit-short' | 'fit-long' | 'crop';
|
|
2
|
+
type BoundingBox = {
|
|
3
|
+
label: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Helper to calculate positions for predictions to be placed to the original image,
|
|
11
|
+
* as we need to scale the coordinates of the predictions based on the resize mode.
|
|
12
|
+
*/
|
|
13
|
+
export declare const mapPredictionToOriginalImage: (resizeMode: ResizeEnum, box: BoundingBox, img: {
|
|
14
|
+
clientWidth: number;
|
|
15
|
+
clientHeight: number;
|
|
16
|
+
naturalWidth: number;
|
|
17
|
+
naturalHeight: number;
|
|
18
|
+
}) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
height: number;
|
|
22
|
+
width: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const getMaskSize: (side: 'vertical' | 'horizontal', img: {
|
|
25
|
+
clientWidth: number;
|
|
26
|
+
clientHeight: number;
|
|
27
|
+
naturalWidth: number;
|
|
28
|
+
naturalHeight: number;
|
|
29
|
+
}) => number;
|
|
30
|
+
export declare const mapStructuredResultsBoundingBox: (opts: {
|
|
31
|
+
box: {
|
|
32
|
+
ymin: number;
|
|
33
|
+
xmin: number;
|
|
34
|
+
ymax: number;
|
|
35
|
+
xmax: number;
|
|
36
|
+
};
|
|
37
|
+
originalWidth: number;
|
|
38
|
+
originalHeight: number;
|
|
39
|
+
mode: ResizeEnum;
|
|
40
|
+
}) => {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
46
|
+
export declare const mapResizedPixelResultsBoundingBox: (opts: {
|
|
47
|
+
box: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
};
|
|
53
|
+
resized: {
|
|
54
|
+
originalWidth: number;
|
|
55
|
+
originalHeight: number;
|
|
56
|
+
newWidth: number;
|
|
57
|
+
newHeight: number;
|
|
58
|
+
};
|
|
59
|
+
mode: ResizeEnum;
|
|
60
|
+
}) => {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapResizedPixelResultsBoundingBox = exports.mapStructuredResultsBoundingBox = exports.getMaskSize = exports.mapPredictionToOriginalImage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Helper to calculate positions for predictions to be placed to the original image,
|
|
6
|
+
* as we need to scale the coordinates of the predictions based on the resize mode.
|
|
7
|
+
*/
|
|
8
|
+
const mapPredictionToOriginalImage = (resizeMode, box, img) => {
|
|
9
|
+
let x = 0;
|
|
10
|
+
let y = 0;
|
|
11
|
+
let width = 0;
|
|
12
|
+
let height = 0;
|
|
13
|
+
if (resizeMode === 'squash') {
|
|
14
|
+
// Just scale the coordinates to the original image ratio
|
|
15
|
+
x = Math.max(0, Math.min(box.x * img.clientWidth, img.clientWidth));
|
|
16
|
+
y = Math.max(0, Math.min(box.y * img.clientHeight, img.clientHeight));
|
|
17
|
+
width = Math.min(box.width * img.clientWidth, img.clientWidth - x);
|
|
18
|
+
height = Math.min(box.height * img.clientHeight, img.clientHeight - y);
|
|
19
|
+
}
|
|
20
|
+
else if (resizeMode === 'fit-short') {
|
|
21
|
+
const referenceAxis = Math.min(img.clientWidth, img.clientHeight);
|
|
22
|
+
// Fit-short mode, i.e. outsides of the longer axis is cropped
|
|
23
|
+
const yStartPosition = (0, exports.getMaskSize)('vertical', img);
|
|
24
|
+
const xStartPosition = (0, exports.getMaskSize)('horizontal', img);
|
|
25
|
+
x = Math.max(0, Math.min(box.x * referenceAxis, referenceAxis));
|
|
26
|
+
y = Math.max(0, Math.min(box.y * referenceAxis, referenceAxis));
|
|
27
|
+
width = Math.min(box.width * referenceAxis, referenceAxis - x);
|
|
28
|
+
height = Math.min(box.height * referenceAxis, referenceAxis - y);
|
|
29
|
+
// Now translate the coordinates for where the cropped part starts
|
|
30
|
+
x = x + xStartPosition;
|
|
31
|
+
y = y + yStartPosition;
|
|
32
|
+
}
|
|
33
|
+
else if (resizeMode === 'fit-long') {
|
|
34
|
+
const padding = getLetterboxSize(img);
|
|
35
|
+
const ratio = img.naturalWidth / img.naturalHeight;
|
|
36
|
+
if (ratio > 1) {
|
|
37
|
+
// Image is wider, so vertical padding was added
|
|
38
|
+
// Calculate normalized padding for the padding
|
|
39
|
+
const squaredHeight = img.clientHeight + 2 * padding;
|
|
40
|
+
const normalizedPadding = padding / squaredHeight;
|
|
41
|
+
// Remove normalized padding from y and re-normalize to the
|
|
42
|
+
// original image height (excluding the padding)
|
|
43
|
+
y = (box.y - normalizedPadding) / (1 - 2 * normalizedPadding);
|
|
44
|
+
x = box.x;
|
|
45
|
+
// Scale normalized width and height of the bounding box
|
|
46
|
+
width = box.width;
|
|
47
|
+
height = box.height / (1 - 2 * normalizedPadding);
|
|
48
|
+
}
|
|
49
|
+
else if (ratio < 1) {
|
|
50
|
+
// Image is taller, so horizontal padding was added
|
|
51
|
+
// Calculate normalized padding for the padding
|
|
52
|
+
const squaredWidth = img.clientWidth + 2 * padding;
|
|
53
|
+
const normalizedPadding = padding / squaredWidth;
|
|
54
|
+
// Remove normalized padding from x and re-normalize to the
|
|
55
|
+
// original image width (excluding the padding)
|
|
56
|
+
x = (box.x - normalizedPadding) / (1 - 2 * normalizedPadding);
|
|
57
|
+
y = box.y;
|
|
58
|
+
// Scale normalized width and height of the bounding box
|
|
59
|
+
width = box.width / (1 - 2 * normalizedPadding);
|
|
60
|
+
height = box.height;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
x = box.x;
|
|
64
|
+
y = box.y;
|
|
65
|
+
width = box.width;
|
|
66
|
+
height = box.height;
|
|
67
|
+
}
|
|
68
|
+
// Now scale the coordinates to the original image ratio
|
|
69
|
+
x = Math.max(0, Math.min(x * img.clientWidth, img.clientWidth));
|
|
70
|
+
y = Math.max(0, Math.min(y * img.clientHeight, img.clientHeight));
|
|
71
|
+
width = Math.min(width * img.clientWidth, img.clientWidth - x);
|
|
72
|
+
height = Math.min(height * img.clientHeight, img.clientHeight - y);
|
|
73
|
+
}
|
|
74
|
+
else if (resizeMode === 'crop') {
|
|
75
|
+
// Not expected
|
|
76
|
+
return { x: 0, y: 0, height: 0, width: 0 };
|
|
77
|
+
}
|
|
78
|
+
return { x, y, height, width };
|
|
79
|
+
};
|
|
80
|
+
exports.mapPredictionToOriginalImage = mapPredictionToOriginalImage;
|
|
81
|
+
// Calculates the width/height of the area to be masked (at one side).
|
|
82
|
+
const getMaskSize = (side, img) => {
|
|
83
|
+
let maskSize = 0;
|
|
84
|
+
if (side === 'horizontal' && img.clientWidth > img.clientHeight) {
|
|
85
|
+
const factor = img.naturalWidth / img.naturalHeight;
|
|
86
|
+
const maskedTotalWidth = img.clientWidth - (img.clientWidth / factor);
|
|
87
|
+
maskSize = Math.floor(maskedTotalWidth / 2);
|
|
88
|
+
}
|
|
89
|
+
else if (side === 'vertical' && img.clientHeight > img.clientWidth) {
|
|
90
|
+
const factor = img.naturalHeight / img.naturalWidth;
|
|
91
|
+
const maskedTotalHeight = img.clientHeight - (img.clientHeight / factor);
|
|
92
|
+
maskSize = Math.floor(maskedTotalHeight / 2);
|
|
93
|
+
}
|
|
94
|
+
return maskSize;
|
|
95
|
+
};
|
|
96
|
+
exports.getMaskSize = getMaskSize;
|
|
97
|
+
// Calculates the width/height to make the image squared (at one side).
|
|
98
|
+
const getLetterboxSize = (img) => {
|
|
99
|
+
let maskSize = 0;
|
|
100
|
+
const ratio = img.naturalWidth / img.naturalHeight;
|
|
101
|
+
if (ratio > 1) {
|
|
102
|
+
// Image is wider, calculate vertical padding to make it square
|
|
103
|
+
const maskedTotalHeight = img.clientWidth - (img.clientWidth / ratio);
|
|
104
|
+
maskSize = Math.floor(maskedTotalHeight / 2);
|
|
105
|
+
}
|
|
106
|
+
else if (ratio < 1) {
|
|
107
|
+
// Image is taller, calculate horizontal padding to make it square
|
|
108
|
+
const maskedTotalWidth = img.clientHeight - (img.clientHeight * ratio);
|
|
109
|
+
maskSize = Math.floor(maskedTotalWidth / 2);
|
|
110
|
+
}
|
|
111
|
+
return maskSize;
|
|
112
|
+
};
|
|
113
|
+
const mapStructuredResultsBoundingBox = (opts) => {
|
|
114
|
+
const bb = (0, exports.mapPredictionToOriginalImage)(opts.mode, {
|
|
115
|
+
label: 'test',
|
|
116
|
+
x: opts.box.xmin,
|
|
117
|
+
y: opts.box.ymin,
|
|
118
|
+
width: (opts.box.xmax - opts.box.xmin),
|
|
119
|
+
height: (opts.box.ymax - opts.box.ymin),
|
|
120
|
+
}, {
|
|
121
|
+
naturalWidth: opts.originalWidth,
|
|
122
|
+
naturalHeight: opts.originalHeight,
|
|
123
|
+
clientWidth: opts.originalWidth,
|
|
124
|
+
clientHeight: opts.originalHeight,
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
x: Math.round(bb.x),
|
|
128
|
+
y: Math.round(bb.y),
|
|
129
|
+
width: Math.round(bb.width),
|
|
130
|
+
height: Math.round(bb.height),
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
exports.mapStructuredResultsBoundingBox = mapStructuredResultsBoundingBox;
|
|
134
|
+
const mapResizedPixelResultsBoundingBox = (opts) => {
|
|
135
|
+
const bb = (0, exports.mapPredictionToOriginalImage)(opts.mode, {
|
|
136
|
+
label: 'test',
|
|
137
|
+
x: opts.box.x / opts.resized.newWidth,
|
|
138
|
+
y: opts.box.y / opts.resized.newHeight,
|
|
139
|
+
width: opts.box.width / opts.resized.newWidth,
|
|
140
|
+
height: opts.box.height / opts.resized.newHeight,
|
|
141
|
+
}, {
|
|
142
|
+
naturalWidth: opts.resized.originalWidth,
|
|
143
|
+
naturalHeight: opts.resized.originalHeight,
|
|
144
|
+
clientWidth: opts.resized.originalWidth,
|
|
145
|
+
clientHeight: opts.resized.originalHeight,
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
x: Math.round(bb.x),
|
|
149
|
+
y: Math.round(bb.y),
|
|
150
|
+
width: Math.round(bb.width),
|
|
151
|
+
height: Math.round(bb.height),
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
exports.mapResizedPixelResultsBoundingBox = mapResizedPixelResultsBoundingBox;
|
|
155
|
+
//# sourceMappingURL=bounding-box-scaling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounding-box-scaling.js","sourceRoot":"","sources":["../../../../shared/views/project/bounding-box-scaling.ts"],"names":[],"mappings":";;;AAUA;;;EAGE;AACK,MAAM,4BAA4B,GAAG,CACxC,UAAsB,EACtB,GAAgB,EAChB,GAKC,EACH,EAAE;IACA,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,IAAI,UAAU,KAAK,QAAQ,EAAE;QACzB,yDAAyD;QACzD,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC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EAAE,GAAG,IAAA,oCAA4B,EAAC,IAAI,CAAC,IAAI,EAAE;QAC/C,KAAK,EAAE,MAAM;QACb,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ;QACrC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS;QACtC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ;QAC7C,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS;KACnD,EAAE;QACC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;QACxC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;QAC1C,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;QACvC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;KAC5C,CAAC,CAAC;IAEH,OAAO;QACH,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;QAC3B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC;KAChC,CAAC;AACN,CAAC,CAAC;AA7BW,QAAA,iCAAiC,qCA6B5C"}
|
|
@@ -463,16 +463,23 @@ video {
|
|
|
463
463
|
background-color: #bcf1fb;
|
|
464
464
|
}
|
|
465
465
|
|
|
466
|
+
#inferencing-in-progress th:first-child, #inferencing-in-progress td:first-child {
|
|
467
|
+
overflow: visible;
|
|
468
|
+
width: 80px;
|
|
469
|
+
}
|
|
470
|
+
|
|
466
471
|
.badge-camera {
|
|
467
472
|
text-transform: none;
|
|
468
473
|
}
|
|
469
474
|
|
|
470
475
|
.capture-camera-inner {
|
|
471
|
-
height: 100%;
|
|
472
476
|
display: inline-block;
|
|
473
477
|
position: relative;
|
|
474
|
-
|
|
475
|
-
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.capture-camera-inner img {
|
|
481
|
+
display: block;
|
|
482
|
+
width: 100%;
|
|
476
483
|
}
|
|
477
484
|
|
|
478
485
|
.bounding-box-label {
|
|
@@ -4176,6 +4183,11 @@ video {
|
|
|
4176
4183
|
|
|
4177
4184
|
#preview-image-container {
|
|
4178
4185
|
position: relative;
|
|
4186
|
+
max-width: 100%;
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
#preview-image-container img {
|
|
4190
|
+
max-width: 100%;
|
|
4179
4191
|
}
|
|
4180
4192
|
|
|
4181
4193
|
#thresholds-body {
|
|
@@ -4211,3 +4223,19 @@ video {
|
|
|
4211
4223
|
.embed-view .header-logo-col {
|
|
4212
4224
|
display: none;
|
|
4213
4225
|
}
|
|
4226
|
+
|
|
4227
|
+
.embed-view #header-row {
|
|
4228
|
+
border: 0 !important;
|
|
4229
|
+
}
|
|
4230
|
+
.embed-view #header-row .col-auto {
|
|
4231
|
+
z-index: 100000;
|
|
4232
|
+
}
|
|
4233
|
+
.embed-view #header-row .header-title-col {
|
|
4234
|
+
visibility: hidden;
|
|
4235
|
+
}
|
|
4236
|
+
.embed-view #header-row .btn-icon-only {
|
|
4237
|
+
background: white;
|
|
4238
|
+
}
|
|
4239
|
+
.embed-view #capture-camera {
|
|
4240
|
+
margin-top: -68px !important;
|
|
4241
|
+
}
|
|
@@ -118,108 +118,112 @@ window.InferenceServer = async (opts) => {
|
|
|
118
118
|
reader.readAsDataURL(els.uploadFile.files[0]);
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
els.previewSectionImg.
|
|
121
|
+
els.previewSectionImg.onload = () => {
|
|
122
|
+
const result = body.result;
|
|
123
|
+
let factor = els.previewSectionImg.naturalHeight / els.previewSectionImg.clientHeight;
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
for (let oldEl of els.previewSectionImgContainer.querySelectorAll('.bounding-box-container')) {
|
|
126
|
+
oldEl.parentNode.removeChild(oldEl);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (let b of (result.bounding_boxes || [])) {
|
|
130
|
+
let bb = {
|
|
131
|
+
x: b.x / factor,
|
|
132
|
+
y: b.y / factor,
|
|
133
|
+
width: b.width / factor,
|
|
134
|
+
height: b.height / factor,
|
|
135
|
+
label: b.label,
|
|
136
|
+
value: b.value
|
|
137
|
+
};
|
|
138
|
+
if (!labelToColor[bb.label]) {
|
|
139
|
+
labelToColor[bb.label] = colors[colorIx++ % colors.length];
|
|
140
|
+
}
|
|
141
|
+
let color = labelToColor[bb.label];
|
|
142
|
+
let el = document.createElement('div');
|
|
143
|
+
el.classList.add('bounding-box-container');
|
|
144
|
+
el.style.position = 'absolute';
|
|
145
|
+
el.style.border = 'solid 3px ' + color;
|
|
146
|
+
|
|
147
|
+
if (modelType === 'object_detection') {
|
|
148
|
+
el.style.width = (bb.width) + 'px';
|
|
149
|
+
el.style.height = (bb.height) + 'px';
|
|
150
|
+
el.style.left = (bb.x) + 'px';
|
|
151
|
+
el.style.top = (bb.y) + 'px';
|
|
152
|
+
}
|
|
153
|
+
else if (modelType === 'constrained_object_detection') {
|
|
154
|
+
let centerX = bb.x + (bb.width / 2);
|
|
155
|
+
let centerY = bb.y + (bb.height / 2);
|
|
156
|
+
|
|
157
|
+
el.style.borderRadius = '10px';
|
|
158
|
+
el.style.width = '20px';
|
|
159
|
+
el.style.height = '20px';
|
|
160
|
+
el.style.left = (centerX - 10) + 'px';
|
|
161
|
+
el.style.top = (centerY - 10) + 'px';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
let label = document.createElement('div');
|
|
165
|
+
label.classList.add('bounding-box-label');
|
|
166
|
+
label.style.background = color;
|
|
167
|
+
label.textContent = bb.label + ' (' + bb.value.toFixed(2) + ')';
|
|
168
|
+
el.style.whiteSpace = 'nowrap';
|
|
169
|
+
el.appendChild(label);
|
|
170
|
+
els.previewSectionImgContainer.appendChild(el);
|
|
141
171
|
}
|
|
142
|
-
let color = labelToColor[bb.label];
|
|
143
|
-
let el = document.createElement('div');
|
|
144
|
-
el.classList.add('bounding-box-container');
|
|
145
|
-
el.style.position = 'absolute';
|
|
146
|
-
el.style.border = 'solid 3px ' + color;
|
|
147
172
|
|
|
148
|
-
|
|
173
|
+
for (let b of (result.visual_anomaly_grid || [])) {
|
|
174
|
+
let bb = {
|
|
175
|
+
x: b.x / factor,
|
|
176
|
+
y: b.y / factor,
|
|
177
|
+
width: b.width / factor,
|
|
178
|
+
height: b.height / factor,
|
|
179
|
+
label: b.label,
|
|
180
|
+
value: b.value
|
|
181
|
+
};
|
|
182
|
+
let el = document.createElement('div');
|
|
183
|
+
el.classList.add('bounding-box-container');
|
|
184
|
+
el.style.position = 'absolute';
|
|
185
|
+
el.style.background = 'rgba(255, 0, 0, 0.5)';
|
|
149
186
|
el.style.width = (bb.width) + 'px';
|
|
150
187
|
el.style.height = (bb.height) + 'px';
|
|
151
188
|
el.style.left = (bb.x) + 'px';
|
|
152
189
|
el.style.top = (bb.y) + 'px';
|
|
153
|
-
}
|
|
154
|
-
else if (modelType === 'constrained_object_detection') {
|
|
155
|
-
let centerX = bb.x + (bb.width / 2);
|
|
156
|
-
let centerY = bb.y + (bb.height / 2);
|
|
157
|
-
|
|
158
|
-
el.style.borderRadius = '10px';
|
|
159
|
-
el.style.width = '20px';
|
|
160
|
-
el.style.height = '20px';
|
|
161
|
-
el.style.left = (centerX - 10) + 'px';
|
|
162
|
-
el.style.top = (centerY - 10) + 'px';
|
|
163
|
-
}
|
|
164
190
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let scoreText = bb.value.toFixed(2);
|
|
194
|
-
if (bb.width < 15) {
|
|
195
|
-
scoreFontSize = '4px';
|
|
196
|
-
scoreText = bb.value.toFixed(1);
|
|
197
|
-
}
|
|
198
|
-
else if (bb.width < 20) {
|
|
199
|
-
scoreFontSize = '6px';
|
|
200
|
-
scoreText = bb.value.toFixed(1);
|
|
191
|
+
let scoreFontSize = '';
|
|
192
|
+
let scoreText = bb.value.toFixed(2);
|
|
193
|
+
if (bb.width < 15) {
|
|
194
|
+
scoreFontSize = '4px';
|
|
195
|
+
scoreText = bb.value.toFixed(1);
|
|
196
|
+
}
|
|
197
|
+
else if (bb.width < 20) {
|
|
198
|
+
scoreFontSize = '6px';
|
|
199
|
+
scoreText = bb.value.toFixed(1);
|
|
200
|
+
}
|
|
201
|
+
else if (bb.width < 32) {
|
|
202
|
+
scoreFontSize = '9px';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let score = document.createElement('div');
|
|
206
|
+
score.style.color = 'white';
|
|
207
|
+
if (scoreFontSize) {
|
|
208
|
+
score.style.fontSize = scoreFontSize;
|
|
209
|
+
}
|
|
210
|
+
score.textContent = scoreText;
|
|
211
|
+
el.appendChild(score);
|
|
212
|
+
|
|
213
|
+
// Center align the score
|
|
214
|
+
el.style.display = 'flex';
|
|
215
|
+
el.style.alignItems = 'center';
|
|
216
|
+
el.style.justifyContent = 'center';
|
|
217
|
+
|
|
218
|
+
els.previewSectionImgContainer.appendChild(el);
|
|
201
219
|
}
|
|
202
|
-
|
|
203
|
-
scoreFontSize = '9px';
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
let score = document.createElement('div');
|
|
207
|
-
score.style.color = 'white';
|
|
208
|
-
if (scoreFontSize) {
|
|
209
|
-
score.style.fontSize = scoreFontSize;
|
|
210
|
-
}
|
|
211
|
-
score.textContent = scoreText;
|
|
212
|
-
el.appendChild(score);
|
|
220
|
+
};
|
|
213
221
|
|
|
214
|
-
|
|
215
|
-
el.style.display = 'flex';
|
|
216
|
-
el.style.alignItems = 'center';
|
|
217
|
-
el.style.justifyContent = 'center';
|
|
222
|
+
els.previewSectionImg.src = dataUrl;
|
|
218
223
|
|
|
219
|
-
els.previewSectionImgContainer.appendChild(el);
|
|
220
|
-
}
|
|
221
224
|
}
|
|
222
225
|
else {
|
|
226
|
+
els.previewSectionImg.onload = null;
|
|
223
227
|
els.previewSection.style.display = 'none';
|
|
224
228
|
}
|
|
225
229
|
|
|
@@ -234,4 +238,11 @@ window.InferenceServer = async (opts) => {
|
|
|
234
238
|
els.runInferenceBtn.textContent = origText;
|
|
235
239
|
}
|
|
236
240
|
};
|
|
241
|
+
|
|
242
|
+
// rerender bounding boxes on resize
|
|
243
|
+
window.onresize = () => {
|
|
244
|
+
if (els.previewSectionImg.onload) {
|
|
245
|
+
els.previewSectionImg.onload();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
237
248
|
};
|