Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/handong0123/tensorflow_deploy
简化与优化tensorflow模型的Java部署
https://github.com/handong0123/tensorflow_deploy
java tensorflow
Last synced: about 1 month ago
JSON representation
简化与优化tensorflow模型的Java部署
- Host: GitHub
- URL: https://github.com/handong0123/tensorflow_deploy
- Owner: handong0123
- License: apache-2.0
- Created: 2019-10-15T12:07:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T06:30:08.000Z (almost 5 years ago)
- Last Synced: 2024-11-16T03:39:39.821Z (2 months ago)
- Topics: java, tensorflow
- Language: Java
- Homepage:
- Size: 53.7 KB
- Stars: 47
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# tensorflow_deploy
#### 简介简化与优化tensorflow模型的Java部署,并提供特征抽取相关工具
#### 注
tensorflow1.14官方jar存在bug,请参照 https://blog.csdn.net/handong01027/article/details/101371739 进行修改#### 特性
1. 多线程预测,提高预测性能50%
2. 提供模型重载,防止模型卡死
3. 封装模型输入输出,使用更加简便,可读性好
4. 提供数据预处理,加载char-encoder,获取文本id等特征抽取常用功能
##### Quick Start
引入依赖:
```java
// CPU
com.github.handong0123
tensorflow-deploy-cpu
1.14.0
// GPU
com.github.handong0123
tensorflow-deploy-gpu
1.14.0
```构造:
```java
// 使用CPU 更多构造参数请看源码
TensorflowProvider tfp = new TensorflowProvider("frozen.pb","/home/demo");
// 使用GPU
TensorflowProvider tfp = new TensorflowProvider(3,"frozen.pb","/home/demo","0,1,2");
```使用:
```java
// 构造模型输入
ModelInput input = new ModelInput();
// 输出的tensor名和数据类型
input.addExceptedOutput("project/Reshape:0",ModelDataType.FLOAT);
// 输入的tensor名和数据数组(未装箱)
input.addPlaceHolderInput("CharInputs:0",new float[][]{});
// 预测
ModelOutput output = tfp.predict(input);
float[][][] scores = (float[][][]) output.getOutput("project/Reshape:0");
```数据处理工具:
```
// 提供大小写转换、全角转半角、加载char-id映射、获取char特征、填充列表等方法
TensorflowDataService dataService = new TensorflowDataServiceImpl();```
#### 如果你有好的想法或建议,可以提issue,也可以联系[email protected],项目会一直维护更新,感谢你的star。