From 2ae2e15adddf5add63b5fb4680bea65ffecabf57 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Fri, 15 Dec 2023 19:23:20 +0100 Subject: [PATCH] avoid laoding previous versions --- .../pytorch/javacpp/PytorchJavaCPPInterface.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java b/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java index faa5154..c1f72f3 100644 --- a/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java +++ b/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java @@ -106,6 +106,10 @@ public class PytorchJavaCPPInterface implements DeepLearningEngineInterface private static final String DTYPE_KEY = "dtype"; private static final String IS_INPUT_KEY = "isInput"; private static final String MEM_NAME_KEY = "memoryName"; + /** + * Name without vesion of the JAR created for this library + */ + private static final String JAR_FILE_NAME = "dl-modelrunner-pytorch-javacpp"; /** * Constructor for the interface. It is going to be called from the @@ -463,6 +467,8 @@ private List getProcessCommandsWithoutArgs() throws IOException, URISynt String codeSource = protectionDomain.getCodeSource().getLocation().getPath(); String f_name = URLDecoder.decode(codeSource, StandardCharsets.UTF_8.toString()); for (File ff : new File(f_name).getParentFile().listFiles()) { + if (ff.getName().startsWith(JAR_FILE_NAME) && !ff.getAbsolutePath().equals(f_name)) + continue; classpath += ff.getAbsolutePath() + File.pathSeparator; } String className = PytorchJavaCPPInterface.class.getName();