-
-
Save vrakesh/0faacec9e9f8d88c4cb96c8ae812493a to your computer and use it in GitHub Desktop.
SSD Inference example in Joule
This file contains 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
import ai.djl.modality.cv.DetectedObjects; | |
import ai.djl.modality.cv.ImageVisualization; | |
import ai.djl.modality.cv.util.BufferedImageUtils; | |
import ai.djl.mxnet.zoo.MxModelZoo; | |
import ai.djl.repository.zoo.ZooModel; | |
import ai.djl.training.util.ProgressBar; | |
import javax.imageio.ImageIO; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
public class SimpleSSDExample { | |
public static void main(String[] args) throws Exception{ | |
// Get image file path | |
BufferedImage img = BufferedImageUtils | |
.fromUrl("https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/pose/soccer.png"); | |
//Get resnet model from model zoo. | |
ZooModel<BufferedImage, DetectedObjects> model = | |
MxModelZoo.SSD.loadModel(new ProgressBar()); | |
//Create a new predictor from model and predict on image. | |
DetectedObjects predictResult = model.newPredictor().predict(img); | |
// Draw Bounding boxes on image | |
ImageVisualization.drawBoundingBoxes(img, predictResult); | |
//Save result | |
ImageIO.write(img, "png", new File("ssd.png")); | |
model.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import ai.djl.modality.cv.DetectedObjects;
import ai.djl.modality.cv.ImageVisualization;
import ai.djl.modality.cv.util.BufferedImageUtils;
import ai.djl.mxnet.zoo.MxModelZoo;
import ai.djl.repository.zoo.ZooModel;
import ai.djl.training.util.ProgressBar;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public final class SimpleSSDExample {
}