https://github.com/hypersolution1/libtf
This library performs non-blocking inference on tensorflow frozen model. Based on the Tensorflow C API.
https://github.com/hypersolution1/libtf
nodejs npm-package tensorflow
Last synced: about 2 months ago
JSON representation
This library performs non-blocking inference on tensorflow frozen model. Based on the Tensorflow C API.
- Host: GitHub
- URL: https://github.com/hypersolution1/libtf
- Owner: hypersolution1
- Created: 2019-09-09T14:38:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-20T19:55:18.000Z (almost 7 years ago)
- Last Synced: 2025-02-26T08:29:26.151Z (over 1 year ago)
- Topics: nodejs, npm-package, tensorflow
- Language: C++
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libtf
This library performs non-blocking inference on tensorflow frozen model. Based on the Tensorflow C API.
## Dependency
Install libtensorflow from https://www.tensorflow.org/install/lang_c
## Install
```bash
npm i libtf
```
## Usage
```js
var TFModel = require('libtf')
var model = TFModel() // To be called for each desired Tensorflow Session
// With options:
// var model = TFModel({
// 'allow_growth': false, // If true, overrides gpu_memory_fraction
// 'gpu_memory_fraction': 1.0,
// })
;(async () => {
await model.load('./model.pb') // Session is created and model loaded
var input = {
"isTrainingflag": false, // Boolean
"dropout_keep_prob": { // Scalar
"dim": [1],
"data": new Float32Array([1]),
},
"inputs/enc_in": { // Tensor, data must be of type Float32Array or UInt8Array
"dim": [1,32],
"data": new Float32Array(1*32),
},
}
var result = await model.execute(input, ["dense_1/Softmax"]) // arg1 is input, arg2 is an array of output names
console.log(result)
// Output:
// { 'dense_1/Softmax': // Output name
// { dim: [ 1, 62 ],
// data:
// Float32Array [ ... ]
// }
// }
})()
.catch(function (err) {
console.log(err)
})
```