Skip to content

jiangnanboy/java_textcnn_onnx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java_textcnn_onnx

java is used to load the onnx format model of textcnn

step

1.after training the textcnn model, convert it to onnx format (src/main/resource/model.onnx)

2.extract token mapping dict (src/main/resources/token.txt)

3.use java to load onnx format model and token dict (src/main/java/Init)

4.inference and prediction (src/main/java/Inference)

example

(text binary classification)

predict:src/main/java/Inference

public static void main(String...args) throws OrtException {
        Map<String, OnnxTensor> inputMap = parse("我们热爱人工智能。");
        System.out.println(Init.session.getInputInfo());
        System.out.println(Init.session.getOutputInfo());
        double prob = infer(inputMap);
        System.out.println("prob -> " + prob);
    }

contact

1、github:https://github.com/jiangnanboy

2、blog:https://www.cnblogs.com/little-horse/

3、e-mail:[email protected]

About

java is used to load the onnx format model of textcnn

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages