代码优化
This commit is contained in:
51
README.md
51
README.md
@ -1,14 +1,47 @@
|
||||
## AI工具箱
|
||||
#AI工具箱
|
||||
|
||||
|
||||
### 代码编译
|
||||
|
||||
注意:在Windows下编译时,需要打开Visual Studio命令行
|
||||
## 安装
|
||||
|
||||
```
|
||||
# 编译第三方库
|
||||
node thirdpart/install.js --with-onnx --with-mnn --with-opencv
|
||||
# 编译主库
|
||||
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命令行
|
||||
|
Reference in New Issue
Block a user