You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/11/15 01:51:26 UTC

[GitHub] nswamy closed pull request #13277: Addressing PR feedback for merging Java API into master

nswamy closed pull request #13277: Addressing PR feedback for merging Java API into master
URL: https://github.com/apache/incubator-mxnet/pull/13277
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Context.scala b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Context.scala
index ac3517b151f..d2d9b27ada9 100644
--- a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Context.scala
+++ b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Context.scala
@@ -25,7 +25,7 @@ import collection.JavaConverters._
   * @param deviceTypeName {'cpu', 'gpu'} String representing the device type
   * @param deviceId The device id of the device, needed for GPU
   */
-class Context(val context: org.apache.mxnet.Context) {
+class Context private[mxnet] (val context: org.apache.mxnet.Context) {
 
   val deviceTypeid: Int = context.deviceTypeid
 
diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/IO.scala b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/IO.scala
index bf961b2bd52..6ba355d6510 100644
--- a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/IO.scala
+++ b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/IO.scala
@@ -17,7 +17,7 @@
 
 package org.apache.mxnet.javaapi
 
-class DataDesc(val dataDesc: org.apache.mxnet.DataDesc) {
+class DataDesc private[mxnet] (val dataDesc: org.apache.mxnet.DataDesc) {
 
   def this(name: String, shape: Shape, dType: DType.DType, layout: String) =
     this(new org.apache.mxnet.DataDesc(name, shape, dType, layout))
diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/NDArray.scala b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/NDArray.scala
index cdcc292ada6..446df257e20 100644
--- a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/NDArray.scala
+++ b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/NDArray.scala
@@ -198,7 +198,7 @@ object NDArray extends NDArrayBase {
   * will result in leaking native memory.
   * </b>
   */
-class NDArray(val nd : org.apache.mxnet.NDArray ) {
+class NDArray private[mxnet] (val nd : org.apache.mxnet.NDArray ) {
 
   def this(arr : Array[Float], shape : Shape, ctx : Context) = {
     this(org.apache.mxnet.NDArray.array(arr, shape, ctx))
diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Shape.scala b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Shape.scala
index 594e3a60578..9ed45e8d677 100644
--- a/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Shape.scala
+++ b/scala-package/core/src/main/scala/org/apache/mxnet/javaapi/Shape.scala
@@ -23,7 +23,7 @@ import collection.JavaConverters._
   * Shape of [[NDArray]] or other data
   */
 
-class Shape(val shape: org.apache.mxnet.Shape) {
+class Shape private[mxnet] (val shape: org.apache.mxnet.Shape) {
   def this(dims: java.util.List[java.lang.Integer])
     = this(new org.apache.mxnet.Shape(dims.asScala.map(Int.unbox)))
   def this(dims: Array[Int]) = this(new org.apache.mxnet.Shape(dims))
diff --git a/scala-package/examples/scripts/infer/objectdetector/run_ssd_example.sh b/scala-package/examples/scripts/infer/objectdetector/run_ssd_example.sh
index adb8830de06..6b4edb7c4c9 100755
--- a/scala-package/examples/scripts/infer/objectdetector/run_ssd_example.sh
+++ b/scala-package/examples/scripts/infer/objectdetector/run_ssd_example.sh
@@ -18,7 +18,7 @@
 # under the License.
 
 hw_type=cpu
-if [[ $1 = gpu ]]
+if [[ $4 = gpu ]]
 then
     hw_type=gpu
 fi
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 63b9f929a82..681253f39a8 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
@@ -1,6 +1,6 @@
-# Single Shot Multi Object Detection using Scala Inference API
+# Single Shot Multi Object Detection using Java Inference API
 
-In this example, you will learn how to use Scala Inference API to run Inference on pre-trained Single Shot Multi Object Detection (SSD) MXNet model.
+In this example, you will learn how to use Java Inference API to run Inference on pre-trained Single Shot Multi Object Detection (SSD) MXNet model.
 
 The model is trained on the [Pascal VOC 2012 dataset](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html). The network is a SSD model built on Resnet50 as base network to extract image features. The model is trained to detect the following entities (classes): ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor']. For more details about the model, you can refer to the [MXNet SSD example](https://github.com/apache/incubator-mxnet/tree/master/example/ssd).
 
@@ -19,7 +19,7 @@ The model is trained on the [Pascal VOC 2012 dataset](http://host.robots.ox.ac.u
 
 1. MXNet
 2. MXNet Scala Package
-3. [IntelliJ IDE (or alternative IDE) project setup](http://mxnet.incubator.apache.org/tutorials/scala/mxnet_scala_on_intellij.html) with the MXNet Scala Package
+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
 
 
@@ -28,18 +28,13 @@ The model is trained on the [Pascal VOC 2012 dataset](http://host.robots.ox.ac.u
 ### Download Artifacts
 #### Step 1
 You can download the files using the script `get_ssd_data.sh`. It will download and place the model files in a `model` folder and the test image files in a `image` folder in the current directory.
-From the `scala-package/examples/scripts/infer/imageclassifier/` folder run:
+From the `scala-package/examples/scripts/infer/objectdetector/` folder run:
 
 ```bash
 ./get_ssd_data.sh
 ```
 
-**Note**: You may need to run `chmod +x get_resnet_data.sh` before running this script.
-
-Alternatively use the following links to download the Symbol and Params files via your browser:
-- [resnet50_ssd_model-symbol.json](https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-symbol.json)
-- [resnet50_ssd_model-0000.params](https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-0000.params)
-- [synset.txt](https://github.com/awslabs/mxnet-model-server/blob/master/examples/ssd/synset.txt)
+**Note**: You may need to run `chmod +x get_ssd_data.sh` before running this script.
 
 In the pre-trained model, the `input_name` is `data` and shape is `(1, 3, 512, 512)`.
 This shape translates to: a batch of `1` image, the image has color and uses `3` channels (RGB), and the image has the dimensions of `512` pixels in height by `512` pixels in width.
@@ -57,13 +52,6 @@ The output shape is `(1, 6132, 6)`. As with the input, the `1` is the number of
 
 ### Setup Datapath and Parameters
 #### Step 2
-The code `Line 31: val baseDir = System.getProperty("user.dir")` in the example will automatically searches the work directory you have defined. Please put the files in your [work directory](https://stackoverflow.com/questions/16239130/java-user-dir-property-what-exactly-does-it-mean). <!-- how do you define the work directory? -->
-
-Alternatively, if you would like to use your own path, please change line 31 into your own path
-```scala
-val baseDir = <Your Own Path>
-```
-
 The followings is the parameters defined for this example, you can find more information in the `class SSDClassifierExample`.
 
 | Argument                      | Comments                                 |
@@ -102,15 +90,8 @@ the outputs come from the the input image, with top3 predictions picked.
 
 
 ## Infer API Details
-This example uses ObjectDetector class provided by MXNet's scala package Infer APIs. It provides methods to load the images, create NDArray out of Java BufferedImage and run prediction using Classifier and Predictor APIs.
+This example uses ObjectDetector class provided by MXNet's Java Infer APIs. It provides methods to load the images, create NDArray out of Java BufferedImage and run prediction using Classifier and Predictor APIs.
 
 
 ## References
 This documentation used the model and inference setup guide from the [MXNet Model Server SSD example](https://github.com/awslabs/mxnet-model-server/blob/master/examples/ssd/README.md).
-
-
-## Next Steps
-
-Check out the following related tutorials and examples for the Infer API:
-
-* [Image Classification with the MXNet Scala Infer API](../imageclassifier/README.md)
diff --git a/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/SSDClassifierExample.java b/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/SSDClassifierExample.java
index 4befc8edde6..a9c00f7f1d8 100644
--- a/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/SSDClassifierExample.java
+++ b/scala-package/examples/src/main/java/org/apache/mxnetexamples/javaapi/infer/objectdetector/SSDClassifierExample.java
@@ -38,162 +38,162 @@
 import java.io.File;
 
 public class SSDClassifierExample {
-	@Option(name = "--model-path-prefix", usage = "input model directory and prefix of the model")
-	private String modelPathPrefix = "/model/ssd_resnet50_512";
-	@Option(name = "--input-image", usage = "the input image")
-	private String inputImagePath = "/images/dog.jpg";
-	@Option(name = "--input-dir", usage = "the input batch of images directory")
-	private String inputImageDir = "/images/";
-	
-	final static Logger logger = LoggerFactory.getLogger(SSDClassifierExample.class);
-	
-	static List<List<ObjectDetectorOutput>>
-	runObjectDetectionSingle(String modelPathPrefix, String inputImagePath, List<Context> context) {
-		Shape inputShape = new Shape(new int[] {1, 3, 512, 512});
-		List<DataDesc> inputDescriptors = new ArrayList<DataDesc>();
-		inputDescriptors.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
-		BufferedImage img = ObjectDetector.loadImageFromFile(inputImagePath);
-		ObjectDetector objDet = new ObjectDetector(modelPathPrefix, inputDescriptors, context, 0);
-		return objDet.imageObjectDetect(img, 3);
-	}
-	
-	static List<List<List<ObjectDetectorOutput>>>
-	runObjectDetectionBatch(String modelPathPrefix, String inputImageDir, List<Context> context) {
-		Shape inputShape = new Shape(new int[]{1, 3, 512, 512});
-		List<DataDesc> inputDescriptors = new ArrayList<DataDesc>();
-		inputDescriptors.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
-		ObjectDetector objDet = new ObjectDetector(modelPathPrefix, inputDescriptors, context, 0);
-		
-		// Loading batch of images from the directory path
-		List<List<String>> batchFiles = generateBatches(inputImageDir, 20);
-		List<List<List<ObjectDetectorOutput>>> outputList
-				= new ArrayList<List<List<ObjectDetectorOutput>>>();
-		
-		for (List<String> batchFile : batchFiles) {
-			List<BufferedImage> imgList = ObjectDetector.loadInputBatch(batchFile);
-			// Running inference on batch of images loaded in previous step
-			List<List<ObjectDetectorOutput>> tmp
-					= objDet.imageBatchObjectDetect(imgList, 5);
-			outputList.add(tmp);
-		}
-		return outputList;
-	}
-	
-	static List<List<String>> generateBatches(String inputImageDirPath, int batchSize) {
-		File dir = new File(inputImageDirPath);
-
-		List<List<String>> output = new ArrayList<List<String>>();
-		List<String> batch = new ArrayList<String>();
-		for (File imgFile : dir.listFiles()) {
-			batch.add(imgFile.getPath());
-			if (batch.size() == batchSize) {
-				output.add(batch);
-				batch = new ArrayList<String>();
-			}
-		}
-		if (batch.size() > 0) {
-			output.add(batch);
-		}
-		return output;
-	}
-	
-	public static void main(String[] args) {
-		SSDClassifierExample inst = new SSDClassifierExample();
-		CmdLineParser parser  = new CmdLineParser(inst);
-		try {
-			parser.parseArgument(args);
-		} catch (Exception e) {
-			logger.error(e.getMessage(), e);
-			parser.printUsage(System.err);
-			System.exit(1);
-		}
-		
-		String mdprefixDir = inst.modelPathPrefix;
-		String imgPath = inst.inputImagePath;
-		String imgDir = inst.inputImageDir;
-		
-		if (!checkExist(Arrays.asList(mdprefixDir + "-symbol.json", imgDir, imgPath))) {
-			logger.error("Model or input image path does not exist");
-			System.exit(1);
-		}
-		
-		List<Context> context = new ArrayList<Context>();
-		if (System.getenv().containsKey("SCALA_TEST_ON_GPU") &&
-				Integer.valueOf(System.getenv("SCALA_TEST_ON_GPU")) == 1) {
-			context.add(Context.gpu());
-		} else {
-			context.add(Context.cpu());
-		}
-		
-		try {
-			Shape inputShape = new Shape(new int[] {1, 3, 512, 512});
-			Shape outputShape = new Shape(new int[] {1, 6132, 6});
-			
-			
-			int width = inputShape.get(2);
-			int height = inputShape.get(3);
-			String outputStr = "\n";
-			
-			List<List<ObjectDetectorOutput>> output
-					= runObjectDetectionSingle(mdprefixDir, imgPath, context);
-			
-			for (List<ObjectDetectorOutput> ele : output) {
-				for (ObjectDetectorOutput i : ele) {
-					outputStr += "Class: " + i.getClassName() + "\n";
-					outputStr += "Probabilties: " + i.getProbability() + "\n";
-					
-					List<Float> coord = Arrays.asList(i.getXMin() * width,
-							i.getXMax() * height, i.getYMin() * width, i.getYMax() * height);
-					StringBuilder sb = new StringBuilder();
-					for (float c: coord) {
-						sb.append(", ").append(c);
-					}
-					outputStr += "Coord:" + sb.substring(2)+ "\n";
-				}
-			}
-			logger.info(outputStr);
-			
-			List<List<List<ObjectDetectorOutput>>> outputList =
-					runObjectDetectionBatch(mdprefixDir, imgDir, context);
-			
-			outputStr = "\n";
-			int index = 0;
-			for (List<List<ObjectDetectorOutput>> i: outputList) {
-				for (List<ObjectDetectorOutput> j : i) {
-					outputStr += "*** Image " + (index + 1) + "***" + "\n";
-					for (ObjectDetectorOutput k : j) {
-						outputStr += "Class: " + k.getClassName() + "\n";
-						outputStr += "Probabilties: " + k.getProbability() + "\n";
-						List<Float> coord = Arrays.asList(k.getXMin() * width,
-								k.getXMax() * height, k.getYMin() * width, k.getYMax() * height);
-						
-						StringBuilder sb = new StringBuilder();
-						for (float c : coord) {
-							sb.append(", ").append(c);
-						}
-						outputStr += "Coord:" + sb.substring(2) + "\n";
-					}
-					index++;
-				}
-			}
-			logger.info(outputStr);
-			
-		} catch (Exception e) {
-			logger.error(e.getMessage(), e);
-			parser.printUsage(System.err);
-			System.exit(1);
-		}
-		System.exit(0);
-	}
-	
-	static Boolean checkExist(List<String> arr)  {
-		Boolean exist = true;
-		for (String item : arr) {
-			exist = new File(item).exists() && exist;
-			if (!exist) {
-				logger.error("Cannot find: " + item);
-			}
-		}
-		return exist;
-	}
+    @Option(name = "--model-path-prefix", usage = "input model directory and prefix of the model")
+    private String modelPathPrefix = "/model/ssd_resnet50_512";
+    @Option(name = "--input-image", usage = "the input image")
+    private String inputImagePath = "/images/dog.jpg";
+    @Option(name = "--input-dir", usage = "the input batch of images directory")
+    private String inputImageDir = "/images/";
+    
+    final static Logger logger = LoggerFactory.getLogger(SSDClassifierExample.class);
+    
+    static List<List<ObjectDetectorOutput>>
+    runObjectDetectionSingle(String modelPathPrefix, String inputImagePath, List<Context> context) {
+        Shape inputShape = new Shape(new int[]{1, 3, 512, 512});
+        List<DataDesc> inputDescriptors = new ArrayList<DataDesc>();
+        inputDescriptors.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
+        BufferedImage img = ObjectDetector.loadImageFromFile(inputImagePath);
+        ObjectDetector objDet = new ObjectDetector(modelPathPrefix, inputDescriptors, context, 0);
+        return objDet.imageObjectDetect(img, 3);
+    }
+    
+    static List<List<List<ObjectDetectorOutput>>>
+    runObjectDetectionBatch(String modelPathPrefix, String inputImageDir, List<Context> context) {
+        Shape inputShape = new Shape(new int[]{1, 3, 512, 512});
+        List<DataDesc> inputDescriptors = new ArrayList<DataDesc>();
+        inputDescriptors.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
+        ObjectDetector objDet = new ObjectDetector(modelPathPrefix, inputDescriptors, context, 0);
+        
+        // Loading batch of images from the directory path
+        List<List<String>> batchFiles = generateBatches(inputImageDir, 20);
+        List<List<List<ObjectDetectorOutput>>> outputList
+                = new ArrayList<List<List<ObjectDetectorOutput>>>();
+        
+        for (List<String> batchFile : batchFiles) {
+            List<BufferedImage> imgList = ObjectDetector.loadInputBatch(batchFile);
+            // Running inference on batch of images loaded in previous step
+            List<List<ObjectDetectorOutput>> tmp
+                    = objDet.imageBatchObjectDetect(imgList, 5);
+            outputList.add(tmp);
+        }
+        return outputList;
+    }
+    
+    static List<List<String>> generateBatches(String inputImageDirPath, int batchSize) {
+        File dir = new File(inputImageDirPath);
+        
+        List<List<String>> output = new ArrayList<List<String>>();
+        List<String> batch = new ArrayList<String>();
+        for (File imgFile : dir.listFiles()) {
+            batch.add(imgFile.getPath());
+            if (batch.size() == batchSize) {
+                output.add(batch);
+                batch = new ArrayList<String>();
+            }
+        }
+        if (batch.size() > 0) {
+            output.add(batch);
+        }
+        return output;
+    }
+    
+    public static void main(String[] args) {
+        SSDClassifierExample inst = new SSDClassifierExample();
+        CmdLineParser parser = new CmdLineParser(inst);
+        try {
+            parser.parseArgument(args);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            parser.printUsage(System.err);
+            System.exit(1);
+        }
+        
+        String mdprefixDir = inst.modelPathPrefix;
+        String imgPath = inst.inputImagePath;
+        String imgDir = inst.inputImageDir;
+        
+        if (!checkExist(Arrays.asList(mdprefixDir + "-symbol.json", imgDir, imgPath))) {
+            logger.error("Model or input image path does not exist");
+            System.exit(1);
+        }
+        
+        List<Context> context = new ArrayList<Context>();
+        if (System.getenv().containsKey("SCALA_TEST_ON_GPU") &&
+                Integer.valueOf(System.getenv("SCALA_TEST_ON_GPU")) == 1) {
+            context.add(Context.gpu());
+        } else {
+            context.add(Context.cpu());
+        }
+        
+        try {
+            Shape inputShape = new Shape(new int[]{1, 3, 512, 512});
+            Shape outputShape = new Shape(new int[]{1, 6132, 6});
+            
+            
+            int width = inputShape.get(2);
+            int height = inputShape.get(3);
+            StringBuilder outputStr = new StringBuilder().append("\n");
+            
+            List<List<ObjectDetectorOutput>> output
+                    = runObjectDetectionSingle(mdprefixDir, imgPath, context);
+            
+            for (List<ObjectDetectorOutput> ele : output) {
+                for (ObjectDetectorOutput i : ele) {
+                    outputStr.append("Class: " + i.getClassName() + "\n");
+                    outputStr.append("Probabilties: " + i.getProbability() + "\n");
+                    
+                    List<Float> coord = Arrays.asList(i.getXMin() * width,
+                            i.getXMax() * height, i.getYMin() * width, i.getYMax() * height);
+                    StringBuilder sb = new StringBuilder();
+                    for (float c : coord) {
+                        sb.append(", ").append(c);
+                    }
+                    outputStr.append("Coord:" + sb.substring(2) + "\n");
+                }
+            }
+            logger.info(outputStr.toString());
+            
+            List<List<List<ObjectDetectorOutput>>> outputList =
+                    runObjectDetectionBatch(mdprefixDir, imgDir, context);
+            
+            outputStr = new StringBuilder().append("\n");
+            int index = 0;
+            for (List<List<ObjectDetectorOutput>> i : outputList) {
+                for (List<ObjectDetectorOutput> j : i) {
+                    outputStr.append("*** Image " + (index + 1) + "***" + "\n");
+                    for (ObjectDetectorOutput k : j) {
+                        outputStr.append("Class: " + k.getClassName() + "\n");
+                        outputStr.append("Probabilties: " + k.getProbability() + "\n");
+                        List<Float> coord = Arrays.asList(k.getXMin() * width,
+                                k.getXMax() * height, k.getYMin() * width, k.getYMax() * height);
+                        
+                        StringBuilder sb = new StringBuilder();
+                        for (float c : coord) {
+                            sb.append(", ").append(c);
+                        }
+                        outputStr.append("Coord:" + sb.substring(2) + "\n");
+                    }
+                    index++;
+                }
+            }
+            logger.info(outputStr.toString());
+            
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            parser.printUsage(System.err);
+            System.exit(1);
+        }
+        System.exit(0);
+    }
+    
+    static Boolean checkExist(List<String> arr) {
+        Boolean exist = true;
+        for (String item : arr) {
+            if (!(new File(item).exists())) {
+                logger.error("Cannot find: " + item);
+                exist = false;
+            }
+        }
+        return exist;
+    }
 }
diff --git a/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/README.md b/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/README.md
index bf4a44a76d0..77aec7bb5de 100644
--- a/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/README.md
+++ b/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/README.md
@@ -28,18 +28,13 @@ The model is trained on the [Pascal VOC 2012 dataset](http://host.robots.ox.ac.u
 ### Download Artifacts
 #### Step 1
 You can download the files using the script `get_ssd_data.sh`. It will download and place the model files in a `model` folder and the test image files in a `image` folder in the current directory.
-From the `scala-package/examples/scripts/infer/imageclassifier/` folder run:
+From the `scala-package/examples/scripts/infer/objectdetector/` folder run:
 
 ```bash
 ./get_ssd_data.sh
 ```
 
-**Note**: You may need to run `chmod +x get_resnet_data.sh` before running this script.
-
-Alternatively use the following links to download the Symbol and Params files via your browser:
-- [resnet50_ssd_model-symbol.json](https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-symbol.json)
-- [resnet50_ssd_model-0000.params](https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-0000.params)
-- [synset.txt](https://github.com/awslabs/mxnet-model-server/blob/master/examples/ssd/synset.txt)
+**Note**: You may need to run `chmod +x get_ssd_data.sh` before running this script.
 
 In the pre-trained model, the `input_name` is `data` and shape is `(1, 3, 512, 512)`.
 This shape translates to: a batch of `1` image, the image has color and uses `3` channels (RGB), and the image has the dimensions of `512` pixels in height by `512` pixels in width.
@@ -57,13 +52,6 @@ The output shape is `(1, 6132, 6)`. As with the input, the `1` is the number of
 
 ### Setup Datapath and Parameters
 #### Step 2
-The code `Line 31: val baseDir = System.getProperty("user.dir")` in the example will automatically searches the work directory you have defined. Please put the files in your [work directory](https://stackoverflow.com/questions/16239130/java-user-dir-property-what-exactly-does-it-mean). <!-- how do you define the work directory? -->
-
-Alternatively, if you would like to use your own path, please change line 31 into your own path
-```scala
-val baseDir = <Your Own Path>
-```
-
 The followings is the parameters defined for this example, you can find more information in the `class SSDClassifierExample`.
 
 | Argument                      | Comments                                 |
diff --git a/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/SSDClassifierExample.scala b/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/SSDClassifierExample.scala
index f752ef6dab5..07d1cc82e92 100644
--- a/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/SSDClassifierExample.scala
+++ b/scala-package/examples/src/main/scala/org/apache/mxnetexamples/infer/objectdetector/SSDClassifierExample.scala
@@ -182,9 +182,9 @@ object SSDClassifierExample {
   def checkExist(arr : Array[String]) : Boolean = {
     var exist : Boolean = true
     for (item <- arr) {
-      exist = Files.exists(Paths.get(item)) && exist
-      if (!exist) {
+      if (!(Files.exists(Paths.get(item)))) {
         logger.error("Cannot find: " + item)
+        exist = false
       }
     }
     exist
diff --git a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetector.scala b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetector.scala
index 447518b5a89..08fffb410ad 100644
--- a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetector.scala
+++ b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/ObjectDetector.scala
@@ -41,7 +41,7 @@ import scala.collection.JavaConverters._
   *                           Defaults to CPU.
   * @param epoch              Model epoch to load; defaults to 0
   */
-class ObjectDetector(val objDetector: org.apache.mxnet.infer.ObjectDetector){
+class ObjectDetector private[mxnet] (val objDetector: org.apache.mxnet.infer.ObjectDetector){
 
   def this(modelPathPrefix: String, inputDescriptors: java.util.List[DataDesc], contexts:
   java.util.List[Context], epoch: Int)
diff --git a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/Predictor.scala b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/Predictor.scala
index 3e0fcb7b507..21e62b3aa55 100644
--- a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/Predictor.scala
+++ b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi/Predictor.scala
@@ -39,7 +39,7 @@ import scala.collection.JavaConverters._
   */
 
 // JavaDoc description of class to be updated in https://issues.apache.org/jira/browse/MXNET-1178
-class Predictor(val predictor: org.apache.mxnet.infer.Predictor){
+class Predictor private[mxnet] (val predictor: org.apache.mxnet.infer.Predictor){
   def this(modelPathPrefix: String, inputDescriptors: java.util.List[DataDesc],
            contexts: java.util.List[Context], epoch: Int)
   = this {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services