openvino-node
Advanced tools
+11
| { | ||
| "$schema": "https://json.schemastore.org/prettierrc", | ||
| "semi": true, | ||
| "printWidth": 100, | ||
| "endOfLine": "lf", | ||
| "tabWidth": 2, | ||
| "singleQuote": false, | ||
| "trailingComma": "all", | ||
| "bracketSpacing": true, | ||
| "proseWrap": "always" | ||
| } |
| const eslint = require("@eslint/js"); | ||
| const prettierConfig = require("eslint-plugin-prettier/recommended"); | ||
| const globals = require("globals"); | ||
| const tseslint = require("typescript-eslint"); | ||
| const { defineConfig } = require("eslint/config"); | ||
| const path = require("node:path"); | ||
| module.exports = defineConfig([ | ||
| { | ||
| ignores: ["types/", "dist/"], | ||
| }, | ||
| { | ||
| files: ["**/*.*js"], | ||
| languageOptions: { | ||
| globals: globals.node, | ||
| }, | ||
| extends: [eslint.configs.recommended], | ||
| }, | ||
| { | ||
| files: ["**/*.ts"], | ||
| languageOptions: { | ||
| globals: globals.node, | ||
| parser: tseslint.parser, | ||
| parserOptions: { | ||
| projectService: true, | ||
| project: "./tsconfig.json", | ||
| tsconfigRootDir: path.resolve(), | ||
| }, | ||
| }, | ||
| extends: [tseslint.configs.recommendedTypeChecked], | ||
| rules: { | ||
| "@typescript-eslint/no-require-imports": 0, | ||
| }, | ||
| }, | ||
| { | ||
| rules: { | ||
| "no-var": ["error"], | ||
| camelcase: ["error"], | ||
| "prefer-destructuring": ["error", { object: true, array: false }], | ||
| }, | ||
| }, | ||
| prettierConfig, // to disable stylistic rules from ESLint | ||
| { | ||
| files: ["**/addon.ts"], | ||
| rules: { | ||
| "@typescript-eslint/no-misused-new": "off", | ||
| }, | ||
| }, | ||
| ]); |
+33
-25
| # Contributing to OpenVINO™ Node.js API | ||
| Your commitment to this project is greatly appreciated and the following guide is intended to help you contribute. | ||
| Your commitment to this project is greatly appreciated and the following guide is intended to help | ||
| you contribute. | ||
| Make sure to read [main contribution guide](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING.md) first. It covers most topics related to contributing to OpenVINO. | ||
| Make sure to read | ||
| [main contribution guide](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING.md) | ||
| first. It covers most topics related to contributing to OpenVINO. | ||
| ## TLDR | ||
@@ -20,36 +22,43 @@ | ||
| ## How to Decide What to Change | ||
| In case of minor fixes, like changing variable names, additional parameter checks, etc., go to the next step. | ||
| In case of minor fixes, like changing variable names, additional parameter checks, etc., go to the | ||
| next step. | ||
| However, if you want to bring significant changes, for example, the extension of architecture or a big part of functionality, that involves a large amount | ||
| of source code, open [an issue](https://github.com/openvinotoolkit/openvino/issues/new?assignees=octocat&labels=enhancement%2Cfeature&projects=&template=feature_request.yml&title=%5BFeature+Request%5D%3A+) first and discuss your idea with | ||
| codeowners. It will prevent you from doing extra work. | ||
| However, if you want to bring significant changes, for example, the extension of architecture or a | ||
| big part of functionality, that involves a large amount of source code, open | ||
| [an issue](https://github.com/openvinotoolkit/openvino/issues/new?assignees=octocat&labels=enhancement%2Cfeature&projects=&template=feature_request.yml&title=%5BFeature+Request%5D%3A+) | ||
| first and discuss your idea with codeowners. It will prevent you from doing extra work. | ||
| You can also take one of the well-described tasks from the [Good First Issue](https://github.com/orgs/openvinotoolkit/projects/3/views/14) section. It can be a great start to contributing with codeowners' support! | ||
| You can also take one of the well-described tasks from the | ||
| [Good First Issue](https://github.com/orgs/openvinotoolkit/projects/3/views/14) section. It can be a | ||
| great start to contributing with codeowners' support! | ||
| ## Let's code | ||
| Get familiar with Node.js API architecture and code samples. | ||
| Refer to the [guide](../docs/code_examples.md), which will help you understand the component structure and the code style. | ||
| Get familiar with Node.js API architecture and code samples. Refer to the | ||
| [guide](../docs/code_examples.md), which will help you understand the component structure and the | ||
| code style. | ||
| The environment setup and build instructions can be found in [Building the Node.js API](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/docs/README.md#openvino-node-package-developer-documentation). | ||
| The environment setup and build instructions can be found in | ||
| [Building the Node.js API](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/docs/README.md#openvino-node-package-developer-documentation). | ||
| Run tests! If you add a new functionality, make sure that it is covered by tests first. | ||
| Read [the guide](../docs/test_examples.md) for more details about the tests and their runs. | ||
| Many CI checks will run after getting a Code Review. Make sure that | ||
| all checks have passed. CI checks are composed of both functional tests and code-style checks and may fail because of warnings/errors in both stages. | ||
| Run tests! If you add a new functionality, make sure that it is covered by tests first. Read | ||
| [the guide](../docs/test_examples.md) for more details about the tests and their runs. Many CI | ||
| checks will run after getting a Code Review. Make sure that all checks have passed. CI checks are | ||
| composed of both functional tests and code-style checks and may fail because of warnings/errors in | ||
| both stages. | ||
| Remember to follow [our codestyle](../docs/CODESTYLE.md). | ||
| By following the provided guide and using an automotive code style checking tool, like | ||
| **eslint** and **clang-format-9**, you will save some time and help with the code review of proposed changes. | ||
| Remember to follow [our codestyle](../docs/CODESTYLE.md). By following the provided guide and using | ||
| an automotive code style checking tool, like **eslint** and **clang-format-18**, you will save some | ||
| time and help with the code review of proposed changes. | ||
| ## Description of the Pull Request | ||
| Append all PR titles with the `[OV JS]` tag. Provide any relevant details in the description, as it will definitely help with the review. The minimum requirement is a compact, bulleted list of proposed changes. | ||
| Append all PR titles with the `[OV JS]` tag. Provide any relevant details in the description, as it | ||
| will definitely help with the review. The minimum requirement is a compact, bulleted list of | ||
| proposed changes. | ||
| Use the following template: | ||
| ``` | ||
@@ -64,6 +73,5 @@ *Describe what is the purpose of this PR* | ||
| ## License | ||
| By contributing to the OpenVINO project, you agree that your contributions will be | ||
| licensed under the terms of the [LICENSE](https://github.com/openvinotoolkit/openvino/blob/master/LICENSE). | ||
| By contributing to the OpenVINO project, you agree that your contributions will be licensed under | ||
| the terms of the [LICENSE](https://github.com/openvinotoolkit/openvino/blob/master/LICENSE). |
+1
-1
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.default = require('../bin/ov_node_addon.node'); | ||
| exports.default = require("../bin/ov_node_addon.node"); | ||
| //# sourceMappingURL=addon.js.map |
+11
-6
| { | ||
| "name": "openvino-node", | ||
| "version": "2025.2.0", | ||
| "version": "2025.3.0", | ||
| "description": "OpenVINO™ utils for using from Node.js environment", | ||
@@ -21,2 +21,3 @@ "repository": { | ||
| "lint": "eslint .", | ||
| "format": "prettier --ignore-path .gitignore --write .", | ||
| "test_setup": "node ./tests/setup.js", | ||
@@ -31,9 +32,13 @@ "test": "npm run test_setup && node --test ./tests/unit/*.test.js", | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.30.1", | ||
| "@types/node": "^22.13.4", | ||
| "@typescript-eslint/eslint-plugin": "^8.34.0", | ||
| "@typescript-eslint/parser": "^8.34.0", | ||
| "eslint": "^8.49.0", | ||
| "mocha": "^10.6.0", | ||
| "eslint": "^9.30.1", | ||
| "eslint-config-prettier": "^10.1.5", | ||
| "eslint-plugin-prettier": "^5.5.1", | ||
| "globals": "^16.3.0", | ||
| "mocha": "^11.7.1", | ||
| "prettier": "3.6.2", | ||
| "random-bigint": "^0.0.1", | ||
| "typescript": "^5.0.4" | ||
| "typescript": "^5.0.4", | ||
| "typescript-eslint": "^8.36.0" | ||
| }, | ||
@@ -40,0 +45,0 @@ "engines": { |
+23
-15
@@ -7,5 +7,5 @@ # OpenVINO™ Node.js Bindings | ||
| OpenVINO™ is an open-source toolkit designed for high-performance deep learning inference. | ||
| Node.js API provides bindings to subset APIs from OpenVINO Runtime. | ||
| The Node.js bindings enable JavaScript developers to use the capabilities of OpenVINO in their applications. | ||
| OpenVINO™ is an open-source toolkit designed for high-performance deep learning inference. Node.js | ||
| API provides bindings to subset APIs from OpenVINO Runtime. The Node.js bindings enable JavaScript | ||
| developers to use the capabilities of OpenVINO in their applications. | ||
@@ -15,2 +15,3 @@ ## Quick Start | ||
| Install the **openvino-node** package: | ||
| ```bash | ||
@@ -21,14 +22,17 @@ npm install openvino-node | ||
| Use the **openvino-node** package: | ||
| ```js | ||
| const { addon: ov } = require('openvino-node'); | ||
| const { addon: ov } = require("openvino-node"); | ||
| ``` | ||
| Refer to the complete description of the `addon` API in the [documentation](https://docs.openvino.ai/2025/api/nodejs_api/addon.html). | ||
| Refer to the complete description of the `addon` API in the | ||
| [documentation](https://docs.openvino.ai/2025/api/nodejs_api/addon.html). | ||
| See the [samples](https://github.com/openvinotoolkit/openvino/blob/master/samples/js/node/README.md) for more details on how to use it. | ||
| See the [samples](https://github.com/openvinotoolkit/openvino/blob/master/samples/js/node/README.md) | ||
| for more details on how to use it. | ||
| ## Usage in Electron applications | ||
| To use the package in development of Electron applications on Windows, make sure that | ||
| **Desktop development with C++** component from | ||
| To use the package in development of Electron applications on Windows, make sure that **Desktop | ||
| development with C++** component from | ||
| [Build Tools for Visual Studio](https://aka.ms/vs/17/release/vs_BuildTools.exe) is installed. | ||
@@ -50,3 +54,4 @@ | ||
| You can run the following sample in the browser, no installation is required. | ||
| [Codesandbox](https://codesandbox.io/) is a free online service with limited resources. For optimal performance and more control, it is recommended to run the sample locally. | ||
| [Codesandbox](https://codesandbox.io/) is a free online service with limited resources. For optimal | ||
| performance and more control, it is recommended to run the sample locally. | ||
@@ -57,14 +62,17 @@ - [hello-classification-sample](https://codesandbox.io/p/devbox/openvino-node-hello-classification-sample-djl893) | ||
| For more details, refer to the [OpenVINO™ JavaScript API Developer Documentation](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/docs/README.md#openvino-node-package-developer-documentation) | ||
| For more details, refer to the | ||
| [OpenVINO™ JavaScript API Developer Documentation](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/docs/README.md#openvino-node-package-developer-documentation) | ||
| ## Contributing | ||
| Contributions are always welcome! Read the [Contribution Guide](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/CONTRIBUTING.md) to learn how you can get involved. | ||
| Contributions are always welcome! Read the | ||
| [Contribution Guide](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/js/node/CONTRIBUTING.md) | ||
| to learn how you can get involved. | ||
| ## See Also | ||
| * [OpenVINO™ README](https://github.com/openvinotoolkit/openvino/blob/master/README.md) | ||
| * [OpenVINO™ Core Components](https://github.com/openvinotoolkit/openvino/blob/master/src/README.md) | ||
| * [OpenVINO™ Python API](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/python/README.md) | ||
| * [OpenVINO™ Other Bindings](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/README.md) | ||
| - [OpenVINO™ README](https://github.com/openvinotoolkit/openvino/blob/master/README.md) | ||
| - [OpenVINO™ Core Components](https://github.com/openvinotoolkit/openvino/blob/master/src/README.md) | ||
| - [OpenVINO™ Python API](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/python/README.md) | ||
| - [OpenVINO™ Other Bindings](https://github.com/openvinotoolkit/openvino/blob/master/src/bindings/README.md) | ||
@@ -71,0 +79,0 @@ [License](https://github.com/openvinotoolkit/openvino/blob/master/LICENSE) |
@@ -1,5 +0,5 @@ | ||
| const { join } = require('node:path'); | ||
| const { join } = require("node:path"); | ||
| const BinaryManager = require('./lib/binary-manager'); | ||
| const packageJson = require('../package.json'); | ||
| const BinaryManager = require("./lib/binary-manager"); | ||
| const packageJson = require("../package.json"); | ||
@@ -11,5 +11,4 @@ if (require.main === module) main(); | ||
| const force = process.argv.includes('-f') || process.argv.includes('--force'); | ||
| const ignoreIfExists = process.argv.includes('-i') | ||
| || process.argv.includes('--ignore-if-exists'); | ||
| const force = process.argv.includes("-f") || process.argv.includes("--force"); | ||
| const ignoreIfExists = process.argv.includes("-i") || process.argv.includes("--ignore-if-exists"); | ||
@@ -20,3 +19,3 @@ const { env } = process; | ||
| await BinaryManager.prepareBinary( | ||
| join(__dirname, '..'), | ||
| join(__dirname, ".."), | ||
| packageJson.binary.version || packageJson.version, | ||
@@ -23,0 +22,0 @@ packageJson.binary, |
@@ -1,9 +0,9 @@ | ||
| const os = require('node:os'); | ||
| const tar = require('tar-fs'); | ||
| const path = require('node:path'); | ||
| const gunzip = require('gunzip-maybe'); | ||
| const fs = require('node:fs/promises'); | ||
| const { createReadStream, existsSync } = require('node:fs'); | ||
| const os = require("node:os"); | ||
| const tar = require("tar-fs"); | ||
| const path = require("node:path"); | ||
| const gunzip = require("gunzip-maybe"); | ||
| const fs = require("node:fs/promises"); | ||
| const { createReadStream, existsSync } = require("node:fs"); | ||
| const { downloadFile, checkIfPathExists, removeDirectory } = require('./utils'); | ||
| const { downloadFile, checkIfPathExists, removeDirectory } = require("./utils"); | ||
@@ -26,3 +26,3 @@ class BinaryManager { | ||
| getExtension() { | ||
| return 'tar.gz'; | ||
| return "tar.gz"; | ||
| } | ||
@@ -38,6 +38,6 @@ | ||
| const fullPath = fullPathTemplate | ||
| .replace(new RegExp('{version}', 'g'), this.version) | ||
| .replace(new RegExp('{platform}', 'g'), this.getPlatformLabel()) | ||
| .replace(new RegExp('{arch}', 'g'), this.getArchLabel()) | ||
| .replace(new RegExp('{extension}', 'g'), this.getExtension()); | ||
| .replace(new RegExp("{version}", "g"), this.version) | ||
| .replace(new RegExp("{platform}", "g"), this.getPlatformLabel()) | ||
| .replace(new RegExp("{arch}", "g"), this.getArchLabel()) | ||
| .replace(new RegExp("{extension}", "g"), this.getExtension()); | ||
@@ -48,3 +48,3 @@ return new URL(fullPath, host).toString(); | ||
| getDestinationPath() { | ||
| const modulePath = this.binaryConfig['module_path']; | ||
| const modulePath = this.binaryConfig["module_path"]; | ||
@@ -82,4 +82,4 @@ return path.resolve(this.packageRoot, modulePath); | ||
| console.warn( | ||
| `Directory '${destinationPath}' already exists. Skipping ` | ||
| + 'runtime downloading because "ignoreIfExists" flag is passed.' | ||
| `Directory '${destinationPath}' already exists. Skipping ` + | ||
| 'runtime downloading because "ignoreIfExists" flag is passed.', | ||
| ); | ||
@@ -97,18 +97,19 @@ | ||
| // Install binaries from directories if possible | ||
| if (process.env.npm_package_resolved?.startsWith('file:')) { | ||
| const binDir = path.join( | ||
| path.dirname(process.env.npm_package_resolved), | ||
| 'bin' | ||
| ).replace('file:', ''); | ||
| if (existsSync(path.join(binDir, 'libopenvino.so')) || | ||
| existsSync(path.join(binDir, 'openvino.dll'))) { | ||
| if (process.env.npm_package_resolved?.startsWith("file:")) { | ||
| const binDir = path | ||
| .join(path.dirname(process.env.npm_package_resolved), "bin") | ||
| .replace("file:", ""); | ||
| if ( | ||
| existsSync(path.join(binDir, "libopenvino.so")) || | ||
| existsSync(path.join(binDir, "openvino.dll")) | ||
| ) { | ||
| try { | ||
| await fs.cp(binDir, destinationPath, {'recursive': true}); | ||
| await fs.cp(binDir, destinationPath, { recursive: true }); | ||
| return; | ||
| } catch(error) { | ||
| } catch (error) { | ||
| console.error(`Failed to copy bin directory: ${error}.`); | ||
| } | ||
| } | ||
| console.log('Do not find bin directory with openvino library.'); | ||
| console.log("Do not find bin directory with openvino library."); | ||
| } | ||
@@ -120,9 +121,7 @@ | ||
| try { | ||
| tempDirectoryPath = await fs.mkdtemp( | ||
| path.join(os.tmpdir(), 'temp-ov-runtime-archive-') | ||
| ); | ||
| tempDirectoryPath = await fs.mkdtemp(path.join(os.tmpdir(), "temp-ov-runtime-archive-")); | ||
| const filename = path.basename(archiveUrl); | ||
| console.log('Downloading OpenVINO runtime archive...'); | ||
| console.log("Downloading OpenVINO runtime archive..."); | ||
| const archiveFilePath = await downloadFile( | ||
@@ -134,8 +133,8 @@ archiveUrl, | ||
| ); | ||
| console.log('OpenVINO runtime archive downloaded.'); | ||
| console.log("OpenVINO runtime archive downloaded."); | ||
| await removeDirectory(destinationPath); | ||
| await this.unarchive(archiveFilePath, destinationPath); | ||
| console.log('The archive was successfully extracted.'); | ||
| } catch(error) { | ||
| console.log("The archive was successfully extracted."); | ||
| } catch (error) { | ||
| console.error(`Failed to download OpenVINO runtime: ${error}.`); | ||
@@ -164,3 +163,3 @@ throw error; | ||
| if (!['win32', 'linux', 'darwin'].includes(platform)) | ||
| if (!["win32", "linux", "darwin"].includes(platform)) | ||
| missleadings.push(`Platform '${platform}' is not supported.`); | ||
@@ -170,10 +169,10 @@ | ||
| if (!['arm64', 'armhf', 'x64'].includes(arch)) | ||
| if (!["arm64", "armhf", "x64"].includes(arch)) | ||
| missleadings.push(`Architecture '${arch}' is not supported.`); | ||
| if (platform === 'win32' && arch !== 'x64') | ||
| if (platform === "win32" && arch !== "x64") | ||
| missleadings.push(`Version for windows and '${arch}' is not supported.`); | ||
| if (missleadings.length) { | ||
| console.error(missleadings.join(' ')); | ||
| console.error(missleadings.join(" ")); | ||
@@ -198,8 +197,11 @@ return false; | ||
| .pipe(gunzip()) | ||
| .pipe(tar.extract(dest) | ||
| .on('finish', () => { | ||
| resolve(); | ||
| }).on('error', (err) => { | ||
| reject(err); | ||
| }), | ||
| .pipe( | ||
| tar | ||
| .extract(dest) | ||
| .on("finish", () => { | ||
| resolve(); | ||
| }) | ||
| .on("error", (err) => { | ||
| reject(err); | ||
| }), | ||
| ); | ||
@@ -206,0 +208,0 @@ }); |
+12
-13
@@ -1,9 +0,9 @@ | ||
| const path = require('node:path'); | ||
| const https = require('node:https'); | ||
| const fs = require('node:fs/promises'); | ||
| const { createWriteStream } = require('node:fs'); | ||
| const path = require("node:path"); | ||
| const https = require("node:https"); | ||
| const fs = require("node:fs/promises"); | ||
| const { createWriteStream } = require("node:fs"); | ||
| const { HttpsProxyAgent } = require('https-proxy-agent'); | ||
| const { HttpsProxyAgent } = require("https-proxy-agent"); | ||
| const codeENOENT = 'ENOENT'; | ||
| const codeENOENT = "ENOENT"; | ||
@@ -46,2 +46,3 @@ module.exports = { | ||
| await fs.access(path); | ||
| return true; | ||
@@ -67,4 +68,3 @@ } catch (error) { | ||
| function downloadFile(url, destination, filename, proxy = null) { | ||
| console.log(`Downloading file by link: ${url} to ${destination}` | ||
| + `with filename: ${filename}`); | ||
| console.log(`Downloading file by link: ${url} to ${destination}` + `with filename: ${filename}`); | ||
@@ -75,4 +75,3 @@ const timeout = 5000; | ||
| if (new URL(url).protocol === 'http:') | ||
| throw new Error('Http link doesn\'t support'); | ||
| if (new URL(url).protocol === "http:") throw new Error("Http link doesn't support"); | ||
@@ -87,3 +86,3 @@ let agent; | ||
| return new Promise((resolve, reject) => { | ||
| file.on('error', (error) => { | ||
| file.on("error", (error) => { | ||
| reject(`Failed to open file stream: ${error}.`); | ||
@@ -103,3 +102,3 @@ }); | ||
| file.on('finish', () => { | ||
| file.on("finish", () => { | ||
| file.close(); | ||
@@ -111,3 +110,3 @@ console.log(`File was successfully downloaded to '${fullPath}'.`); | ||
| request.on('error', (error) => { | ||
| request.on("error", (error) => { | ||
| reject(`Failed to send request: ${error}.`); | ||
@@ -114,0 +113,0 @@ }); |
+120
-58
| type SupportedTypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | ||
| type elementTypeString = 'u8' | 'u32' | 'u16' | 'u64' | 'i8' | 'i64' | 'i32' | 'i16' | 'f64' | 'f32' | 'string'; | ||
| type elementTypeString = "u8" | "u32" | "u16" | "u64" | "i8" | "i64" | "i32" | "i16" | "f64" | "f32" | "string"; | ||
| type OVAny = string | number | boolean; | ||
@@ -14,2 +14,6 @@ /** | ||
| /** | ||
| * It constructs a new Core object. | ||
| */ | ||
| new (): Core; | ||
| /** | ||
| * Registers extensions to a Core object. | ||
@@ -169,10 +173,9 @@ * @param libraryPath Path to the library with ov::Extension. | ||
| } | ||
| interface CoreConstructor { | ||
| new (): Core; | ||
| } | ||
| /** | ||
| * A user-defined model read by {@link Core.readModel}. | ||
| */ | ||
| interface Model { | ||
| /** | ||
| * It constructs a default Model object. Use {@link Core.readModel} | ||
| * to read Model from supported file format. | ||
| */ | ||
| new (): Model; | ||
| /** | ||
| * It returns a cloned model. | ||
@@ -248,2 +251,17 @@ */ | ||
| setFriendlyName(name: string): void; | ||
| /** Reshapes model input. | ||
| * @param partialShape The {@link PartialShape} object | ||
| * or its string representation to reshape the model input. | ||
| * @param variablesShapes New shapes for variables. | ||
| */ | ||
| reshape(partialShape: PartialShape | string, variablesShapes?: Record<string, PartialShape | string>): Model; | ||
| /** Reshapes model inputs. | ||
| * @param partialShapes A Map with partial shapes. | ||
| * @param key The key is a model input index, tensor name | ||
| * or {@link Output} object. | ||
| * @param value The value is a {@link PartialShape} or | ||
| * a string representation of {@link PartialShape}. | ||
| * @param variablesShapes New shapes for variables. | ||
| */ | ||
| reshape(partialShapes: Map<number | string | Output, PartialShape | string>, variablesShapes?: Record<string, PartialShape | string>): Model; | ||
| /** | ||
@@ -264,2 +282,7 @@ * It gets all the model inputs as an array. | ||
| interface CompiledModel { | ||
| /** | ||
| * It constructs a default CompiledModel object. Use {@link Core.compileModel} | ||
| * or {@link Core.importModel} to get model compiled for a specific device. | ||
| */ | ||
| new (): CompiledModel; | ||
| /** It gets all inputs of a compiled model. */ | ||
@@ -333,7 +356,34 @@ inputs: Output[]; | ||
| * The {@link Tensor} is a lightweight class that represents data used for | ||
| * inference. There are different ways to create a tensor. You can find them | ||
| * in {@link TensorConstructor} section. | ||
| * inference. | ||
| * | ||
| * @remarks | ||
| * The tensor memory is shared with the TypedArray. That is, | ||
| * the responsibility for maintaining the reference to the TypedArray lies with | ||
| * the user. Any action performed on the TypedArray will be reflected in this | ||
| * tensor memory. | ||
| */ | ||
| interface Tensor { | ||
| /** | ||
| * It constructs a tensor using the element type and shape. The new tensor | ||
| * data will be allocated by default. | ||
| * @param type The element type of the new tensor. | ||
| * @param shape The shape of the new tensor. | ||
| */ | ||
| new (type: element | elementTypeString, shape: number[]): Tensor; | ||
| /** | ||
| * It constructs a tensor using the element type and shape. The new tensor | ||
| * wraps allocated host memory. | ||
| * @param type The element type of the new tensor. | ||
| * @param shape The shape of the new tensor. | ||
| * @param tensorData A subclass of TypedArray that will be wrapped | ||
| * by a {@link Tensor}. | ||
| */ | ||
| new (type: element | elementTypeString, shape: number[], tensorData: SupportedTypedArray): Tensor; | ||
| /** | ||
| * It constructs a tensor using the element type and shape. The strings from | ||
| * the array are used to fill the new tensor. Each element of a string tensor | ||
| * is a string of arbitrary length, including an empty string. | ||
| */ | ||
| new (tensorData: string[]): Tensor; | ||
| /** | ||
| * This property provides access to the tensor's data. | ||
@@ -375,42 +425,13 @@ * | ||
| /** | ||
| * This interface contains constructors of the {@link Tensor} class. | ||
| * | ||
| * @remarks | ||
| * The tensor memory is shared with the TypedArray. That is, | ||
| * the responsibility for maintaining the reference to the TypedArray lies with | ||
| * the user. Any action performed on the TypedArray will be reflected in this | ||
| * tensor memory. | ||
| * The {@link InferRequest} object is used to make predictions and can be run in | ||
| * asynchronous or synchronous manners. | ||
| */ | ||
| interface TensorConstructor { | ||
| interface InferRequest { | ||
| /** | ||
| * It constructs a tensor using the element type and shape. The new tensor | ||
| * data will be allocated by default. | ||
| * @param type The element type of the new tensor. | ||
| * @param shape The shape of the new tensor. | ||
| * It constructs a default InferRequest object. | ||
| * Use {@link CompiledModel.createInferRequest} | ||
| * to get InferRequest object specific for a given deployed model. | ||
| */ | ||
| new (type: element | elementTypeString, shape: number[]): Tensor; | ||
| new (): InferRequest; | ||
| /** | ||
| * It constructs a tensor using the element type and shape. The new tensor | ||
| * wraps allocated host memory. | ||
| * @param type The element type of the new tensor. | ||
| * @param shape The shape of the new tensor. | ||
| * @param tensorData A subclass of TypedArray that will be wrapped | ||
| * by a {@link Tensor}. | ||
| */ | ||
| new (type: element | elementTypeString, shape: number[], tensorData: SupportedTypedArray): Tensor; | ||
| /** | ||
| * It constructs a tensor using the element type and shape. The strings from | ||
| * the array are used to fill the new tensor. Each element of a string tensor | ||
| * is a string of arbitrary length, including an empty string. | ||
| */ | ||
| new (tensorData: string[]): Tensor; | ||
| } | ||
| /** | ||
| * The {@link InferRequest} object is created using | ||
| * {@link CompiledModel.createInferRequest} method and is specific for a given | ||
| * deployed model. It is used to make predictions and can be run in | ||
| * asynchronous or synchronous manners. | ||
| */ | ||
| interface InferRequest { | ||
| /** | ||
| * It infers specified input(s) in the synchronous mode. | ||
@@ -535,2 +556,3 @@ * @remarks | ||
| interface Output { | ||
| new (): Output; | ||
| anyName: string; | ||
@@ -567,2 +589,3 @@ shape: number[]; | ||
| interface PrePostProcessor { | ||
| new (model: Model): PrePostProcessor; | ||
| build(): PrePostProcessor; | ||
@@ -572,6 +595,9 @@ input(idxOrTensorName?: number | string): InputInfo; | ||
| } | ||
| interface PrePostProcessorConstructor { | ||
| new (model: Model): PrePostProcessor; | ||
| } | ||
| interface PartialShape { | ||
| /** | ||
| * It constructs a PartialShape by passed string. | ||
| * Omit parameter to create empty shape. | ||
| * @param [shape] String representation of the shape. | ||
| */ | ||
| new (shape?: string): PartialShape; | ||
| isStatic(): boolean; | ||
@@ -583,11 +609,41 @@ isDynamic(): boolean; | ||
| /** | ||
| * This interface contains constructor of the {@link PartialShape} class. | ||
| * Callback function type for AsyncInferQueue operations. | ||
| * @param inferRequest The {@link InferRequest} object from the queue's pool. | ||
| * It allows to access input and output tensors. | ||
| * @param userData User data that was passed to the startAsync method. If data was not | ||
| * passed, it will be undefined. | ||
| * @param error Optional error that occurred during inference, if any. | ||
| */ | ||
| interface PartialShapeConstructor { | ||
| type AsyncInferQueueCallback = (error: null | Error, inferRequest: InferRequest, userData: object) => void; | ||
| interface AsyncInferQueue { | ||
| /** | ||
| * It constructs a PartialShape by passed string. | ||
| * Omit parameter to create empty shape. | ||
| * @param [shape] String representation of the shape. | ||
| * Creates AsyncInferQueue. | ||
| * @param compiledModel The compiledModel that will be used | ||
| * to create InferRequests in the pool. | ||
| * @param jobs Number of InferRequest objects in the pool. If not provided, | ||
| * jobs number will be set automatically to the optimal number. | ||
| */ | ||
| new (shape?: string): PartialShape; | ||
| new (compiledModel: CompiledModel, jobs?: number): AsyncInferQueue; | ||
| /** | ||
| * Sets unified callback on all InferRequests from queue's pool. | ||
| * The callback that was previously set will be replaced. | ||
| * @param callback - Any function that matches callback's requirements. | ||
| */ | ||
| setCallback(callback: AsyncInferQueueCallback): void; | ||
| /** | ||
| * It starts asynchronous inference for the specified input data. | ||
| * @param inputData An object with the key-value pairs where the key is the | ||
| * input name and value is a tensor or an array with tensors. | ||
| * @param userData User data that will be passed to the callback. | ||
| * @returns A Promise that can be used to track the callback completion. | ||
| */ | ||
| startAsync(inputData: { | ||
| [inputName: string]: Tensor; | ||
| } | Tensor[], userData?: object): Promise<object>; | ||
| /** | ||
| * Releases resources associated with this AsyncInferQueue instance. | ||
| * Call this method after all `startAsync` requests have completed | ||
| * and the AsyncInferQueue is no longer needed. | ||
| */ | ||
| release(): void; | ||
| } | ||
@@ -613,8 +669,13 @@ declare enum element { | ||
| export interface NodeAddon { | ||
| Core: CoreConstructor; | ||
| Tensor: TensorConstructor; | ||
| PartialShape: PartialShapeConstructor; | ||
| Core: Core; | ||
| Model: Model; | ||
| CompiledModel: CompiledModel; | ||
| Tensor: Tensor; | ||
| InferRequest: InferRequest; | ||
| Output: Output; | ||
| PartialShape: PartialShape; | ||
| AsyncInferQueue: AsyncInferQueue; | ||
| preprocess: { | ||
| resizeAlgorithm: typeof resizeAlgorithm; | ||
| PrePostProcessor: PrePostProcessorConstructor; | ||
| PrePostProcessor: PrePostProcessor; | ||
| }; | ||
@@ -636,4 +697,5 @@ /** | ||
| element: typeof element; | ||
| resizeAlgorithm: typeof resizeAlgorithm; | ||
| } | ||
| declare const _default: NodeAddon; | ||
| export default _default; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import addon from './addon'; | ||
| import addon from "./addon"; | ||
| export { addon }; |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
47157
10.79%14
16.67%1033
11.8%77
11.59%11
57.14%