diff --git a/build.gradle b/build.gradle index 4584958..6d96dc0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,34 +1,17 @@ -plugins { - id 'java' -} - -repositories { - mavenLocal() - jcenter() - maven { - url "https://oss.sonatype.org/content/repositories/snapshots/" +allprojects { + repositories { + jcenter() + maven { + url "https://oss.sonatype.org/content/repositories/snapshots/" + } } -} - -dependencies { - implementation "javax.visrec:visrec-api:1.0-SNAPSHOT" - implementation "ai.djl:api:0.3.0-SNAPSHOT" - implementation "ai.djl:basicdataset:0.3.0-SNAPSHOT" - implementation "ai.djl:model-zoo:0.3.0-SNAPSHOT" - implementation "ai.djl.mxnet:mxnet-model-zoo:0.3.0-SNAPSHOT" - implementation 'ai.djl.mxnet:mxnet-engine:0.3.0-SNAPSHOT' - implementation 'ai.djl.mxnet:mxnet-native-mkl:1.6.0-c-SNAPSHOT' - implementation "org.apache.commons:commons-csv:1.7" - implementation "org.slf4j:slf4j-simple:1.7.30" - testImplementation("org.testng:testng:6.14.3") { - exclude group: "junit", module: "junit" + apply plugin: 'idea' + idea { + module { + outputDir = file('build/classes/java/main') + testOutputDir = file('build/classes/java/test') + // inheritOutputDirs = true + } } } - -test { - // Use TestNG for unit tests - useTestNG() -} - -apply from: file("${rootProject.projectDir}/tools/gradle/formatter.gradle") diff --git a/examples/build.gradle b/examples/build.gradle new file mode 100644 index 0000000..3120c56 --- /dev/null +++ b/examples/build.gradle @@ -0,0 +1,30 @@ +plugins { + id "java" + id "application" +} + +dependencies { + implementation project(":jsr381") + + testImplementation("org.testng:testng:6.14.3") { + exclude group: "junit", module: "junit" + } +} + +test { + // Use TestNG for unit tests + useTestNG() +} + +application { + mainClassName = System.getProperty("main", "ai.djl.jsr381.detection.ObjectDetectorExample") +} + +run { + systemProperties System.getProperties() + systemProperties.remove("user.dir") + systemProperty("file.encoding", "UTF-8") +} +tasks.distTar.enabled = false + +apply from: file("${rootProject.projectDir}/tools/gradle/formatter.gradle") diff --git a/examples/gradlew b/examples/gradlew new file mode 120000 index 0000000..502f5a2 --- /dev/null +++ b/examples/gradlew @@ -0,0 +1 @@ +../gradlew \ No newline at end of file diff --git a/examples/gradlew.bat b/examples/gradlew.bat new file mode 120000 index 0000000..2840132 --- /dev/null +++ b/examples/gradlew.bat @@ -0,0 +1 @@ +../gradlew.bat \ No newline at end of file diff --git a/examples/src/main/java/ai/djl/jsr381/classification/BinaryClassifierExample.java b/examples/src/main/java/ai/djl/jsr381/classification/BinaryClassifierExample.java new file mode 100644 index 0000000..14c2025 --- /dev/null +++ b/examples/src/main/java/ai/djl/jsr381/classification/BinaryClassifierExample.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package ai.djl.jsr381.classification; + +import java.io.File; +import javax.visrec.ml.ClassificationException; +import javax.visrec.ml.ClassifierCreationException; +import javax.visrec.ml.classification.BinaryClassifier; +import javax.visrec.ml.classification.NeuralNetBinaryClassifier; + +public class BinaryClassifierExample { + + public static void main(String[] args) + throws ClassificationException, ClassifierCreationException { + File trainingFile = new File("../jsr381/src/test/resources/spam.csv"); + BinaryClassifier spamClassifier = + NeuralNetBinaryClassifier.builder() + .inputClass(float[].class) + .inputsNum(57) + .hiddenLayers(5) + .maxEpochs(2) + .trainingFile(trainingFile) + .build(); + + // create test email feature + float[] emailFeatures = new float[57]; + emailFeatures[56] = 1; + + Float result = spamClassifier.classify(emailFeatures); + System.out.println(result); + } +} diff --git a/examples/src/main/java/ai/djl/jsr381/classification/ImageClassifierExample.java b/examples/src/main/java/ai/djl/jsr381/classification/ImageClassifierExample.java new file mode 100644 index 0000000..35e0279 --- /dev/null +++ b/examples/src/main/java/ai/djl/jsr381/classification/ImageClassifierExample.java @@ -0,0 +1,41 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package ai.djl.jsr381.classification; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Map; +import javax.visrec.ml.ClassificationException; +import javax.visrec.ml.ClassifierCreationException; +import javax.visrec.ml.classification.ImageClassifier; +import javax.visrec.ml.classification.NeuralNetImageClassifier; + +public class ImageClassifierExample { + + public static void main(String[] args) + throws ClassifierCreationException, ClassificationException { + File input = new File("../jsr381/src/test/resources/0.png"); + + ImageClassifier classifier = + NeuralNetImageClassifier.builder() + .inputClass(BufferedImage.class) + .imageHeight(28) + .imageWidth(28) + .build(); + + Map result = classifier.classify(input); + for (Map.Entry entry : result.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + } +} diff --git a/examples/src/main/java/ai/djl/jsr381/detection/ObjectDetectorExample.java b/examples/src/main/java/ai/djl/jsr381/detection/ObjectDetectorExample.java new file mode 100644 index 0000000..c0339bf --- /dev/null +++ b/examples/src/main/java/ai/djl/jsr381/detection/ObjectDetectorExample.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance + * with the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ +package ai.djl.jsr381.detection; + +import ai.djl.Application; +import ai.djl.MalformedModelException; +import ai.djl.modality.cv.DetectedObjects; +import ai.djl.modality.cv.util.BufferedImageUtils; +import ai.djl.repository.zoo.Criteria; +import ai.djl.repository.zoo.ModelNotFoundException; +import ai.djl.repository.zoo.ModelZoo; +import ai.djl.repository.zoo.ZooModel; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import javax.visrec.ml.ClassificationException; +import javax.visrec.util.BoundingBox; + +public class ObjectDetectorExample { + + public static void main(String[] args) + throws ClassificationException, IOException, ModelNotFoundException, + MalformedModelException { + Criteria criteria = + Criteria.builder() + .setTypes(BufferedImage.class, DetectedObjects.class) + .optApplication(Application.CV.OBJECT_DETECTION) + .optArgument("threshold", 0.01) + .build(); + try (ZooModel model = ModelZoo.loadModel(criteria)) { + SimpleObjectDetector objectDetector = new SimpleObjectDetector(model); + + BufferedImage input = + BufferedImageUtils.fromUrl( + "https://djl-ai.s3.amazonaws.com/resources/images/dog_bike_car.jpg"); + Map> result = objectDetector.detectObject(input); + + for (List boundingBoxes : result.values()) { + for (BoundingBox boundingBox : boundingBoxes) { + System.out.println(boundingBox.toString()); + } + } + } + } +} diff --git a/gradle.properties b/gradle.properties index 1c3eab5..955cb5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,8 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xmx1024M + +systemProp.org.gradle.internal.http.socketTimeout=120000 +systemProp.org.gradle.internal.http.connectionTimeout=60000 + +# FIXME: Workaround gradle publish issue: https://github.com/gradle/gradle/issues/11308 +systemProp.org.gradle.internal.publish.checksums.insecure=true diff --git a/jsr381/build.gradle b/jsr381/build.gradle new file mode 100644 index 0000000..d35af7a --- /dev/null +++ b/jsr381/build.gradle @@ -0,0 +1,118 @@ +plugins { + id "java-library" + id "maven-publish" + id "signing" +} + +group "ai.djl.jsr381" +boolean isRelease = project.hasProperty("release") || project.hasProperty("staging") +version = "0.3.0" + (isRelease ? "" : "-SNAPSHOT") + +dependencies { + api "javax.visrec:visrec-api:1.0-SNAPSHOT" + api "ai.djl:api:0.3.0" + api "ai.djl:basicdataset:0.3.0" + api "ai.djl:model-zoo:0.3.0" + api "ai.djl.mxnet:mxnet-model-zoo:0.3.0" + api 'ai.djl.mxnet:mxnet-engine:0.3.0' + api 'ai.djl.mxnet:mxnet-native-auto:1.6.0' + api "org.apache.commons:commons-csv:1.7" + + testImplementation "org.slf4j:slf4j-simple:1.7.30" + testImplementation("org.testng:testng:6.14.3") { + exclude group: "junit", module: "junit" + } +} + +java { + withJavadocJar() + withSourcesJar() +} + +test { + // Use TestNG for unit tests + useTestNG() +} + +apply from: file("${rootProject.projectDir}/tools/gradle/formatter.gradle") + +project.tasks.withType(GenerateModuleMetadata) { + enabled = false +} + +signing { + required(project.hasProperty("staging") || project.hasProperty("snapshot")) + def signingKey = findProperty("signingKey") + def signingPassword = findProperty("signingPassword") + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications +} + +if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (gradle.startParameter.taskNames.contains("publish")) { + throw new GradleException("JDK 1.8 is required to run publish task.") + } + return +} + +publishing { + publications { + maven(MavenPublication) { + from components.java + artifacts = [jar, javadocJar, sourcesJar] + pom { + name = "Deep Java Library implementation of JSR-381" + description = "Deep Java Library implementation of JSR-381" + url = "http://www.djl.ai/" + + packaging = "jar" + + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0' + } + } + + scm { + connection = "scm:git:git@github.com:awslabs/djl.git" + developerConnection = "scm:git:git@github.com:awslabs/djl.git" + url = "https://github.com/awslabs/djl" + tag = "HEAD" + } + + developers { + developer { + name = "DJL.AI Team" + email = "djl-dev@amazon.com" + organization = "Amazon AI" + organizationUrl = "https://amazon.com" + } + } + } + } + } + + repositories { + maven { + if (project.hasProperty("snapshot")) { + name = "snapshot" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + credentials { + username = findProperty("ossrhUsername") + password = findProperty("ossrhPassword") + } + } else if (project.hasProperty("staging")) { + name = "staging" + url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username = findProperty("ossrhUsername") + password = findProperty("ossrhPassword") + } + } else { + name = "local" + url = "build/repo" + } + } + } +} diff --git a/jsr381/gradlew b/jsr381/gradlew new file mode 120000 index 0000000..502f5a2 --- /dev/null +++ b/jsr381/gradlew @@ -0,0 +1 @@ +../gradlew \ No newline at end of file diff --git a/jsr381/gradlew.bat b/jsr381/gradlew.bat new file mode 120000 index 0000000..2840132 --- /dev/null +++ b/jsr381/gradlew.bat @@ -0,0 +1 @@ +../gradlew.bat \ No newline at end of file diff --git a/src/main/java/visrec/djl/ml/classification/SimpleBinaryClassifier.java b/jsr381/src/main/java/ai/djl/jsr381/classification/SimpleBinaryClassifier.java similarity index 93% rename from src/main/java/visrec/djl/ml/classification/SimpleBinaryClassifier.java rename to jsr381/src/main/java/ai/djl/jsr381/classification/SimpleBinaryClassifier.java index 7b2714c..25631bf 100644 --- a/src/main/java/visrec/djl/ml/classification/SimpleBinaryClassifier.java +++ b/jsr381/src/main/java/ai/djl/jsr381/classification/SimpleBinaryClassifier.java @@ -1,4 +1,4 @@ -package visrec.djl.ml.classification; +package ai.djl.jsr381.classification; import ai.djl.inference.Predictor; import ai.djl.repository.zoo.ZooModel; diff --git a/src/main/java/visrec/djl/ml/classification/SimpleImageClassifier.java b/jsr381/src/main/java/ai/djl/jsr381/classification/SimpleImageClassifier.java similarity index 98% rename from src/main/java/visrec/djl/ml/classification/SimpleImageClassifier.java rename to jsr381/src/main/java/ai/djl/jsr381/classification/SimpleImageClassifier.java index b672283..6cb5b73 100644 --- a/src/main/java/visrec/djl/ml/classification/SimpleImageClassifier.java +++ b/jsr381/src/main/java/ai/djl/jsr381/classification/SimpleImageClassifier.java @@ -1,4 +1,4 @@ -package visrec.djl.ml.classification; +package ai.djl.jsr381.classification; import ai.djl.inference.Predictor; import ai.djl.modality.Classifications; diff --git a/src/main/java/visrec/djl/ml/dataset/CsvDataset.java b/jsr381/src/main/java/ai/djl/jsr381/dataset/CsvDataset.java similarity index 98% rename from src/main/java/visrec/djl/ml/dataset/CsvDataset.java rename to jsr381/src/main/java/ai/djl/jsr381/dataset/CsvDataset.java index 23346e0..67fefed 100644 --- a/src/main/java/visrec/djl/ml/dataset/CsvDataset.java +++ b/jsr381/src/main/java/ai/djl/jsr381/dataset/CsvDataset.java @@ -1,4 +1,4 @@ -package visrec.djl.ml.dataset; +package ai.djl.jsr381.dataset; import ai.djl.ndarray.NDArray; import ai.djl.ndarray.NDList; diff --git a/src/main/java/visrec/djl/ml/detection/SimpleObjectDetector.java b/jsr381/src/main/java/ai/djl/jsr381/detection/SimpleObjectDetector.java similarity index 98% rename from src/main/java/visrec/djl/ml/detection/SimpleObjectDetector.java rename to jsr381/src/main/java/ai/djl/jsr381/detection/SimpleObjectDetector.java index a86c302..aa17c48 100644 --- a/src/main/java/visrec/djl/ml/detection/SimpleObjectDetector.java +++ b/jsr381/src/main/java/ai/djl/jsr381/detection/SimpleObjectDetector.java @@ -1,4 +1,4 @@ -package visrec.djl.ml.detection; +package ai.djl.jsr381.detection; import ai.djl.inference.Predictor; import ai.djl.modality.cv.DetectedObjects; diff --git a/src/main/java/visrec/djl/spi/DjlBinaryClassifierFactory.java b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlBinaryClassifierFactory.java similarity index 97% rename from src/main/java/visrec/djl/spi/DjlBinaryClassifierFactory.java rename to jsr381/src/main/java/ai/djl/jsr381/spi/DjlBinaryClassifierFactory.java index ae2f6b0..81ac958 100644 --- a/src/main/java/visrec/djl/spi/DjlBinaryClassifierFactory.java +++ b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlBinaryClassifierFactory.java @@ -1,6 +1,8 @@ -package visrec.djl.spi; +package ai.djl.jsr381.spi; import ai.djl.Model; +import ai.djl.jsr381.classification.SimpleBinaryClassifier; +import ai.djl.jsr381.dataset.CsvDataset; import ai.djl.metric.Metrics; import ai.djl.ndarray.NDArray; import ai.djl.ndarray.NDList; @@ -26,8 +28,6 @@ import javax.visrec.ml.classification.BinaryClassifier; import javax.visrec.ml.classification.NeuralNetBinaryClassifier; import javax.visrec.spi.BinaryClassifierFactory; -import visrec.djl.ml.classification.SimpleBinaryClassifier; -import visrec.djl.ml.dataset.CsvDataset; public class DjlBinaryClassifierFactory implements BinaryClassifierFactory { diff --git a/src/main/java/visrec/djl/spi/DjlImageClassifierFactory.java b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlImageClassifierFactory.java similarity index 95% rename from src/main/java/visrec/djl/spi/DjlImageClassifierFactory.java rename to jsr381/src/main/java/ai/djl/jsr381/spi/DjlImageClassifierFactory.java index e4a7254..d3ed3d3 100644 --- a/src/main/java/visrec/djl/spi/DjlImageClassifierFactory.java +++ b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlImageClassifierFactory.java @@ -1,7 +1,8 @@ -package visrec.djl.spi; +package ai.djl.jsr381.spi; import ai.djl.MalformedModelException; import ai.djl.basicmodelzoo.BasicModelZoo; +import ai.djl.jsr381.classification.SimpleImageClassifier; import ai.djl.modality.Classifications; import ai.djl.repository.zoo.Criteria; import ai.djl.repository.zoo.ModelNotFoundException; @@ -15,7 +16,6 @@ import javax.visrec.spi.ImageClassifierFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import visrec.djl.ml.classification.SimpleImageClassifier; public class DjlImageClassifierFactory implements ImageClassifierFactory { diff --git a/src/main/java/visrec/djl/spi/DjlImageFactoryService.java b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlImageFactoryService.java similarity index 99% rename from src/main/java/visrec/djl/spi/DjlImageFactoryService.java rename to jsr381/src/main/java/ai/djl/jsr381/spi/DjlImageFactoryService.java index 88c1153..ef20e2a 100644 --- a/src/main/java/visrec/djl/spi/DjlImageFactoryService.java +++ b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlImageFactoryService.java @@ -1,4 +1,4 @@ -package visrec.djl.spi; +package ai.djl.jsr381.spi; import java.awt.image.BufferedImage; import java.io.File; diff --git a/src/main/java/visrec/djl/spi/DjlImplementationService.java b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlImplementationService.java similarity index 93% rename from src/main/java/visrec/djl/spi/DjlImplementationService.java rename to jsr381/src/main/java/ai/djl/jsr381/spi/DjlImplementationService.java index 33d314e..a7ab9ab 100644 --- a/src/main/java/visrec/djl/spi/DjlImplementationService.java +++ b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlImplementationService.java @@ -1,4 +1,4 @@ -package visrec.djl.spi; +package ai.djl.jsr381.spi; import javax.visrec.spi.ImplementationService; diff --git a/src/main/java/visrec/djl/spi/DjlServiceProvider.java b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlServiceProvider.java similarity index 92% rename from src/main/java/visrec/djl/spi/DjlServiceProvider.java rename to jsr381/src/main/java/ai/djl/jsr381/spi/DjlServiceProvider.java index 1acbf20..8cb2ce9 100644 --- a/src/main/java/visrec/djl/spi/DjlServiceProvider.java +++ b/jsr381/src/main/java/ai/djl/jsr381/spi/DjlServiceProvider.java @@ -1,4 +1,4 @@ -package visrec.djl.spi; +package ai.djl.jsr381.spi; import javax.visrec.spi.BuilderService; import javax.visrec.spi.ImageFactoryService; @@ -14,6 +14,7 @@ public final class DjlServiceProvider extends ServiceProvider { /** {@inheritDoc} */ @Override + @SuppressWarnings("deprecation") public BuilderService getBuilderService() { return null; } diff --git a/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.BinaryClassifierFactory b/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.BinaryClassifierFactory new file mode 100644 index 0000000..f1e1aba --- /dev/null +++ b/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.BinaryClassifierFactory @@ -0,0 +1 @@ +ai.djl.jsr381.spi.DjlBinaryClassifierFactory diff --git a/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.ImageClassifierFactory b/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.ImageClassifierFactory new file mode 100644 index 0000000..cbb4c21 --- /dev/null +++ b/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.ImageClassifierFactory @@ -0,0 +1 @@ +ai.djl.jsr381.spi.DjlImageClassifierFactory diff --git a/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.ServiceProvider b/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.ServiceProvider new file mode 100644 index 0000000..69b81c4 --- /dev/null +++ b/jsr381/src/main/resources/META-INF/services/javax.visrec.spi.ServiceProvider @@ -0,0 +1 @@ +ai.djl.jsr381.spi.DjlServiceProvider diff --git a/src/test/java/visrec/djl/ml/classification/BinaryClassifierTest.java b/jsr381/src/test/java/ai/djl/jsr381/classification/BinaryClassifierTest.java similarity index 97% rename from src/test/java/visrec/djl/ml/classification/BinaryClassifierTest.java rename to jsr381/src/test/java/ai/djl/jsr381/classification/BinaryClassifierTest.java index 7bbf458..a1371c7 100644 --- a/src/test/java/visrec/djl/ml/classification/BinaryClassifierTest.java +++ b/jsr381/src/test/java/ai/djl/jsr381/classification/BinaryClassifierTest.java @@ -10,7 +10,7 @@ * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ -package visrec.djl.ml.classification; +package ai.djl.jsr381.classification; import java.io.File; import java.net.URL; diff --git a/src/test/java/visrec/djl/ml/classification/ImageClassifierTest.java b/jsr381/src/test/java/ai/djl/jsr381/classification/ImageClassifierTest.java similarity index 97% rename from src/test/java/visrec/djl/ml/classification/ImageClassifierTest.java rename to jsr381/src/test/java/ai/djl/jsr381/classification/ImageClassifierTest.java index 9bf5b9f..90aad91 100644 --- a/src/test/java/visrec/djl/ml/classification/ImageClassifierTest.java +++ b/jsr381/src/test/java/ai/djl/jsr381/classification/ImageClassifierTest.java @@ -10,7 +10,7 @@ * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ -package visrec.djl.ml.classification; +package ai.djl.jsr381.classification; import java.awt.image.BufferedImage; import java.io.File; diff --git a/src/test/java/visrec/djl/ml/detection/ObjectDetectorTest.java b/jsr381/src/test/java/ai/djl/jsr381/detection/ObjectDetectorTest.java similarity index 83% rename from src/test/java/visrec/djl/ml/detection/ObjectDetectorTest.java rename to jsr381/src/test/java/ai/djl/jsr381/detection/ObjectDetectorTest.java index 3ab1da3..7e7b2a5 100644 --- a/src/test/java/visrec/djl/ml/detection/ObjectDetectorTest.java +++ b/jsr381/src/test/java/ai/djl/jsr381/detection/ObjectDetectorTest.java @@ -10,12 +10,12 @@ * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ -package visrec.djl.ml.detection; +package ai.djl.jsr381.detection; +import ai.djl.Application; import ai.djl.MalformedModelException; import ai.djl.modality.cv.DetectedObjects; import ai.djl.modality.cv.util.BufferedImageUtils; -import ai.djl.repository.MRL; import ai.djl.repository.zoo.Criteria; import ai.djl.repository.zoo.ModelNotFoundException; import ai.djl.repository.zoo.ModelZoo; @@ -37,7 +37,8 @@ public void testObjectDetection() Criteria criteria = Criteria.builder() .setTypes(BufferedImage.class, DetectedObjects.class) - .optApplication(MRL.Model.CV.OBJECT_DETECTION) + .optApplication(Application.CV.OBJECT_DETECTION) + .optArgument("threshold", 0.01) .build(); try (ZooModel model = ModelZoo.loadModel(criteria)) { SimpleObjectDetector objectDetector = new SimpleObjectDetector(model); @@ -47,8 +48,10 @@ public void testObjectDetection() "https://djl-ai.s3.amazonaws.com/resources/images/dog_bike_car.jpg"); Map> result = objectDetector.detectObject(input); - for (String label : result.keySet()) { - System.out.println(label); + for (List boundingBoxes : result.values()) { + for (BoundingBox boundingBox : boundingBoxes) { + System.out.println(boundingBox.toString()); + } } } } diff --git a/src/test/resources/0.png b/jsr381/src/test/resources/0.png similarity index 100% rename from src/test/resources/0.png rename to jsr381/src/test/resources/0.png diff --git a/src/test/resources/spam.csv b/jsr381/src/test/resources/spam.csv similarity index 100% rename from src/test/resources/spam.csv rename to jsr381/src/test/resources/spam.csv diff --git a/settings.gradle b/settings.gradle index a2c89ad..4157fb8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'visrec-djl' +include "jsr381", "examples" diff --git a/src/main/resources/META-INF/services/javax.visrec.spi.BinaryClassifierFactory b/src/main/resources/META-INF/services/javax.visrec.spi.BinaryClassifierFactory deleted file mode 100644 index 7264007..0000000 --- a/src/main/resources/META-INF/services/javax.visrec.spi.BinaryClassifierFactory +++ /dev/null @@ -1 +0,0 @@ -visrec.djl.spi.DjlBinaryClassifierFactory diff --git a/src/main/resources/META-INF/services/javax.visrec.spi.ImageClassifierFactory b/src/main/resources/META-INF/services/javax.visrec.spi.ImageClassifierFactory deleted file mode 100644 index 09b5700..0000000 --- a/src/main/resources/META-INF/services/javax.visrec.spi.ImageClassifierFactory +++ /dev/null @@ -1 +0,0 @@ -visrec.djl.spi.DjlImageClassifierFactory diff --git a/src/main/resources/META-INF/services/javax.visrec.spi.ServiceProvider b/src/main/resources/META-INF/services/javax.visrec.spi.ServiceProvider deleted file mode 100644 index 4dcf279..0000000 --- a/src/main/resources/META-INF/services/javax.visrec.spi.ServiceProvider +++ /dev/null @@ -1 +0,0 @@ -visrec.djl.spi.DjlServiceProvider