diff --git a/src/main/java/qupath/ext/djl/DjlExtension.java b/src/main/java/qupath/ext/djl/DjlExtension.java index e7f0157..e66cfd8 100644 --- a/src/main/java/qupath/ext/djl/DjlExtension.java +++ b/src/main/java/qupath/ext/djl/DjlExtension.java @@ -43,7 +43,7 @@ public class DjlExtension implements QuPathExtension, GitHubProject { static { // Prevent downloading engines automatically - System.setProperty("offline", "true"); + System.setProperty("ai.djl.offline", "true"); // Opt out of tracking, see https://github.com/deepjavalibrary/djl/pull/2178/files System.setProperty("OPT_OUT_TRACKING", "true"); } diff --git a/src/main/java/qupath/ext/djl/DjlTools.java b/src/main/java/qupath/ext/djl/DjlTools.java index 21251fc..73021b5 100644 --- a/src/main/java/qupath/ext/djl/DjlTools.java +++ b/src/main/java/qupath/ext/djl/DjlTools.java @@ -245,21 +245,20 @@ public static Engine getEngine(String name, boolean downloadIfNeeded) throws Ill } synchronized (lock) { - var offlineStatus = System.getProperty("offline"); + var offlineStatus = System.getProperty("ai.djl.offline"); try { if (downloadIfNeeded) - System.setProperty("offline", "false"); + System.setProperty("ai.djl.offline", "false"); else - System.setProperty("offline", "true"); - + System.setProperty("ai.djl.offline", "true"); var engine = Engine.getEngine(name); if (engine != null) loadedEngines.add(name); return engine; } catch (Exception e) { - if (downloadIfNeeded) + if (downloadIfNeeded) { logger.error("Unable to get engine " + name + ": " + e.getMessage(), e); - else { + } else { var msg = e.getLocalizedMessage(); if (msg == null) logger.warn("Unable to get engine {}", name); @@ -268,7 +267,7 @@ public static Engine getEngine(String name, boolean downloadIfNeeded) throws Ill } return null; } finally { - System.setProperty("offline", offlineStatus); + System.setProperty("ai.djl.offline", offlineStatus); } } } diff --git a/src/main/java/qupath/ext/djl/DjlZoo.java b/src/main/java/qupath/ext/djl/DjlZoo.java index c8c7719..79dccb0 100644 --- a/src/main/java/qupath/ext/djl/DjlZoo.java +++ b/src/main/java/qupath/ext/djl/DjlZoo.java @@ -244,10 +244,10 @@ public static List listInstanceSegmentationModels() throws ModelNotFou * @throws IOException */ public static Criteria buildCriteria(Artifact artifact, boolean allowDownload) throws ModelNotFoundException, MalformedModelException, IOException { - var before = System.getProperty("offline"); + var before = System.getProperty("ai.djl.offline"); try { if (allowDownload) - System.setProperty("offline", "false"); + System.setProperty("ai.djl.offline", "false"); var application = artifact.getMetadata().getApplication(); @@ -300,7 +300,7 @@ public static List listInstanceSegmentationModels() throws ModelNotFou } return builder.build(); } finally { - System.setProperty("offline", before); + System.setProperty("ai.djl.offline", before); } } diff --git a/src/main/java/qupath/ext/djl/ui/DjlEngineCommand.java b/src/main/java/qupath/ext/djl/ui/DjlEngineCommand.java index b967bd7..acd5605 100644 --- a/src/main/java/qupath/ext/djl/ui/DjlEngineCommand.java +++ b/src/main/java/qupath/ext/djl/ui/DjlEngineCommand.java @@ -268,7 +268,8 @@ private static void updateVersionFromStatus(EngineStatus status, String engineNa try { var engine = Engine.getEngine(engineName); labelVersion.setText(engine.getVersion()); - labelVersion.setTooltip(new Tooltip(engine.toString())); + // this is toString, but TF ends up trying to download again. + labelVersion.setTooltip(new Tooltip(engine.getEngineName() + ':' + engine.getVersion())); return; } catch (Exception e) { logger.error("Error updating engine version: {}", e.getMessage(), e);