tensorflow_deploy

tensorflow deploy for java

License

License

Categories

Categories

TensorFlow Business Logic Libraries Machine Learning
GroupId

GroupId

com.github.handong0123
ArtifactId

ArtifactId

tensorflow_deploy_cpu
Last Version

Last Version

1.14.0
Release Date

Release Date

Type

Type

jar
Description

Description

tensorflow_deploy
tensorflow deploy for java
Project URL

Project URL

https://github.com/handong0123/tensorflow_deploy
Source Code Management

Source Code Management

https://github.com/handong0123/tensorflow_deploy

Download tensorflow_deploy_cpu

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.handong0123/tensorflow_deploy_cpu/ -->
<dependency>
    <groupId>com.github.handong0123</groupId>
    <artifactId>tensorflow_deploy_cpu</artifactId>
    <version>1.14.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.handong0123/tensorflow_deploy_cpu/
implementation 'com.github.handong0123:tensorflow_deploy_cpu:1.14.0'
// https://jarcasting.com/artifacts/com.github.handong0123/tensorflow_deploy_cpu/
implementation ("com.github.handong0123:tensorflow_deploy_cpu:1.14.0")
'com.github.handong0123:tensorflow_deploy_cpu:jar:1.14.0'
<dependency org="com.github.handong0123" name="tensorflow_deploy_cpu" rev="1.14.0">
  <artifact name="tensorflow_deploy_cpu" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.handong0123', module='tensorflow_deploy_cpu', version='1.14.0')
)
libraryDependencies += "com.github.handong0123" % "tensorflow_deploy_cpu" % "1.14.0"
[com.github.handong0123/tensorflow_deploy_cpu "1.14.0"]

Dependencies

compile (10)

Group / Artifact Type Version
org.tensorflow : tensorflow jar 1.14.0
org.tensorflow : libtensorflow_jni jar 1.14.0
org.tensorflow : libtensorflow jar 1.14.0
org.tensorflow : proto jar 1.14.0
com.google.protobuf : protobuf-java jar 3.6.1
org.slf4j : slf4j-api jar 1.7.25
org.springframework.boot : spring-boot jar 1.4.0.RELEASE
com.google.guava : guava jar 27.0.1-jre
com.alibaba : fastjson jar 1.2.62
org.apache.commons : commons-lang3 jar 3.7

Project Modules

There are no modules declared in this project.

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

引入依赖:

  // CPU
  <dependency>
  <groupId>com.github.handong0123</groupId>
  <artifactId>tensorflow-deploy-cpu</artifactId>
  <version>1.14.0</version>
  </dependency>
  // GPU    
  <dependency>
  <groupId>com.github.handong0123</groupId>
  <artifactId>tensorflow-deploy-gpu</artifactId>
  <version>1.14.0</version>
  </dependency>

构造:

// 使用CPU 更多构造参数请看源码
TensorflowProvider tfp = new TensorflowProvider("frozen.pb","/home/demo");
    
// 使用GPU
TensorflowProvider tfp = new TensorflowProvider(3,"frozen.pb","/home/demo","0,1,2");

使用:

// 构造模型输入
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。

Versions

Version
1.14.0