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 2019/02/15 23:20:00 UTC

[GitHub] andrewfayres opened a new issue #14181: Scala Infer ObjectDector crashes on models which don't return

andrewfayres opened a new issue #14181: Scala Infer ObjectDector crashes on models which don't return
URL: https://github.com/apache/incubator-mxnet/issues/14181
 
 
   ## Description
   The Scala Infer API's ObjectDetector will crash when provided with a model which doesn't return coordinates for bounding boxes. We should handle this situation more gracefully. Either return an error message stating that the model doesn't have the required outputs or return the results without the bounding boxes.
   
   ## Error Message:
   ```
   $ ./bin/run_det.sh
   SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
   SLF4J: Defaulting to no-operation (NOP) logger implementation
   SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
   [22:18:13] src/nnvm/legacy_json_util.cc:209: Loading symbol saved by previous version v1.3.1. Attempting to upgrade...
   [22:18:13] src/nnvm/legacy_json_util.cc:217: Symbol successfully upgraded!
   [22:18:17] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running performance tests to find the best convolution algorithm, this can take a while... (setting env variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
   Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
       at org.apache.mxnet.infer.ObjectDetector$$anonfun$2.apply(ObjectDetector.scala:132)
       at org.apache.mxnet.infer.ObjectDetector$$anonfun$2.apply(ObjectDetector.scala:132)
       at scala.math.Ordering$$anon$5.compare(Ordering.scala:122)
       at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
       at java.util.TimSort.sort(TimSort.java:234)
       at java.util.Arrays.sort(Arrays.java:1438)
       at scala.collection.SeqLike$class.sorted(SeqLike.scala:648)
       at scala.collection.mutable.ArrayOps$ofRef.sorted(ArrayOps.scala:186)
       at scala.collection.SeqLike$class.sortBy(SeqLike.scala:623)
       at scala.collection.mutable.ArrayOps$ofRef.sortBy(ArrayOps.scala:186)
       at org.apache.mxnet.infer.ObjectDetector.sortAndReformat(ObjectDetector.scala:132)
       at org.apache.mxnet.infer.ObjectDetector$$anonfun$objectDetectWithNDArray$1.apply$mcVI$sp(ObjectDetector.scala:106)
       at org.apache.mxnet.infer.ObjectDetector$$anonfun$objectDetectWithNDArray$1.apply(ObjectDetector.scala:104)
       at org.apache.mxnet.infer.ObjectDetector$$anonfun$objectDetectWithNDArray$1.apply(ObjectDetector.scala:104)
       at scala.collection.parallel.mutable.ParArray$ParArrayIterator.foreach_quick(ParArray.scala:143)
       at scala.collection.parallel.mutable.ParArray$ParArrayIterator.foreach(ParArray.scala:136)
       at scala.collection.parallel.ParIterableLike$Foreach.leaf(ParIterableLike.scala:972)
       at scala.collection.parallel.Task$$anonfun$tryLeaf$1.apply$mcV$sp(Tasks.scala:49)
       at scala.collection.parallel.Task$$anonfun$tryLeaf$1.apply(Tasks.scala:48)
       at scala.collection.parallel.Task$$anonfun$tryLeaf$1.apply(Tasks.scala:48)
       at scala.collection.parallel.Task$class.tryLeaf(Tasks.scala:51)
       at scala.collection.parallel.ParIterableLike$Foreach.tryLeaf(ParIterableLike.scala:969)
       at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.compute(Tasks.scala:152)
       at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.compute(Tasks.scala:443)
       at scala.concurrent.forkjoin.RecursiveAction.exec(RecursiveAction.java:160)
       at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
       at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
       at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
       at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
   ```
   
   ## Minimum reproducible example
   ```
       public static void main(String[] args) {
           String modelPathPrefix = "./resnet-152";
           String inputImagePath = "./cat.jpg";
   
           List<Context> context = new ArrayList<Context>();
           context.add(Context.gpu());
   
           // Prepare the model                                                                                                                          
           List<DataDesc> inputDesc = new ArrayList<>();
           Shape inputShape = new Shape(new int[]{1, 3, 224, 224});
           inputDesc.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
           ObjectDetector objDet = new ObjectDetector(modelPathPrefix, inputDesc, context, 0);
   
           // predict                                                                                                                                    
           int iter = 100;
           ArrayList<Double> data = new ArrayList<Double>(iter);
           for(int i=0; i<iter; i++) {
               // Prepare data                                                                                                                           
               BufferedImage img = ObjectDetector.loadImageFromFile(inputImagePath);
   
               long start = System.nanoTime();
               List<List<ObjectDetectorOutput>> result = objDet.imageObjectDetect(img,3);
               long stop = System.nanoTime();
   
               double elapsed = (stop-start)/1000000.0;
               data.add(elapsed);
           }
   ```
   
   ## Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1. Download resnet-152 model
   2. Run above code calling ObjectDetector (above code is Java and call the Java API but error is in the Scala layer)
   

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