Files
ai-box/README.md
2025-03-10 18:12:32 +08:00

48 lines
980 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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命令行