diff --git a/.github/workflows/android_ci.yml b/.github/workflows/android_ci.yml index 82ee767..c82d161 100644 --- a/.github/workflows/android_ci.yml +++ b/.github/workflows/android_ci.yml @@ -5,7 +5,8 @@ on: branches: - master paths: - - 'Android/*' + - 'Android/**' + - '!Android/version.gradle' schedule: - cron: "0 2 * * 1-5" diff --git a/.github/workflows/generate_changelog.yml b/.github/workflows/generate_changelog.yml index 37008eb..0f906f8 100644 --- a/.github/workflows/generate_changelog.yml +++ b/.github/workflows/generate_changelog.yml @@ -1,8 +1,11 @@ name: Generate changelog on: - release: - types: [published] + push: + branches: + - master + paths: + - 'Android/version.gradle' jobs: generate_changelog: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4dd9c1b..ce311cf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,11 @@ name: publish aoe on: - release: - types: [published] + push: + branches: + - master + paths: + - 'Android/version.gradle' env: GPR_USER: ${{ secrets.GPR_USER }} GPR_API_KEY: ${{ secrets.GPR_API_KEY }} diff --git a/Android/Advanced.md b/Android/Advanced.md deleted file mode 100644 index 5e64587..0000000 --- a/Android/Advanced.md +++ /dev/null @@ -1,2 +0,0 @@ -# 高级定制 - diff --git a/Android/Component.md b/Android/Component.md deleted file mode 100644 index e69de29..0000000 diff --git a/Android/Concept.md b/Android/Concept.md deleted file mode 100644 index b42b146..0000000 --- a/Android/Concept.md +++ /dev/null @@ -1,98 +0,0 @@ - - -# 核心概念 -## AoeClient -AoeClient 是 AoE 推理操作的唯一交互窗口,您需要在自己业务实现中创建并使用。 - -``` - -/** - * @param context 全局上下文 - * @param clientId 区分业务实现的ID(自定义) - * @param options Client配置,用来指定组件实例和运行模式 - * @param mainModelDir 主模型配置目录 - * @param subsequentModelDirs 子模型配置目录(用于多模型融合场景) - */ -public AoeClient(@NonNull Context context, - @NonNull String clientId, - @NonNull Options options, - @NonNull String mainModelDir, - @Nullable String... subsequentModelDirs) - -``` - -### 初始化 init -调用 `init()` 方法进行组件和模型初始化 -``` -/** - * 初始化、加载模型文件 - * - */ -@StatusCode -public int init() -``` -初始化状态码定义如下: -``` -public @interface StatusCode { - int UNDEFINE = 0; - /** - * 模型描述文件读取错误 - */ - int CONFIG_PARSE_ERROR = 1; - /** - * 模型描述文件解析正常,准备加载模型 - */ - int MODEL_LOAD_READY = 2; - /** - * 模型文件加载错误 - */ - int MODEL_LOAD_ERROR = 3; - /** - * 模型加载完成 - */ - int MODEL_LOAD_OK = 4; - -} -``` -### 释放资源 release -调用 `release()` 释放模型加载资源。 - -### 判断推理服务是否为可用状态 isRunning -当模型描述文件、组件和模型都加载完成,可进行推理操作时,调用 `isRunning()` 返回 true 。 - -### 执行推理 process -在推理服务为可用时,执行 `process()` ,喂入输入数据,数据将由自定义[InterpreterComponent](#InterpreterComponent)实现执行处理。 -``` -@WorkerThread -@Nullable -public Object process(Object input) -``` - -## AoeModelOption -模型配置的标准化接口,AoE Android SDK 标准模型配置规范是在模型目录下定义模型描述文件,说明模型加载方式和路径: -``` -assets/{feature_name}/model.config -``` -默认是以 Json 格式定义 AoeModelOption 所需的字段内容。 - -允许自定义模型定义文件格式,只需拓展 *AoeModelOption* 接口定义,并配套实现注册[ModelOptionLoaderComponent](#ModelOptionLoaderComponent),自行解析模型描述文件。具体用法可参见 [Demo](./samples/demo/extensions/squeeze-model-option-loader) -``` -public interface AoeModelOption extends Serializable { - - String getModelDir(); - - String getModelName(); - - boolean isValid(); -} -``` - - -## InterpreterComponent -推理框架执行包装组件接口,负责完成模型文件的加载,推理操作执行,数据预处理、后处理转换,为推理操作的直接实现。必需实现该接口,并显式注入到AoeClient。 - -## ParcelComponent -对象序列化组件接口,默认使用 `对象序列化机制(object serialization)`,是 Java 语言内建的一种对象持久化方式。该方式比较通用但需要输入数据实现 `Serializable` 接口,且序列化效率比较低,推荐使用 [Kryo](./aoe/extensions/parcel-kryo) 拓展组件实现,大概增加 200k 包大小,但是不要求实现 Serializable 接口,且实测处理耗时约为原生对象序列化的 1/7。 - -## ModelOptionLoaderComponent -对应 [AoeModelOption](#AoeModelOption) 实现的加载器组件接口,用于拓展数据模型加载协议。 diff --git a/Android/ReleaseNotes.md b/Android/ReleaseNotes.md deleted file mode 100644 index f8b3db1..0000000 --- a/Android/ReleaseNotes.md +++ /dev/null @@ -1,4 +0,0 @@ -# Release notes # - -### 1.0.0 ### - diff --git a/Android/aoe/api/README.md b/Android/aoe/api/README.md index 20053ec..3046d80 100644 --- a/Android/aoe/api/README.md +++ b/Android/aoe/api/README.md @@ -1,38 +1,83 @@ -# AoE API # +# AoE API | [ ![library-api](https://api.bintray.com/packages/aoe/maven/library-api/images/download.svg) ](https://bintray.com/aoe/maven/library-api/_latestVersion) -此目录包含了AoE API定义,业务可根据组件接口定义拓展功能实现进行注册。 +AoE 核心 API -> 参考文档 [概念介绍](./../../../Concept.md) +## 使用 -## AoeModelOption +``` lang=gradle +implementation "com.didi.aoe:library-api:$aoe_version_name" +``` -模型配置接口,用户需自定义一个模型描述文件,解析器提取出模型文件信息,用于配套 -Interpreter 加载解析模型文件。框架提供通用流程实现,可根据业务情况进行方便拓展。 +## 核心概念 +## AoeModelOption -标准模型配置规范是在模型目录下定义模型描述文件: +模型配置接口,AoE 标准模型配置规范是在模型目录下定义模型描述文件: ``` assets/{feature_name}/model.config ``` -默认是以 Json 格式定义 AoeModelOption 所需的字段内容。 +以 **Json** 格式定义 AoeModelOption 所需的字段内容。 -允许自定义模型定义文件格式,只需拓展 *AoeModelOption* 接口定义,并配套实现注册 +> 可以自定义模型定义文件格式,只需拓展 *AoeModelOption* 接口定义,并配套实现注册 [ModelOptionLoaderComponent](#ModelOptionLoaderComponent),自行解析模型描述 文件。 ``` public interface AoeModelOption extends Serializable { + /** + * 模型文件文件夹路径 + * + * @return 文件夹路径 + */ + @NonNull String getModelDir(); + /** + * 模型文件名 + * + * @return 模型文件名,不含路径 + */ + @NonNull String getModelName(); + @Nullable + String getVersion(); + + @NonNull + @ModelSource + String getModelSource(); + + /** + * 模型配置验证 + * + * @return true,解析字段符合配置字段基本要求 + */ boolean isValid(); } ``` +## InterpreterComponent +推理引擎翻译组件,提供对模型文件的加载、推理动作执行,AoE 对应不同的推理引擎提供对应的封装实现,需由用户集成抽象类,实现数据预处理、后处理。 -> Tips: 示例项目 [Sequeeze](./../../../samples/demo/features/sequeeze) +## Convertor +通过对应推理框架的 InterpreterComponent 抽象子类透传下来需要的接口定义,由用户自行实现输入数据到模型输入数据格式的转换,以及模型结果的处理逻辑。 -## AoeProcessor +``` lang=kotlin +interface Convertor { + /** + * 数据预处理,将输入数据转换成模型输入数据 + * + * @param input 业务输入数据 + * @return 模型输入数据 + */ + fun preProcess(input: TInput): TModelInput? -框架提供的核心控制接口,包括各组件接口定义。 \ No newline at end of file + /** + * 数据后处理,将模型输出数据转换成业务输出数据 + * + * @param modelOutput 模型输出数据 + * @return 业务输出数据 + */ + fun postProcess(modelOutput: TModelOutput?): TOutput? +} +``` diff --git a/Android/aoe/core/README.md b/Android/aoe/core/README.md deleted file mode 100644 index 969c9ce..0000000 --- a/Android/aoe/core/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# AoE Core # - -此模组实现了 AoE 核心框架流程。 \ No newline at end of file diff --git a/Android/aoe/logging/README.md b/Android/aoe/logging/README.md deleted file mode 100644 index 47f5d3a..0000000 --- a/Android/aoe/logging/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# AoE logging 组件 # - -此模组实现了 AoE 默认的日志实现,用户可实现Logger接口后调用LoggerFactory静态方法进行注入构造器,进行托管。 - -``` -LoggerFactory.setLoggerBinder(@Nullable LoggerBinder binder) -``` - diff --git a/Android/examples/demo/README.md b/Android/examples/demo/README.md deleted file mode 100644 index fc4db4d..0000000 --- a/Android/examples/demo/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# AoE Demo # - -此目录包含了 AoE 集成使用演示Demo,包含了两个功能: - -* 基于 [TensorFLow Lite](https://www.tensorflow.org/lite/) 框架的 MNIST - 手写数字识别功能; - -![](../../../../images/mnist_android.jpeg) - -* 基于 [NCNN](https://github.com/Tencent/ncnn) 框架的 SqueezeNet 物体识别功能。 - -![](../../../../images/squeeze_android.jpeg) \ No newline at end of file diff --git a/Android/global_config.gradle b/Android/global_config.gradle index f204a9d..1a0b626 100644 --- a/Android/global_config.gradle +++ b/Android/global_config.gradle @@ -14,6 +14,8 @@ * limitations under the License. */ +apply from: 'version.gradle' + /** * 工程全局变量定义 */ @@ -22,8 +24,7 @@ ext { aoe_min_sdk_version = 15 aoe_target_sdk_version = 26 - aoe_version_code = 2 - aoe_version_name = '1.1.1.6' + aoe_version_code = 3 kotlin_version = '1.3.61' @@ -98,6 +99,9 @@ def addRepos(RepositoryHandler handler) { handler.jcenter() handler.google() + handler.maven { + url 'https://dl.bintray.com/aoe/maven' + } handler.maven { url 'https://maven.pkg.github.com/didi/aoe' credentials { @@ -105,9 +109,6 @@ def addRepos(RepositoryHandler handler) { password = properties.getProperty("gpr.key") ?: System.getenv("GPR_API_KEY") } } - handler.maven { - url 'https://dl.bintray.com/aoe/maven' - } } ext.addRepos = this.&addRepos diff --git a/Android/publish.sh b/Android/publish.sh index e5a1792..169ace6 100644 --- a/Android/publish.sh +++ b/Android/publish.sh @@ -41,16 +41,16 @@ do ./gradlew :runtime-${name}:${task} done -# -------------- publish extensions -extensions=(pytorch) - -echo extensions: ${extensions} - -for name in ${extensions} -do - echo :extensions-${name}:${task} - ./gradlew :extensions-${name}:${task} -done +## -------------- publish extensions +#extensions=(pytorch) +# +#echo extensions: ${extensions} +# +#for name in ${extensions} +#do +# echo :extensions-${name}:${task} +# ./gradlew :extensions-${name}:${task} +#done echo aoe published echo done. diff --git a/Android/version.gradle b/Android/version.gradle new file mode 100644 index 0000000..214cf72 --- /dev/null +++ b/Android/version.gradle @@ -0,0 +1,20 @@ +/* + * Copyright 2019 The AoE Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +ext { + aoe_version_name = '1.1.1.7' +} \ No newline at end of file