This repository was archived by the owner on Nov 17, 2023. It is now read-only.
[MXNET-116] Inference - ObjectDetector and SSDObjectDetectorExample#10229
Merged
nswamy merged 6 commits intoapache:masterfrom Mar 24, 2018
Merged
[MXNET-116] Inference - ObjectDetector and SSDObjectDetectorExample#10229nswamy merged 6 commits intoapache:masterfrom
nswamy merged 6 commits intoapache:masterfrom
Conversation
6 tasks
nswamy
suggested changes
Mar 23, 2018
| @@ -0,0 +1,116 @@ | |||
| # Single Shot Multi Object Detection using Scala Inference API | |||
|
|
|||
| In this example, you will learn how to use Scala Inference API to import pre-trained Single Shot Multi Object Detection (SSD) MXNet model. | |||
Member
There was a problem hiding this comment.
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 Scala Inference API to import pre-trained Single Shot Multi Object Detection (SSD) MXNet model. | ||
|
|
||
| The pre-trained 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). |
Member
There was a problem hiding this comment.
The model is trained on the [Pascal VOC 2012 dataset]
| ./get_resnet_data.sh | ||
| ``` | ||
|
|
||
| **Note**: You may need to run `chmod +x get_resnet_data.sh` before running this script. |
Member
There was a problem hiding this comment.
Do you still need this if the file already is set to be a executable?
Also you do not need to chmod+x if you running the script as bash ./get_resnet_data.sh
| 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. | ||
|
|
||
| The signature also specifies `image/jpeg` as the expected input type, since this example's image pre-processor only supports the handling of binary JPEG images. |
|
|
||
| The signature also specifies `image/jpeg` as the expected input type, since this example's image pre-processor only supports the handling of binary JPEG images. | ||
|
|
||
| The signature specifies the output shape is `(1, 6132, 6)`. As with the input, the `1` is the number of images. `6132` is the number of prediction results, and `6` is for the size of each prediction. Each prediction contains the following components: |
|
|
||
|
|
||
| ## 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 BufferedImage and run prediction using Classifier and Predictor APIs. |
Member
There was a problem hiding this comment.
BufferedImage-> Java BufferedImage
| import java.nio.file.{Files, Paths} | ||
|
|
||
| class SSDClassifierExample { | ||
| @Option(name = "--model-dir", usage = "the input model directory and prefix of the model") |
| class ObjectDetector(modelPathPrefix: String, | ||
| inputDescriptors: IndexedSeq[DataDesc]) { | ||
|
|
||
| val classifier: Classifier = getClassifier(modelPathPrefix, inputDescriptors) |
|
|
||
| // Considering 'NCHW' as default layout when not provided | ||
| // Else get axis according to the layout | ||
| val height = inputShape(if (inputLayout.indexOf('H')<0) 2 else inputLayout.indexOf('H')) |
Member
There was a problem hiding this comment.
use these variables from the ImageClassifier.
|
|
||
| val result = objectDetectWithNDArray(IndexedSeq(op), topK) | ||
| handler.execute(op.dispose()) | ||
| for (ele <- imageBatch) { |
342a3b1 to
916d1ab
Compare
nswamy
approved these changes
Mar 23, 2018
ashokei
pushed a commit
to ashokei/incubator-mxnet
that referenced
this pull request
Mar 27, 2018
…pache#10229) * Inference - ObjectDetector and SSDObjectDetectorExample
jinhuang415
pushed a commit
to jinhuang415/incubator-mxnet
that referenced
this pull request
Mar 30, 2018
…pache#10229) * Inference - ObjectDetector and SSDObjectDetectorExample
rahul003
pushed a commit
to rahul003/mxnet
that referenced
this pull request
Jun 4, 2018
…pache#10229) * Inference - ObjectDetector and SSDObjectDetectorExample
zheng-da
pushed a commit
to zheng-da/incubator-mxnet
that referenced
this pull request
Jun 28, 2018
…pache#10229) * Inference - ObjectDetector and SSDObjectDetectorExample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add Object Detection Class for MXNet Inference API, also add test and example to it. This code is fully tested with SSD model.
@Roshrini @nswamy @aaronmarkham
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes