48 lines
980 B
Markdown
48 lines
980 B
Markdown
#AI工具箱
|
||
|
||
## 安装
|
||
|
||
```
|
||
npm install @yizhi/ai
|
||
```
|
||
|
||
## 使用
|
||
|
||
```typescript
|
||
import ai from "@yizhi/ai";
|
||
|
||
// 配置相应的node插件,插件需自行编译
|
||
ai.config("CV_ADDON_FILE", "/path/to/cv.node");
|
||
ai.config("MNN_ADDON_FILE", "/path/to/mnn.node");
|
||
ai.config("ORT_ADDON_FILE", "/path/to/onnxruntime.node");
|
||
|
||
//直接推理
|
||
const facedet = await ai.deploy.facedet.Yolov5Face.load("YOLOV5S_ONNX");
|
||
const boxes = await facedet.predict("/path/to/image");
|
||
|
||
//使用自己的模型
|
||
const session = new ai.backend.ort.Session(modelBuffer);
|
||
const outputs = session.run(inputs);
|
||
|
||
```
|
||
|
||
## 插件编译
|
||
|
||
1. 依赖
|
||
1. python3
|
||
1. cmake
|
||
1. ninja
|
||
1. c++编译器(gcc,clang,Visual Studio ...)
|
||
|
||
1. 编译第三方库
|
||
```
|
||
node thirdpart/install.js --with-mnn --with-onnx --with-opencv
|
||
```
|
||
1. 编译插件
|
||
```
|
||
cmake -B build -G Ninja . -DCMAKE_BUILD_TYPE=Release
|
||
cmake --build build --config Release
|
||
```
|
||
|
||
注意:注意:在Windows下编译时,需要打开Visual Studio命令行
|