diff --git a/tika-parsers/tika-parsers-ml/tika-dl/src/main/java/org/apache/tika/dl/imagerec/DL4JVGG16Net.java b/tika-parsers/tika-parsers-ml/tika-dl/src/main/java/org/apache/tika/dl/imagerec/DL4JVGG16Net.java index a6f6ca81a8..327dbb17ed 100644 --- a/tika-parsers/tika-parsers-ml/tika-dl/src/main/java/org/apache/tika/dl/imagerec/DL4JVGG16Net.java +++ b/tika-parsers/tika-parsers-ml/tika-dl/src/main/java/org/apache/tika/dl/imagerec/DL4JVGG16Net.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Set; +import org.apache.commons.io.FileUtils; import org.datavec.image.loader.NativeImageLoader; import org.deeplearning4j.nn.graph.ComputationGraph; import org.deeplearning4j.util.ModelSerializer; @@ -98,6 +99,10 @@ public void initialize(Map params) throws TikaConfigException { try { if (serialize) { if (cacheDir.exists()) { + FileUtils.deleteDirectory(cacheDir); + } + if (cacheDir.exists()) { + LOG.info("Trying to load preprocessed model from {}", cacheDir); model = ModelSerializer.restoreComputationGraph(cacheDir); LOG.info("Preprocessed Model Loaded from {}", cacheDir); } else {