Skip to content

Commit

Permalink
[onnx] Adds yolov8n to model zoo (#2909)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Apr 26, 2024
1 parent aa5fcf2 commit 1e1829f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class OrtModelZoo extends ModelZoo {
OrtModelZoo() {
addModel(REPOSITORY.model(CV.IMAGE_CLASSIFICATION, GROUP_ID, "resnet", "0.0.1"));
addModel(REPOSITORY.model(CV.OBJECT_DETECTION, GROUP_ID, "yolo5s", "0.0.1"));
addModel(REPOSITORY.model(CV.OBJECT_DETECTION, GROUP_ID, "yolov8n", "0.0.1"));
addModel(REPOSITORY.model(Tabular.SOFTMAX_REGRESSION, GROUP_ID, "iris_flowers", "0.0.1"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"metadataVersion": "0.2",
"resourceType": "model",
"application": "cv/object_detection",
"groupId": "ai.djl.onnxruntime",
"artifactId": "yolov8n",
"name": "yolov8n",
"description": "YoloV8 Model",
"website": "http://www.djl.ai/engines/onnxruntime/model-zoo",
"licenses": {
"license": {
"name": "The Apache License, Version 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
}
},
"artifacts": [
{
"version": "0.0.1",
"snapshot": false,
"name": "yolov8n",
"arguments": {
"width": 640,
"height": 640,
"resize": true,
"rescale": true,
"optApplyRatio": true,
"threshold": 0.6,
"translatorFactory": "ai.djl.modality.cv.translator.YoloV8TranslatorFactory"
},
"files": {
"model": {
"uri": "0.0.1/yolov8n.zip",
"name": "",
"sha1Hash": "9fbad7f706713843cbb8c8d6a56c81a640ec6fa2",
"size": 11053839
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ public static void main(String[] args) throws IOException, ModelException, Trans
}

public static DetectedObjects predict() throws IOException, ModelException, TranslateException {
Path modelPath = Paths.get("src/test/resources/yolov8n.onnx");
Path imgPath = Paths.get("src/test/resources/yolov8_test.jpg");
Image img = ImageFactory.getInstance().fromFile(imgPath);

Criteria<Image, DetectedObjects> criteria =
Criteria.builder()
.setTypes(Image.class, DetectedObjects.class)
.optModelPath(modelPath)
.optModelUrls("djl://ai.djl.onnxruntime/yolov8n")
.optEngine("OnnxRuntime")
.optArgument("width", 640)
.optArgument("height", 640)
Expand All @@ -63,7 +62,6 @@ public static DetectedObjects predict() throws IOException, ModelException, Tran
// for performance optimization maxBox parameter can reduce number of
// considered boxes from 8400
.optArgument("maxBox", 1000)
.optArgument("synsetFileName", "yolov8_synset.txt")
.optTranslatorFactory(new YoloV8TranslatorFactory())
.optProgress(new ProgressBar())
.build();
Expand Down

0 comments on commit 1e1829f

Please sign in to comment.