Repository: deepjavalibrary/djl
Pull request #3206 (2024-05-21 00:35:27)

[examples] Fixes ObjectDetection example for macOS m1
## 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/.github/workflows/native_jni_s3_pytorch.yml b/.github/workflows/native_jni_s3_pytorch.yml
index 95fd4a8cb..1607e4d35 100644
--- a/.github/workflows/native_jni_s3_pytorch.yml
+++ b/.github/workflows/native_jni_s3_pytorch.yml
@@ -193,7 +193,9 @@ jobs:
           call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
           set "CUDA_PATH=%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v11.7"
           set "PATH=%CUDA_PATH%\bin;%CUDA_PATH%\libnvvp;%PATH%"
-          gradlew :engines:pytorch:pytorch-native:cleanJNI :engines:pytorch:pytorch-native:compileJNI -Pcuda=${{ github.event.inputs.cuda }} -Ppt_version=${{ github.event.inputs.pt_version }}
+          set CUDA_VERSION=${{ github.event.inputs.cuda }}
+          if "%CUDA_VERSION%" == "" set CUDA_VERSION=cu121
+          gradlew :engines:pytorch:pytorch-native:cleanJNI :engines:pytorch:pytorch-native:compileJNI -Pcuda=%CUDA_VERSION% -Ppt_version=${{ github.event.inputs.pt_version }}
       - name: Configure AWS Credentials
         uses: aws-actions/configure-aws-credentials@v4
         with:
diff --git a/examples/src/main/java/ai/djl/examples/inference/cv/ObjectDetection.java b/examples/src/main/java/ai/djl/examples/inference/cv/ObjectDetection.java
index 287ddb248..1d916302e 100644
--- a/examples/src/main/java/ai/djl/examples/inference/cv/ObjectDetection.java
+++ b/examples/src/main/java/ai/djl/examples/inference/cv/ObjectDetection.java
@@ -57,8 +57,8 @@ public final class ObjectDetection {
                 Criteria.builder()
                         .optApplication(Application.CV.OBJECT_DETECTION)
                         .setTypes(Image.class, DetectedObjects.class)
-                        .optFilter("backbone", "mobilenet_v2")
-                        .optEngine("TensorFlow")
+                        .optArgument("threshold", 0.5)
+                        .optEngine("PyTorch")
                         .optProgress(new ProgressBar())
                         .build();
 


Test patch:
diff --git a/examples/src/test/java/ai/djl/examples/inference/ObjectDetectionTest.java b/examples/src/test/java/ai/djl/examples/inference/ObjectDetectionTest.java
index a1007cc34..076fda3f9 100644
--- a/examples/src/test/java/ai/djl/examples/inference/ObjectDetectionTest.java
+++ b/examples/src/test/java/ai/djl/examples/inference/ObjectDetectionTest.java
@@ -42,7 +42,7 @@ public class ObjectDetectionTest {
         Assert.assertTrue(result.getNumberOfObjects() >= 3);
         Classifications.Classification obj = result.best();
         String className = obj.getClassName();
-        List<String> objects = Arrays.asList("dog", "Cat", "car");
+        List<String> objects = Arrays.asList("dog", "bicycle", "car");
         Assert.assertTrue(objects.contains(className));
         Assert.assertTrue(obj.getProbability() > 0.6);
     }