From c08b7862206a6520d1339554621686c14ee7ac5d Mon Sep 17 00:00:00 2001 From: Ayres Date: Thu, 20 Dec 2018 22:22:40 -0800 Subject: [PATCH] Added javadocs and improved example instructions --- .../javaapi/infer/objectdetector/README.md | 8 ++-- .../infer/javaapi/ObjectDetectorOutput.scala | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/README.md b/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/README.md index 681253f39a88..55741024d08b 100644 --- a/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/README.md +++ b/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/README.md @@ -17,8 +17,8 @@ The model is trained on the [Pascal VOC 2012 dataset](http://host.robots.ox.ac.u ## Prerequisites -1. MXNet -2. MXNet Scala Package +1. [Build MXNet](http://mxnet.incubator.apache.org/install/scala_setup.html) +2. [Build MXNet Scala/Java Package](http://mxnet.incubator.apache.org/install/scala_setup.html) 3. [IntelliJ IDE (or alternative IDE) project setup](http://mxnet.incubator.apache.org/tutorials/java/mxnet_java_on_intellij.html) with the MXNet Scala/Java Package 4. wget @@ -64,10 +64,10 @@ The followings is the parameters defined for this example, you can find more inf ## How to Run Inference After the previous steps, you should be able to run the code using the following script that will pass all of the required parameters to the Infer API. -From the `scala-package/examples/scripts/inferexample/objectdetector/` folder run: +From the `scala-package/examples/scripts/infer/objectdetector/` folder run: ```bash -./run_ssd_example.sh ../models/resnet50_ssd/resnet50_ssd/resnet50_ssd_model ../images/dog.jpg ../images +./run_ssd_example.sh ../models/resnet50_ssd/resnet50_ssd_model ../images/dog.jpg ../images ``` **Notes**: diff --git a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetectorOutput.scala b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetectorOutput.scala index 13369c8fcef5..5a6ac7599fa9 100644 --- a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetectorOutput.scala +++ b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetectorOutput.scala @@ -17,18 +17,55 @@ package org.apache.mxnet.infer.javaapi +/** + * The ObjectDetectorOutput class is a simple POJO helper class that is used to simplify + * the interactions with ObjectDetector predict results. The class stores the bounding box + * coordinates, name of preicted class, and the probability. + */ + + class ObjectDetectorOutput (className: String, args: Array[Float]){ + /** + * Gets the predicted class's name. + * + * @return String representing the name of the predicted class + */ def getClassName: String = className + /** + * Gets the probability of the predicted class. + * + * @return Float representing the probability of predicted class + */ def getProbability: Float = args(0) + /** + * Gets the minimum X coordinate for the bounding box containing the predicted object. + * + * @return Float of the min X coordinate for the object bounding box + */ def getXMin: Float = args(1) + /** + * Gets the maximum X coordinate for the bounding box containing the predicted object. + * + * @return Float of the max X coordinate for the object bounding box + */ def getXMax: Float = args(2) + /** + * Gets the minimum Y coordinate for the bounding box containing the predicted object. + * + * @return Float of the min Y coordinate for the object bounding box + */ def getYMin: Float = args(3) + /** + * Gets the maximum Y coordinate for the bounding box containing the predicted object. + * + * @return Float of the max Y coordinate for the object bounding box + */ def getYMax: Float = args(4) }