nswamy commented on a change in pull request #12848: Fix Batch input issue with 
Scala Benchmark
URL: https://github.com/apache/incubator-mxnet/pull/12848#discussion_r226799645
 
 

 ##########
 File path: 
scala-package/infer/src/main/scala/org/apache/mxnet/infer/ObjectDetector.scala
 ##########
 @@ -147,13 +150,16 @@ class ObjectDetector(modelPathPrefix: String,
   def imageBatchObjectDetect(inputBatch: Traversable[BufferedImage], topK: 
Option[Int] = None):
   IndexedSeq[IndexedSeq[(String, Array[Float])]] = {
 
-    val imageBatch = ListBuffer[NDArray]()
-    for (image <- inputBatch) {
-      val scaledImage = ImageClassifier.reshapeImage(image, width, height)
-      val pixelsNdarray = ImageClassifier.bufferedImageToPixels(scaledImage, 
inputShape)
-      imageBatch += pixelsNdarray
-    }
-    val op = NDArray.concatenate(imageBatch)
+    val inputBatchSeq = inputBatch.toIndexedSeq
+    val imageBatch = inputBatchSeq.indices.par.map(idx => {
+      val scaledImage = ImageClassifier.reshapeImage(inputBatchSeq(idx), 
width, height)
 
 Review comment:
   we should parallelize this method using threads - you can create a JIRA for 
it and pick up whenever time permits

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to