summaryrefslogtreecommitdiffstats
path: root/model-integration
diff options
context:
space:
mode:
authorLester Solbakken <lesters@oath.com>2022-06-07 15:35:19 +0200
committergjoranv <gv@verizonmedia.com>2022-06-08 11:45:31 +0200
commit8a01b3e2106739aaaf4ad918edbed04244360eb2 (patch)
treef7ea0d3cbb2417d619824d7e9b16d1e69c911e53 /model-integration
parent438f313637fef3293661b9655636dc0a4b3d63d0 (diff)
Remove TensorFlow feature converter
Diffstat (limited to 'model-integration')
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java42
1 files changed, 1 insertions, 41 deletions
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java
index 5316416c4dc..bd9410eecee 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java
@@ -51,47 +51,7 @@ public class TensorFlowImporter extends ModelImporter {
*/
@Override
public ImportedModel importModel(String modelName, String modelDir) {
- return convertToOnnxAndImport(modelName, modelDir);
- }
-
- private ImportedModel convertToOnnxAndImport(String modelName, String modelDir) {
- Path tempDir = null;
- try {
- tempDir = Files.createTempDirectory("tf2onnx");
- String convertedPath = tempDir.toString() + File.separatorChar + "converted.onnx";
- String outputOfLastConversionAttempt = "";
- for (int opset : onnxOpsetsToTry) {
- log.info("Converting TensorFlow model '" + modelDir + "' to ONNX with opset " + opset + "...");
- Pair<Integer, String> res = convertToOnnx(modelDir, convertedPath, opset);
- if (res.getFirst() == 0) {
- log.info("Conversion to ONNX with opset " + opset + " successful.");
-
- /*
- * For now we have to import tensorflow models as native Vespa expressions.
- * The temporary ONNX file that is created by conversion needs to be put
- * in the application package so it can be file distributed.
- */
- return onnxImporter.importModelAsNative(modelName, convertedPath, ImportedMlModel.ModelType.TENSORFLOW);
- }
- log.fine("Conversion to ONNX with opset " + opset + " failed. Reason: " + res.getSecond());
- outputOfLastConversionAttempt = res.getSecond();
- }
- throw new IllegalArgumentException("Unable to convert TensorFlow model in '" + modelDir + "' to ONNX: " +
- outputOfLastConversionAttempt);
- } catch (IOException e) {
- throw new IllegalArgumentException("Conversion from TensorFlow to ONNX failed for '" + modelDir + "'");
- } finally {
- if (tempDir != null) {
- IOUtils.recursiveDeleteDir(tempDir.toFile());
- }
- }
- }
-
- private Pair<Integer, String> convertToOnnx(String savedModel, String output, int opset) throws IOException {
- ProcessExecuter executer = new ProcessExecuter();
- String job = "vespa-convert-tf2onnx --saved-model " + savedModel + " --output " + output + " --opset " + opset
- + " --use-graph-names"; // for backward compatibility with tf2onnx versions < 1.9.1
- return executer.exec(job);
+ throw new IllegalArgumentException("Import of TensorFlow models is no longer supported");
}
}