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/03/23 16:37:22 UTC

[GitHub] Roshrini commented on a change in pull request #10054: [MXNET-53]Image classifier for scala-infer package

Roshrini commented on a change in pull request #10054: [MXNET-53]Image classifier for scala-infer package
URL: https://github.com/apache/incubator-mxnet/pull/10054#discussion_r176793884
 
 

 ##########
 File path: scala-package/infer/src/test/scala/ml/dmlc/mxnet/infer/ImageClassifierSuite.scala
 ##########
 @@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ml.dmlc.mxnet.infer
+
+import ml.dmlc.mxnet._
+import ml.dmlc.mxnet.{DataDesc, Shape}
+
+import org.mockito.Matchers._
+import org.mockito.Mockito
+import org.scalatest.{BeforeAndAfterAll}
+
+// scalastyle:off
+import java.awt.image.BufferedImage
+// scalastyle:on
+
+/**
+  * Unit tests for ImageClassifier
+  */
+class ImageClassifierSuite extends ClassifierSuite with BeforeAndAfterAll {
+
+  class MyImageClassifier(modelPathPrefix: String,
+                           inputDescriptors: IndexedSeq[DataDesc])
+    extends ImageClassifier(modelPathPrefix, inputDescriptors) {
+
+    override def getPredictor(): MyClassyPredictor = {
+      Mockito.mock(classOf[MyClassyPredictor])
+    }
+
+    override def getClassifier(modelPathPrefix: String, inputDescriptors:
+    IndexedSeq[DataDesc]): Classifier = {
+      Mockito.mock(classOf[Classifier])
+    }
+
+    def getSynset(): IndexedSeq[String] = synset
+  }
+
+  test("ImageClassifierSuite-testRescaleImage") {
+    val image1 = new BufferedImage(100, 200, BufferedImage.TYPE_BYTE_GRAY)
+    val image2 = ImageClassifier.reshapeImage(image1, 1000, 2000)
+
+    assert(image2.getWidth === 1000)
 
 Review comment:
   Python has libraries to do image hashing(imagehash). Getting hash is not that trivial in Java. Will have to implement image hashing function (average_hash)to match the hash.
   
   However, I ran the function "ImageClassifier.reshapeImage" and tested the hash with python if it's resizing correctly or not. It's working as expected. 

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