'tensorflow 2.0 Estimator model using scala/java predict?

I can use python3 tf2.x to predict, but how can i use java to predict?

I tried so many times i found the question maybe is the version of Example.proto, but i'm not sure.. the java code i wrote like this:

 val concreteFunction = bundle.function("serving_default")
 val model = sparkEnv.sc.broadcast(concreteFunction)
 val result = sparkEnv.spark.read.parquet(inputPath).map(item => {
      val example = convert2Example(schemaInfo,item)
      val map = new java.util.HashMap[String,Tensor]()
      val b = new String(example.toByteArray)
      val tensor = TString.scalarOf(b)
      map.put("examples",tensor)
      val score = model.value.call(map).get("score")
      score.toString
 }).rdd


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source