Repository: deepjavalibrary/djl
Pull request #3279 (2024-06-26 18:48:50)

[mxnet-model-zoo] Adds missing translatorFactory in metadata
## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here



Patch:
diff --git a/buildSrc/src/main/kotlin/ai/djl/javaProject.gradle.kts b/buildSrc/src/main/kotlin/ai/djl/javaProject.gradle.kts
index 2a3dc07fd..a0bd2e76e 100644
--- a/buildSrc/src/main/kotlin/ai/djl/javaProject.gradle.kts
+++ b/buildSrc/src/main/kotlin/ai/djl/javaProject.gradle.kts
@@ -1,5 +1,3 @@
-@file:Suppress("UNCHECKED_CAST")
-
 package ai.djl
 
 import org.gradle.kotlin.dsl.attributes
diff --git a/extensions/timeseries/src/main/java/ai/djl/timeseries/timefeature/TimeOffset.java b/extensions/timeseries/src/main/java/ai/djl/timeseries/timefeature/TimeOffset.java
index 2fe0d2c65..d845050c2 100644
--- a/extensions/timeseries/src/main/java/ai/djl/timeseries/timefeature/TimeOffset.java
+++ b/extensions/timeseries/src/main/java/ai/djl/timeseries/timefeature/TimeOffset.java
@@ -22,27 +22,28 @@ public class TimeOffset {
     private static String oPattern = "(?<multiple>\\d*)(?<granularity>\\w+)";
 
     private String name;
-    private int n;
+    private int offsetValue;
 
     /**
      * Constructs a new {@code TimeOffset} instance.
      *
      * @param name offset granularity including "D", "M" etc
-     * @param n offset multiple
+     * @param offsetValue offset multiple
      */
-    public TimeOffset(String name, int n) {
+    public TimeOffset(String name, int offsetValue) {
         this.name = name;
-        this.n = n;
+        this.offsetValue = offsetValue;
     }
 
     /**
      * Return {@code TimeOffset} object from frequency string.
      *
-     * @param freqStr Frequency string of the form [multiple][granularity] such as "12H", "1D" etc.
+     * @param frequencyString Frequency string of the form [multiple][granularity] such as "12H",
+     *     "1D" etc.
      * @return a TimeOffset containing multiple and granularity
      */
-    public static TimeOffset toOffset(String freqStr) {
-        Matcher matcher = Pattern.compile(oPattern).matcher(freqStr);
+    public static TimeOffset toOffset(String frequencyString) {
+        Matcher matcher = Pattern.compile(oPattern).matcher(frequencyString);
         matcher.find();
         String name = matcher.group("granularity");
         if ("".equals(name)) {
@@ -73,7 +74,7 @@ public class TimeOffset {
      * @return the multiple of {@code TimeOffset}
      */
     public double getMultipleOfTimeOffset() {
-        return n;
+        return offsetValue;
     }
 
     /**
@@ -82,6 +83,6 @@ public class TimeOffset {
      * @return the formatted frequency string
      */
     public String toFreqStr() {
-        return n + name;
+        return offsetValue + name;
     }
 }
diff --git a/gradle/plugins/build.gradle.kts b/gradle/plugins/build.gradle.kts
deleted file mode 100644
index 46f9c3f71..000000000
--- a/gradle/plugins/build.gradle.kts
+++ /dev/null
@@ -1,3 +0,0 @@
-plugins {
-    `kotlin-dsl`
-}
\ No newline at end of file
diff --git a/gradle/plugins/settings.gradle.kts b/gradle/plugins/settings.gradle.kts
deleted file mode 100644
index 1bdf3a884..000000000
--- a/gradle/plugins/settings.gradle.kts
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencyResolutionManagement {
-    repositories.gradlePluginPortal()
-}
\ No newline at end of file
diff --git a/gradle/plugins/src/main/kotlin/ai.djl.java.gradle.kts b/gradle/plugins/src/main/kotlin/ai.djl.java.gradle.kts
deleted file mode 100644
index 0a92d7e65..000000000
--- a/gradle/plugins/src/main/kotlin/ai.djl.java.gradle.kts
+++ /dev/null
@@ -1,21 +0,0 @@
-plugins {
-    java
-    idea
-}
-
-group = "ai.djl"
-val isRelease = project.hasProperty("release") || project.hasProperty("staging")
-//version = "${djl_version}" + (isRelease ? "" : "-SNAPSHOT")
-
-repositories {
-    mavenCentral()
-    maven("https://oss.sonatype.org/content/repositories/snapshots/")
-}
-
-idea {
-    module {
-        outputDir = file("build/classes/java/main")
-        testOutputDir = file("build/classes/java/test")
-        // inheritOutputDirs = true
-    }
-}
\ No newline at end of file


Test patch:
diff --git a/engines/mxnet/mxnet-model-zoo/src/test/resources/mlrepo/model/cv/instance_segmentation/ai/djl/mxnet/mask_rcnn/metadata.json b/engines/mxnet/mxnet-model-zoo/src/test/resources/mlrepo/model/cv/instance_segmentation/ai/djl/mxnet/mask_rcnn/metadata.json
index 99ea51cb3..31be8acc6 100644
--- a/engines/mxnet/mxnet-model-zoo/src/test/resources/mlrepo/model/cv/instance_segmentation/ai/djl/mxnet/mask_rcnn/metadata.json
+++ b/engines/mxnet/mxnet-model-zoo/src/test/resources/mlrepo/model/cv/instance_segmentation/ai/djl/mxnet/mask_rcnn/metadata.json
@@ -57,7 +57,8 @@
       },
       "arguments": {
         "normalize": true,
-        "synsetFileName": "classes.txt"
+        "synsetFileName": "classes.txt",
+        "translatorFactory": "ai.djl.modality.cv.translator.InstanceSegmentationTranslatorFactory"
       },
       "files": {
         "classes": {
diff --git a/integration/src/main/java/ai/djl/integration/tests/training/EvaluatorTest.java b/integration/src/main/java/ai/djl/integration/tests/training/EvaluatorTest.java
index 4638cfd03..2e858a291 100644
--- a/integration/src/main/java/ai/djl/integration/tests/training/EvaluatorTest.java
+++ b/integration/src/main/java/ai/djl/integration/tests/training/EvaluatorTest.java
@@ -32,13 +32,13 @@ public class EvaluatorTest {
     public void testAccuracy() {
         try (NDManager manager = NDManager.newBaseManager(TestUtils.getEngine())) {
 
-            NDArray predictions =
+            NDArray predictionsArray =
                     manager.create(new float[] {0.3f, 0.7f, 0, 1, 0.4f, 0.6f}, new Shape(3, 2));
             NDArray labels = manager.create(new int[] {0, 1, 1}, new Shape(3));
 
             AbstractAccuracy acc = new Accuracy();
             acc.addAccumulator("");
-            acc.updateAccumulator("", new NDList(labels), new NDList(predictions));
+            acc.updateAccumulator("", new NDList(labels), new NDList(predictionsArray));
             float accuracy = acc.getAccumulator("");
             float expectedAccuracy = 2.f / 3;
             Assert.assertEquals(
@@ -50,7 +50,7 @@ public class EvaluatorTest {
 
             acc = new Accuracy();
             acc.addAccumulator("");
-            acc.updateAccumulator("", new NDList(labels), new NDList(predictions));
+            acc.updateAccumulator("", new NDList(labels), new NDList(predictionsArray));
             accuracy = acc.getAccumulator("");
             expectedAccuracy = 2.f / 3;
             Assert.assertEquals(
@@ -64,12 +64,12 @@ public class EvaluatorTest {
     public void testCoverage() {
         try (NDManager manager = NDManager.newBaseManager(TestUtils.getEngine())) {
 
-            NDArray predictions = manager.create(new float[] {0.3f, 0.7f, 0.0f}, new Shape(3));
+            NDArray predictionsArray = manager.create(new float[] {0.3f, 0.7f, 0.0f}, new Shape(3));
             NDArray labels = manager.create(new float[] {0.5f, 0.5f, 0.5f}, new Shape(3));
 
             Coverage coverage = new Coverage();
             coverage.addAccumulator("");
-            coverage.updateAccumulator("", new NDList(labels), new NDList(predictions));
+            coverage.updateAccumulator("", new NDList(labels), new NDList(predictionsArray));
             float accuracy = coverage.getAccumulator("");
             float expectedAccuracy = 1.f / 3;
             Assert.assertEquals(
@@ -82,7 +82,7 @@ public class EvaluatorTest {
     @Test
     public void testTopKAccuracy() {
         try (NDManager manager = NDManager.newBaseManager(TestUtils.getEngine())) {
-            NDArray predictions =
+            NDArray predictionsArray =
                     manager.create(
                             new float[] {
                                 0.1f, 0.2f, 0.3f, 0.4f, 0, 1, 0, 0, 0.3f, 0.5f, 0.1f, 0.1f
@@ -91,7 +91,7 @@ public class EvaluatorTest {
             NDArray labels = manager.create(new int[] {0, 1, 2}, new Shape(3));
             TopKAccuracy topKAccuracy = new TopKAccuracy(2);
             topKAccuracy.addAccumulator("");
-            topKAccuracy.updateAccumulator("", new NDList(labels), new NDList(predictions));
+            topKAccuracy.updateAccumulator("", new NDList(labels), new NDList(predictionsArray));
             float expectedAccuracy = 1.f / 3;
             float accuracy = topKAccuracy.getAccumulator("");
             Assert.assertEquals(
@@ -102,7 +102,7 @@ public class EvaluatorTest {
             labels = manager.create(new long[] {0, 1, 2}, new Shape(3));
             topKAccuracy = new TopKAccuracy(2);
             topKAccuracy.addAccumulator("");
-            topKAccuracy.updateAccumulator("", new NDList(labels), new NDList(predictions));
+            topKAccuracy.updateAccumulator("", new NDList(labels), new NDList(predictionsArray));
             expectedAccuracy = 1.f / 3;
             accuracy = topKAccuracy.getAccumulator("");
             Assert.assertEquals(