Object Detection API
Analytics Zoo provides a collection of pre-trained models for Object Detection. These models can be used for out-of-the-box inference if you are interested in categories already in the corresponding datasets. According to the business scenarios, users can embed the models locally, distributedly in Apache Spark, Apache Storm or Apache Flink.
Object Detection examples
Analytics Zoo provides two typical kind of pre-trained Object Detection models : SSD and Faster-RCNN on dataset PASCAL and COCO. For the usage of these models, please check below examples.
Scala
It's very easy to apply the model for inference with below code piece.
val model = ObjectDetector.load[Float](params.model)
val data = ImageSet.read(params.image, sc, params.nPartition)
val output = model.predictImageSet(data)
For preprocessors for Object Detection models, please check Object Detection Config
Note: We expect the loaded images has 3 channels. If the channel is not 3(eg, gray/png images), please set imageCodec
when loading images ImageSet.read
. See https://analytics-zoo.github.io/0.1.0/#ProgrammingGuide/object-detection/#object-detection-examples
Users can also do the inference directly using Analytics zoo. Sample code for SSD VGG on PASCAL as below:
val model = ObjectDetector.load[Float](params.model)
val data = ImageSet.read(params.image, sc, params.nPartition)
val preprocessor = Resize(300, 300) ->
ChannelNormalize(123f, 117f, 104f, 1f, 1f, 1f) ->
MatToTensor() -> ImageFrameToSample()
val output = model.predictImageset(data)
Python
It's very easy to apply the model for inference with below code piece.
model = ObjectDetector.load_model(model_path)
image_set = ImageSet.read(img_path, sc)
output = model.predict_image_set(image_set)
User can also define his own configuration to do the inference with below code piece.
model = ObjectDetector.load_model(model_path)
image_set = ImageSet.read(img_path, sc)
preprocessing = ChainedPreprocessing(
[ImageResize(256, 256), ImageCenterCrop(224, 224),
ImageChannelNormalize(123.0, 117.0, 104.0), ImageMatToTensor(),
ImageSetToSample()])
config = ImageConfigure(preprocessing)
output = model.predict_image_set(image_set)
For preprocessors for Object Detection models, please check Object Detection Config
Download link
PASCAL VOC models
- SSD 300x300 MobileNet
- SSD 300x300 VGG
- SSD 300x300 VGG Quantize
- SSD 512x512 VGG
- SSD 512x512 VGG Quantize
- Faster-RCNN VGG
- Faster-RCNN VGG Compress
- Faster-RCNN VGG Compress Quantize
- Faster-RCNN PvaNet
- Faster-RCNN PvaNet Compress
- Faster-RCNN PvaNet Compress Quantize
COCO models