...
Code Block | ||
---|---|---|
| ||
/*
* Psudeocode for how ObjectDetector Class can be used to do SSD detection
* A full working SSD example will be included in the release.
*/
// Set the context to be used
List<Context> context = new ArrayList<Context>();
context.add(Context.cpu());
// Define the shape and data type of the input
Shape inputShape = new Shape(new int[] {1, 3, 512, 512});
List<DataDesc> inputDescriptors = new ArrayList<DataDesc>();
inputDescriptors.add(new DataDesc("data", inputShape, DType.Float32(), "NCHW"));
// Instantiate the object detector with the model, input descriptors, context, and epoch
JavaObjectDetector objDetector = new JavaObjectDetector(modelPathPrefix, inputDescriptors, context, 0);
// Load an image and run inference on it
BufferedImage img = JavaImageClassifier.loadImageFromFile(inputImagePath);
objDetector.imageObjectDetect(img, 3); |
...