onnxruntime_ng/download/vision/
object_detection_image_segmentation.rs

1//! Module defining object detection and image segmentation  models available to download.
2//!
3//! See [https://github.com/onnx/models#object_detection](https://github.com/onnx/models#object_detection)
4
5// Acronyms are specific ONNX model names and contains upper cases
6#![allow(clippy::upper_case_acronyms)]
7
8use crate::download::{vision::Vision, AvailableOnnxModel, ModelUrl};
9
10/// Object Detection & Image Segmentation
11///
12/// > Object detection models detect the presence of multiple objects in an image and segment out areas of the
13/// > image where the objects are detected. Semantic segmentation models partition an input image by labeling each pixel
14/// > into a set of pre-defined categories.
15///
16/// Source: [https://github.com/onnx/models#object_detection](https://github.com/onnx/models#object_detection)
17#[derive(Debug, Clone)]
18pub enum ObjectDetectionImageSegmentation {
19    /// A real-time CNN for object detection that detects 20 different classes. A smaller version of the
20    /// more complex full YOLOv2 network.
21    ///
22    /// Variant downloaded: ONNX Version 1.3 with Opset Version 8.
23    TinyYoloV2,
24    /// Single Stage Detector: real-time CNN for object detection that detects 80 different classes.
25    ///
26    /// Variant downloaded: ONNX Version 1.5 with Opset Version 10.
27    Ssd,
28    /// A variant of MobileNet that uses the Single Shot Detector (SSD) model framework. The model detects 80
29    /// different object classes and locates up to 10 objects in an image.
30    ///
31    /// Variant downloaded: ONNX Version 1.7.0 with Opset Version 10.
32    SSDMobileNetV1,
33    /// Increases efficiency from R-CNN by connecting a RPN with a CNN to create a single, unified network for
34    /// object detection that detects 80 different classes.
35    ///
36    /// Variant downloaded: ONNX Version 1.5 with Opset Version 10.
37    FasterRcnn,
38    /// A real-time neural network for object instance segmentation that detects 80 different classes. Extends
39    /// Faster R-CNN as each of the 300 elected ROIs go through 3 parallel branches of the network: label
40    /// prediction, bounding box prediction and mask prediction.
41    ///
42    /// Variant downloaded: ONNX Version 1.5 with Opset Version 10.
43    MaskRcnn,
44    /// A real-time dense detector network for object detection that addresses class imbalance through Focal Loss.
45    /// RetinaNet is able to match the speed of previous one-stage detectors and defines the state-of-the-art in
46    /// two-stage detectors (surpassing R-CNN).
47    ///
48    /// Variant downloaded: ONNX Version 1.6.0 with Opset Version 9.
49    RetinaNet,
50    /// A CNN model for real-time object detection system that can detect over 9000 object categories. It uses a
51    /// single network evaluation, enabling it to be more than 1000x faster than R-CNN and 100x faster than
52    /// Faster R-CNN.
53    ///
54    /// Variant downloaded: ONNX Version 1.3 with Opset Version 8.
55    YoloV2,
56    /// A CNN model for real-time object detection system that can detect over 9000 object categories. It uses
57    /// a single network evaluation, enabling it to be more than 1000x faster than R-CNN and 100x faster than
58    /// Faster R-CNN. This model is trained with COCO dataset and contains 80 classes.
59    ///
60    /// Variant downloaded: ONNX Version 1.5 with Opset Version 9.
61    YoloV2Coco,
62    /// A deep CNN model for real-time object detection that detects 80 different classes. A little bigger than
63    /// YOLOv2 but still very fast. As accurate as SSD but 3 times faster.
64    ///
65    /// Variant downloaded: ONNX Version 1.5 with Opset Version 10.
66    YoloV3,
67    /// A smaller version of YOLOv3 model.
68    ///
69    /// Variant downloaded: ONNX Version 1.6 with Opset Version 11.
70    TinyYoloV3,
71    /// Optimizes the speed and accuracy of object detection. Two times faster than EfficientDet. It improves
72    /// YOLOv3's AP and FPS by 10% and 12%, respectively, with mAP50 of 52.32 on the COCO 2017 dataset and
73    /// FPS of 41.7 on Tesla 100.
74    ///
75    /// Variant downloaded: ONNX Version 1.6 with Opset Version 11.
76    YoloV4,
77    /// Deep CNN based pixel-wise semantic segmentation model with >80% mIOU (mean Intersection Over Union).
78    /// Trained on cityscapes dataset, which can be effectively implemented in self driving vehicle systems.
79    ///
80    /// Variant downloaded: ONNX Version 1.2.2 with Opset Version 7.
81    Duc,
82}
83
84impl ModelUrl for ObjectDetectionImageSegmentation {
85    fn fetch_url(&self) -> &'static str {
86        match self {
87            ObjectDetectionImageSegmentation::TinyYoloV2 => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/tiny-yolov2/model/tinyyolov2-8.onnx",
88            ObjectDetectionImageSegmentation::Ssd => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/ssd/model/ssd-10.onnx",
89            ObjectDetectionImageSegmentation::SSDMobileNetV1 => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/ssd-mobilenetv1/model/ssd_mobilenet_v1_10.onnx",
90            ObjectDetectionImageSegmentation::FasterRcnn => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/faster-rcnn/model/FasterRCNN-10.onnx",
91            ObjectDetectionImageSegmentation::MaskRcnn => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/mask-rcnn/model/MaskRCNN-10.onnx",
92            ObjectDetectionImageSegmentation::RetinaNet => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/retinanet/model/retinanet-9.onnx",
93            ObjectDetectionImageSegmentation::YoloV2 => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/yolov2/model/yolov2-voc-8.onnx",
94            ObjectDetectionImageSegmentation::YoloV2Coco => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/yolov2-coco/model/yolov2-coco-9.onnx",
95            ObjectDetectionImageSegmentation::YoloV3 => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/yolov3/model/yolov3-10.onnx",
96            ObjectDetectionImageSegmentation::TinyYoloV3 => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/tiny-yolov3/model/tiny-yolov3-11.onnx",
97            ObjectDetectionImageSegmentation::YoloV4 => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/yolov4/model/yolov4.onnx",
98            ObjectDetectionImageSegmentation::Duc => "https://github.com/onnx/models/raw/master/vision/object_detection_segmentation/duc/model/ResNet101-DUC-7.onnx",
99        }
100    }
101}
102
103impl From<ObjectDetectionImageSegmentation> for AvailableOnnxModel {
104    fn from(model: ObjectDetectionImageSegmentation) -> Self {
105        AvailableOnnxModel::Vision(Vision::ObjectDetectionImageSegmentation(model))
106    }
107}