lanking520 commented on a change in pull request #10179: [MXNET-116] object detector class added URL: https://github.com/apache/incubator-mxnet/pull/10179#discussion_r176233141
########## File path: scala-package/infer/src/main/scala/ml/dmlc/mxnet/infer/ObjectDetector.scala ########## @@ -0,0 +1,151 @@ +/* + * 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 +// scalastyle:off +import java.awt.image.BufferedImage +// scalastyle:on +import ml.dmlc.mxnet.NDArray +import ml.dmlc.mxnet.DataDesc +import scala.collection.mutable.ListBuffer +/** + * A class for object detection tasks + * + * @param modelPathPrefix PathPrefix from where to load the symbol, parameters and synset.txt + * Example: file://model-dir/ssd_resnet50_512 + * (will resolve both ssd_resnet50_512-symbol.json and ssd_resnet50_512-0000.params) + * file://model-dir/synset.txt + * @param inputDescriptors Descriptors defining the input node names, shape, + * layout and Type parameters + */ +class ObjectDetector(modelPathPrefix: String, + inputDescriptors: IndexedSeq[DataDesc]) + extends Classifier(modelPathPrefix: String, + inputDescriptors: IndexedSeq[DataDesc]) {1 + + val classifier: Classifier = getClassifier(modelPathPrefix, inputDescriptors) + + val inputLayout = inputDescriptors(0).layout + + val inputShape = inputDescriptors(0).shape + + // Considering 'NCHW' as default layout when not provided + // Else get axis according to the layout + val batch = inputShape(if (inputLayout.indexOf('N')<0) 0 else inputLayout.indexOf('N')) Review comment: I think that one is the ImageClassifier part, this is ObjectDetector, we need to do this part again. Will force user input CHW ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services