Repository: deepjavalibrary/djl
Pull request #1695 (2022-06-05 00:42:44)

[pytorch] Uses pytorch to test API and aws-ai module
Change-Id: Ib490eb8c4e026a3c4dee94d76700b1e9744812f8

## 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


codecov-commenter: # [Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/1695?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) Report
> Merging [#1695](https://codecov.io/gh/deepjavalibrary/djl/pull/1695?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) (3cd532d) into [master](https://codecov.io/gh/deepjavalibrary/djl/commit/bb5073f7ffc33f1883621fc1783dbb01e70b418f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) (bb5073f) will **decrease** coverage by `1.59%`.
> The diff coverage is `65.58%`.

```diff
@@             Coverage Diff              @@
##             master    #1695      +/-   ##
============================================
- Coverage     72.08%   70.49%   -1.60%     
- Complexity     5126     5512     +386     
============================================
  Files           473      521      +48     
  Lines         21970    24431    +2461     
  Branches       2351     2648     +297     
============================================
+ Hits          15838    17223    +1385     
- Misses         4925     5899     +974     
- Partials       1207     1309     +102     
```


| [Impacted Files](https://codecov.io/gh/deepjavalibrary/djl/pull/1695?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | Coverage Δ | |
|---|---|---|
| [api/src/main/java/ai/djl/modality/cv/Image.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L0ltYWdlLmphdmE=) | `69.23% <ø> (-4.11%)` | :arrow_down: |
| [...rc/main/java/ai/djl/modality/cv/output/Joints.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9Kb2ludHMuamF2YQ==) | `71.42% <ø> (ø)` | |
| [.../main/java/ai/djl/modality/cv/output/Landmark.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9MYW5kbWFyay5qYXZh) | `100.00% <ø> (ø)` | |
| [...main/java/ai/djl/modality/cv/output/Rectangle.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9SZWN0YW5nbGUuamF2YQ==) | `72.41% <0.00%> (ø)` | |
| [...i/djl/modality/cv/translator/BigGANTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvQmlnR0FOVHJhbnNsYXRvci5qYXZh) | `21.42% <ø> (-5.24%)` | :arrow_down: |
| [...odality/cv/translator/BigGANTranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvQmlnR0FOVHJhbnNsYXRvckZhY3RvcnkuamF2YQ==) | `33.33% <0.00%> (+8.33%)` | :arrow_up: |
| [...nslator/InstanceSegmentationTranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvSW5zdGFuY2VTZWdtZW50YXRpb25UcmFuc2xhdG9yRmFjdG9yeS5qYXZh) | `14.28% <0.00%> (-3.90%)` | :arrow_down: |
| [.../ai/djl/modality/cv/translator/YoloTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1RyYW5zbGF0b3IuamF2YQ==) | `8.33% <0.00%> (-0.50%)` | :arrow_down: |
| [.../modality/cv/translator/YoloTranslatorFactory.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1RyYW5zbGF0b3JGYWN0b3J5LmphdmE=) | `8.33% <0.00%> (-1.67%)` | :arrow_down: |
| [...i/djl/modality/cv/translator/YoloV5Translator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1Y1VHJhbnNsYXRvci5qYXZh) | `5.38% <0.00%> (-0.31%)` | :arrow_down: |
| ... and [284 more](https://codecov.io/gh/deepjavalibrary/djl/pull/1695/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/1695?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/1695?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary). Last update [ec82480...3cd532d](https://codecov.io/gh/deepjavalibrary/djl/pull/1695?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).


Patch:
diff --git a/api/build.gradle b/api/build.gradle
index 94c2c2e7e..5f16a668e 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -8,7 +8,7 @@ dependencies {
         exclude group: "junit", module: "junit"
     }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
-    testRuntimeOnly project(":engines:mxnet:mxnet-model-zoo")
+    testRuntimeOnly project(":engines:pytorch:pytorch-model-zoo")
 }
 
 javadoc {
diff --git a/basicdataset/build.gradle b/basicdataset/build.gradle
index 132999c50..eac450c4d 100644
--- a/basicdataset/build.gradle
+++ b/basicdataset/build.gradle
@@ -10,7 +10,7 @@ dependencies {
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 
     testImplementation project(":testing")
-    testImplementation project(":engines:mxnet:mxnet-engine")
+    testImplementation project(":engines:pytorch:pytorch-engine")
 }
 
 task syncS3(type: Exec) {
diff --git a/extensions/aws-ai/build.gradle b/extensions/aws-ai/build.gradle
index 360ede00f..e28f63b0a 100644
--- a/extensions/aws-ai/build.gradle
+++ b/extensions/aws-ai/build.gradle
@@ -9,7 +9,7 @@ dependencies {
     api "software.amazon.awssdk:sts"
     api project(":api")
 
-    testImplementation project(":engines:mxnet:mxnet-model-zoo")
+    testImplementation project(":engines:pytorch:pytorch-model-zoo")
 
     testImplementation("org.testng:testng:${testng_version}") {
         exclude group: "junit", module: "junit"


Test patch:
diff --git a/api/src/test/java/ai/djl/repository/DjlRepositoryTest.java b/api/src/test/java/ai/djl/repository/DjlRepositoryTest.java
index 83b8e9507..0f39630a7 100644
--- a/api/src/test/java/ai/djl/repository/DjlRepositoryTest.java
+++ b/api/src/test/java/ai/djl/repository/DjlRepositoryTest.java
@@ -26,16 +26,16 @@ public class DjlRepositoryTest {
 
     @Test
     public void testResource() throws ModelNotFoundException, MalformedModelException, IOException {
-        Repository repo = Repository.newInstance("DJL", "djl://ai.djl.mxnet/mlp");
+        Repository repo = Repository.newInstance("DJL", "djl://ai.djl.pytorch/resnet");
         Assert.assertEquals(repo.getResources().size(), 1);
 
-        repo = Repository.newInstance("DJL", "djl://ai.djl.mxnet/resnet/0.0.1");
+        repo = Repository.newInstance("DJL", "djl://ai.djl.pytorch/resnet/0.0.1");
         Assert.assertEquals(repo.getResources().size(), 1);
 
-        repo = Repository.newInstance("DJL", "djl://ai.djl.mxnet/resnet/0.0.1/resnet18_v1");
+        repo = Repository.newInstance("DJL", "djl://ai.djl.pytorch/resnet/0.0.1/traced_resnet18");
         Assert.assertEquals(repo.getResources().size(), 1);
 
-        repo = Repository.newInstance("DJL", "djl://ai.djl.mxnet/fake/0.0.1");
+        repo = Repository.newInstance("DJL", "djl://ai.djl.pytorch/fake/0.0.1");
         Assert.assertEquals(repo.getResources().size(), 0);
 
         repo = Repository.newInstance("DJL", "djl://ai.djl.fake/mlp/0.0.1");
@@ -46,19 +46,19 @@ public class DjlRepositoryTest {
 
         Assert.expectThrows(
                 IllegalArgumentException.class,
-                () -> Repository.newInstance("DJL", "djl://ai.djl.mxnet"));
+                () -> Repository.newInstance("DJL", "djl://ai.djl.pytorch"));
 
         Assert.expectThrows(
                 IllegalArgumentException.class,
-                () -> Repository.newInstance("DJL", "djl://ai.djl.mxnet/"));
+                () -> Repository.newInstance("DJL", "djl://ai.djl.pytorch/"));
 
         Criteria<Image, Classifications> criteria =
                 Criteria.builder()
                         .setTypes(Image.class, Classifications.class)
-                        .optModelUrls("djl://ai.djl.mxnet/resnet/0.0.1/resnet18_v1")
+                        .optModelUrls("djl://ai.djl.pytorch/resnet/0.0.1/traced_resnet18")
                         .build();
         try (ZooModel<Image, Classifications> model = criteria.loadModel()) {
-            Assert.assertEquals(model.getName(), "resnet18_v1");
+            Assert.assertEquals(model.getName(), "traced_resnet18");
         }
     }
 }
diff --git a/extensions/aws-ai/src/test/java/ai/djl/aws/s3/S3RepositoryTest.java b/extensions/aws-ai/src/test/java/ai/djl/aws/s3/S3RepositoryTest.java
index 96ab442f1..7afc9e17e 100644
--- a/extensions/aws-ai/src/test/java/ai/djl/aws/s3/S3RepositoryTest.java
+++ b/extensions/aws-ai/src/test/java/ai/djl/aws/s3/S3RepositoryTest.java
@@ -51,13 +51,12 @@ public class S3RepositoryTest {
         Criteria<NDList, NDList> criteria =
                 Criteria.builder()
                         .setTypes(NDList.class, NDList.class)
-                        .optModelUrls(
-                                "s3://djl-ai/mlrepo/model/cv/image_classification/ai/djl/mxnet/mlp/0.0.1")
-                        .optModelName("mlp")
+                        .optModelUrls("s3://djl-ai/resources/demo/pytorch/traced_resnet18")
+                        .optModelName("traced_resnet18")
                         .build();
 
         try (ZooModel<NDList, NDList> model = criteria.loadModel()) {
-            Assert.assertEquals(model.getName(), "mlp");
+            Assert.assertEquals(model.getName(), "traced_resnet18");
         }
     }
 
@@ -75,12 +74,12 @@ public class S3RepositoryTest {
         Criteria<NDList, NDList> criteria =
                 Criteria.builder()
                         .setTypes(NDList.class, NDList.class)
-                        .optModelUrls("s3://djl-ai/resources/test-models/mlp.tar.gz")
-                        .optModelName("mlp")
+                        .optModelUrls("s3://djl-ai/resources/demo/pytorch/traced_resnet18.zip")
+                        .optModelName("traced_resnet18")
                         .build();
 
         try (ZooModel<NDList, NDList> model = criteria.loadModel()) {
-            Assert.assertEquals(model.getName(), "mlp");
+            Assert.assertEquals(model.getName(), "traced_resnet18");
         }
     }