Skip to content

Commit f5f3e5b

Browse files
committed
chore(v2.1.0): publish core@2.1.0 webgl@1.1.0 and update models version
1 parent 2708d91 commit f5f3e5b

File tree

28 files changed

+298
-23588
lines changed

28 files changed

+298
-23588
lines changed

packages/paddlejs-backend-webgl/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/paddlejs-backend-webgl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paddlejs/paddlejs-backend-webgl",
3-
"version": "1.0.7",
3+
"version": "1.1.0",
44
"description": "",
55
"main": "lib/index",
66
"scripts": {

packages/paddlejs-core/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@ As the core part of the Paddle.js ecosystem, this package hosts `@paddlejs/paddl
55
which is responsible for the operation of the inference process of the entire engine,
66
and provides interfaces for backend registration and environment variable registration.
77

8+
9+
## RunnerConfig
10+
11+
When registering the engine you need to configure the engine, you must configure the items `modelPath`, `feedShape`, all items are configured as follows.
12+
13+
```typescript
14+
15+
// model struture
16+
enum GraphType {
17+
SingleOutput = 'single',
18+
MultipleOutput = 'multiple',
19+
MultipleInput = 'multipleInput'
20+
}
21+
22+
interface RunnerConfig {
23+
modelPath: string; // model path (local or web address)
24+
modelName?: string; // model name
25+
feedShape: { // input feed shape
26+
fc?: number; // feed channel, default is 3.
27+
fw: number; // feed width
28+
fh: number; // feed height
29+
};
30+
fill?: Color; // the color used to padding
31+
mean?: number[]; // mean value
32+
std?: number[]; // standard deviation
33+
bgr?: boolean; // whether the image channel alignment is BGR, default is false (RGB)
34+
type?: GraphType; // model structure, default is singleInput and singleOutput
35+
needPreheat?: boolean; // whether to warm up the engine during initialization, default is true
36+
plugins?: { // register model topology transform plugin
37+
preTransforms?: Transformer[]; // transform before creating network topology
38+
transforms?: Transformer[]; // transform when traversing model layers
39+
postTransforms?: Transformer[]; // transform the model topology diagram after it has been created
40+
};
41+
}
42+
43+
```
844
## Importing
945
You can install this package via npm., `@paddlejs/paddlejs-core`
1046

@@ -32,3 +68,56 @@ const res = await runner.predict(mediadata, callback?);
3268
**Note**: If you are importing the Core package, you also need to import a backend (e.g.,
3369
[paddlejs-backend-webgl](/packages/paddlejs-backend-webgl), [paddlejs-backend-webgpu](/packages/paddlejs-backend-webgpu)).
3470
71+
72+
## High-level use
73+
74+
1. `@paddlejs/paddlejs-core` provides the interface `registerOp`, through which developers can register custom operators.
75+
76+
2. `@paddlejs/paddlejs-core` provides the global variable `env` module, through which developers can register environment variables, using the following method:
77+
78+
```js
79+
// set env key/flag and value
80+
env.set(key, value);
81+
82+
// get value by key/flag
83+
env.get(key);
84+
```
85+
86+
3. transform model stucture
87+
88+
By registering the model transformers through `runnerConfig.plugins`, developers can make changes (add, delete, change) to the model structure, such as pruning to remove unnecessary layers to speed up inference, or adding custom layers to the end of the model and turning post-processing into layers in the model to speed up post-processing.
89+
90+
91+
4. Turn on performance flag for acceleration
92+
93+
Paddle.js currently provides five performance `flags`, which can be set to `true` if you want to enable inference acceleration.
94+
95+
96+
```js
97+
env.set('webgl_pack_channel', true);
98+
```
99+
Turn on `webgl_pack_channel` and the eligible conv2d will use packing shader to perform packing transformations to improve performance through vectorization calculations.
100+
101+
102+
```js
103+
env.set('webgl_force_half_float_texture', true);
104+
```
105+
Enable `webgl_force_half_float_texture`, feature map uses half float `HALF_FLOAT`.
106+
107+
108+
```js
109+
env.set('webgl_feed_process', true);
110+
```
111+
Turn on `webgl_feed_process` to convert all pre-processing parts of the model to shader processing, and keep the original image texture.
112+
113+
114+
```js
115+
env.set('webgl_gpu_pipeline', true);
116+
```
117+
Turn on `webgl_gpu_pipeline` to convert all model pre-processing parts to shader processing, and render the model results to `WebGL2RenderingContext` of webgl backend on screen. Developers can perform model post-processing on the output texture and the original image texture to achieve the `GPU_PIPELINE`: pre-processing + inference + post-processing (rendering processing) to get high performance. Take humanseg model case for reference.
118+
119+
120+
```js
121+
env.set('webgl_pack_output', true);
122+
```
123+
Enable `webgl_pack_output` to migrate the `NHWC` to `NCHW` layout transformation of the model output to the GPU, and `pack` to a four-channel layout to reduce loop processing when reading the results from the GPU

packages/paddlejs-core/README_cn.md

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,43 @@
44

55
是 Paddle.js 推理引擎的核心部分,npm 包名是 `@paddlejs/paddlejs-core`,负责整个引擎的推理流程运行,提供计算方案注册、环境变量注册的接口。
66

7-
## 安装
7+
8+
## 引擎配置 RunnerConfig
9+
注册引擎时需要对引擎进行配置,必须配置项为 `modelPath``feedShape`,所有项目配置如下:
10+
11+
```typescript
12+
13+
// 模型网络图结构
14+
enum GraphType {
15+
SingleOutput = 'single', // 单输出
16+
MultipleOutput = 'multiple', // 多输出
17+
MultipleInput = 'multipleInput' // 多输入
18+
}
19+
20+
interface RunnerConfig {
21+
modelPath: string; // 模型路径(本地路径或者网络地址)
22+
modelName?: string; // 模型名称
23+
feedShape: { // 模型输入 feed shape
24+
fc?: number; // 通道,默认为 3
25+
fw: number; //
26+
fh: number; //
27+
};
28+
fill?: string; // 缩放后用什么颜色填充不足方形部分
29+
mean?: number[]; // 平均值
30+
std?: number[]; // 标准差
31+
bgr?: boolean; // 图片通道排列是否是 BGR,默认为 false,为主流 RGB
32+
type?: GraphType; // 模型网络图结构,默认单输入单输出
33+
needPreheat?: boolean; // 是否在引擎初始化时进行预热,默认为 true
34+
plugins?: { // 注册模型拓扑结构转换插件
35+
preTransforms?: Transformer[]; // 在创建网络拓扑前进行转换
36+
transforms?: Transformer[]; // 在遍历模型层时进行转换
37+
postTransforms?: Transformer[]; // 创建网络拓扑图完成后进行转换
38+
};
39+
}
40+
41+
```
42+
43+
## 安装和使用
844
使用 npm 安装,`@paddlejs/paddlejs-core`
945

1046
```js
@@ -30,3 +66,59 @@ const res = await runner.predict(mediadata, callback?);
3066
3167
**Note**: 如果你引入 paddlejs-core,你仍需引入一个计算方案。(目前我们提供两种方案, webgpu 目前还是实验阶段,需要使用 chrome canary 访问,
3268
[paddlejs-backend-webgl](/packages/paddlejs-backend-webgl), [paddlejs-backend-webgpu](/packages/paddlejs-backend-webgpu)).
69+
70+
71+
72+
## 高阶使用
73+
74+
1. `@paddlejs/paddlejs-core` 提供接口 `registerOp`,开发者可以通过该接口,完成自定义算子注册。
75+
76+
2. `@paddlejs/paddlejs-core` 提供全局变量 `env` 模块,开发者可以通过该模块完成环境变量注册,使用方法如下:
77+
78+
```js
79+
// set env key/flag and value
80+
env.set(key, value);
81+
82+
// get value by key/flag
83+
env.get(key);
84+
```
85+
86+
3. 改变模型结构
87+
88+
通过 `runnerConfig.plugins` 注册模型转换器,开发者可以对模型结构进行改变(增、删、改),比如通过剪枝去除不必要的模型层来加快推理,也可以将自定义层加入模型最后,将后处理变为模型中的层来加速后处理。
89+
90+
91+
4. 开启性能 flag 实现加速
92+
93+
目前 Paddle.js 提供五个性能相关 `flag`,如需开启推理加速,可以将相关 `flag``true`
94+
95+
96+
#### 开启 `webgl_pack_channel`,合适的 conv2d 会使用 packing shader 进行排布变换,通过向量化计算来提高性能。
97+
98+
```js
99+
env.set('webgl_pack_channel', true);
100+
```
101+
102+
#### 开启 `webgl_force_half_float_texture`,feature map 使用半浮点 `HALF_FLOAT`
103+
104+
```js
105+
env.set('webgl_force_half_float_texture', true);
106+
```
107+
108+
#### 开启 `webgl_feed_process`,将模型前处理部分全部转换为 shader GPU 处理,并保留原始图片 texture
109+
110+
```js
111+
env.set('webgl_feed_process', true);
112+
```
113+
114+
#### 开启 `webgl_gpu_pipeline`,将模型前处理部分全部转换为 shader GPU 处理,且将模型推理结果上屏渲染到 webgl backend 的 `WebGL2RenderingContext` 上。开发者可对输出结果 texture 和原始图片 texture 进行模型后处理,来实现 GPU 全流程:前处理+推理+后处理(渲染处理),获得高性能,可参考 humanseg model 案例。
115+
116+
```js
117+
env.set('webgl_gpu_pipeline', true);
118+
```
119+
120+
#### 开启 `webgl_pack_output`,将模型输出结果 `NHWC``NCHW` 排布变换迁移至 GPU 进行,并 `pack` 为四通道排布,从 GPU 读取结果时,可以减少循环处理
121+
122+
```js
123+
env.set('webgl_pack_output', true);
124+
```

packages/paddlejs-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paddlejs/paddlejs-core",
3-
"version": "2.0.7",
3+
"version": "2.1.0",
44
"description": "",
55
"main": "lib/index",
66
"scripts": {

packages/paddlejs-examples/humanStream/package-lock.json

Lines changed: 11 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/paddlejs-examples/humanStream/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"@paddlejs-mediapipe/camera": "0.0.2",
15-
"@paddlejs-models/humanseg": "^1.0.2"
15+
"@paddlejs-models/humanseg": "^1.1.0"
1616
},
1717
"devDependencies": {
1818
"@types/webrtc": "0.0.26",

packages/paddlejs-examples/mobilenet/package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/paddlejs-examples/mobilenet/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15-
"@paddlejs-models/mobilenet": "0.0.5"
15+
"@paddlejs-models/mobilenet": "^1.0.1"
1616
},
1717
"devDependencies": {
1818
"html-webpack-plugin": "^3.2.0",

packages/paddlejs-examples/ocrdetection/package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)