1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
//! Module defining image classification models available to download. //! //! See [https://github.com/onnx/models#image_classification](https://github.com/onnx/models#image_classification) use crate::download::{vision::Vision, AvailableOnnxModel, ModelUrl}; /// Image classification model /// /// > This collection of models take images as input, then classifies the major objects in the images /// > into 1000 object categories such as keyboard, mouse, pencil, and many animals. /// /// Source: [https://github.com/onnx/models#image-classification-](https://github.com/onnx/models#image-classification-) #[derive(Debug, Clone)] pub enum ImageClassification { /// Image classification aimed for mobile targets. /// /// > MobileNet models perform image classification - they take images as input and classify the major /// > object in the image into a set of pre-defined classes. They are trained on ImageNet dataset which /// > contains images from 1000 classes. MobileNet models are also very efficient in terms of speed and /// > size and hence are ideal for embedded and mobile applications. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/mobilenet](https://github.com/onnx/models/tree/master/vision/classification/mobilenet) /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. MobileNet, /// Image classification, trained on ImageNet with 1000 classes. /// /// > ResNet models provide very high accuracies with affordable model sizes. They are ideal for cases when /// > high accuracy of classification is required. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/resnet](https://github.com/onnx/models/tree/master/vision/classification/resnet) ResNet(ResNet), /// A small CNN with AlexNet level accuracy on ImageNet with 50x fewer parameters. /// /// > SqueezeNet is a small CNN which achieves AlexNet level accuracy on ImageNet with 50x fewer parameters. /// > SqueezeNet requires less communication across servers during distributed training, less bandwidth to /// > export a new model from the cloud to an autonomous car and more feasible to deploy on FPGAs and other /// > hardware with limited memory. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/squeezenet](https://github.com/onnx/models/tree/master/vision/classification/squeezenet) /// /// Variant downloaded: SqueezeNet v1.1, ONNX Version 1.2.1 with Opset Version 7. SqueezeNet, /// Image classification, trained on ImageNet with 1000 classes. /// /// > VGG models provide very high accuracies but at the cost of increased model sizes. They are ideal for /// > cases when high accuracy of classification is essential and there are limited constraints on model sizes. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/vgg](https://github.com/onnx/models/tree/master/vision/classification/vgg) Vgg(Vgg), /// Convolutional neural network for classification, which competed in the ImageNet Large Scale Visual Recognition Challenge in 2012. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/alexnet](https://github.com/onnx/models/tree/master/vision/classification/alexnet) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. AlexNet, /// Convolutional neural network for classification, which competed in the ImageNet Large Scale Visual Recognition Challenge in 2014. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/inception_and_googlenet/googlenet](https://github.com/onnx/models/tree/master/vision/classification/inception_and_googlenet/googlenet) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. GoogleNet, /// Variant of AlexNet, it's the name of a convolutional neural network for classification, which competed in the ImageNet Large Scale Visual Recognition Challenge in 2012. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/caffenet](https://github.com/onnx/models/tree/master/vision/classification/caffenet) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. CaffeNet, /// Convolutional neural network for detection. /// /// > This model was made by transplanting the R-CNN SVM classifiers into a fc-rcnn classification layer. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/rcnn_ilsvrc13](https://github.com/onnx/models/tree/master/vision/classification/rcnn_ilsvrc13) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. RcnnIlsvrc13, /// Convolutional neural network for classification. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/rcnn_ilsvrc13](https://github.com/onnx/models/tree/master/vision/classification/rcnn_ilsvrc13) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. DenseNet121, /// Google's Inception Inception(InceptionVersion), /// Computationally efficient CNN architecture designed specifically for mobile devices with very limited computing power. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/shufflenet](https://github.com/onnx/models/tree/master/vision/classification/shufflenet) ShuffleNet(ShuffleNetVersion), /// Deep convolutional networks for classification. /// /// > This model's 4th layer has 512 maps instead of 1024 maps mentioned in the paper. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/zfnet-512](https://github.com/onnx/models/tree/master/vision/classification/zfnet-512) ZFNet512, /// Image classification model that achieves state-of-the-art accuracy. /// /// > It is designed to run on mobile CPU, GPU, and EdgeTPU devices, allowing for applications on mobile and loT, where computational resources are limited. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/efficientnet-lite4](https://github.com/onnx/models/tree/master/vision/classification/efficientnet-lite4) /// /// Variant downloaded: ONNX Version 1.7.0 with Opset Version 11. EfficientNetLite4, } /// Google's Inception #[derive(Debug, Clone)] pub enum InceptionVersion { /// Google's Inception v1 /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/inception_and_googlenet/inception_v1](https://github.com/onnx/models/tree/master/vision/classification/inception_and_googlenet/inception_v1) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. V1, /// Google's Inception v2 /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/inception_and_googlenet/inception_v2](https://github.com/onnx/models/tree/master/vision/classification/inception_and_googlenet/inception_v2) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. V2, } /// ResNet /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/resnet](https://github.com/onnx/models/tree/master/vision/classification/resnet) #[derive(Debug, Clone)] pub enum ResNet { /// ResNet v1 V1(ResNetV1), /// ResNet v2 V2(ResNetV2), } /// ResNet v1 /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/resnet](https://github.com/onnx/models/tree/master/vision/classification/resnet) #[derive(Debug, Clone)] pub enum ResNetV1 { /// ResNet18 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet18, /// ResNet34 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet34, /// ResNet50 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet50, /// ResNet101 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet101, /// ResNet152 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet152, } /// ResNet v2 /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/resnet](https://github.com/onnx/models/tree/master/vision/classification/resnet) #[derive(Debug, Clone)] pub enum ResNetV2 { /// ResNet18 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet18, /// ResNet34 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet34, /// ResNet50 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet50, /// ResNet101 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet101, /// ResNet152 /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. ResNet152, } /// ResNet /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/resnet](https://github.com/onnx/models/tree/master/vision/classification/resnet) #[derive(Debug, Clone)] pub enum Vgg { /// VGG with 16 convolutional layers /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. Vgg16, /// VGG with 16 convolutional layers, with batch normalization applied after each convolutional layer. /// /// The batch normalization leads to better convergence and slightly better accuracies. /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. Vgg16Bn, /// VGG with 19 convolutional layers /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. Vgg19, /// VGG with 19 convolutional layers, with batch normalization applied after each convolutional layer. /// /// The batch normalization leads to better convergence and slightly better accuracies. /// /// Variant downloaded: ONNX Version 1.2.1 with Opset Version 7. Vgg19Bn, } /// Computationally efficient CNN architecture designed specifically for mobile devices with very limited computing power. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/shufflenet](https://github.com/onnx/models/tree/master/vision/classification/shufflenet) #[derive(Debug, Clone)] pub enum ShuffleNetVersion { /// Source: [https://github.com/onnx/models/tree/master/vision/classification/shufflenet](https://github.com/onnx/models/tree/master/vision/classification/shufflenet) /// /// Variant downloaded: ONNX Version 1.4 with Opset Version 9. V1, /// ShuffleNetV2 is an improved architecture that is the state-of-the-art in terms of speed and accuracy tradeoff used for image classification. /// /// Source: [https://github.com/onnx/models/tree/master/vision/classification/shufflenet](https://github.com/onnx/models/tree/master/vision/classification/shufflenet) /// /// Variant downloaded: ONNX Version 1.6 with Opset Version 10. V2, } impl ModelUrl for ImageClassification { fn fetch_url(&self) -> &'static str { match self { ImageClassification::MobileNet => "https://github.com/onnx/models/raw/master/vision/classification/mobilenet/model/mobilenetv2-7.onnx", ImageClassification::SqueezeNet => "https://github.com/onnx/models/raw/master/vision/classification/squeezenet/model/squeezenet1.1-7.onnx", ImageClassification::Inception(version) => version.fetch_url(), ImageClassification::ResNet(version) => version.fetch_url(), ImageClassification::Vgg(variant) => variant.fetch_url(), ImageClassification::AlexNet => "https://github.com/onnx/models/raw/master/vision/classification/alexnet/model/bvlcalexnet-9.onnx", ImageClassification::GoogleNet => "https://github.com/onnx/models/raw/master/vision/classification/inception_and_googlenet/googlenet/model/googlenet-9.onnx", ImageClassification::CaffeNet => "https://github.com/onnx/models/raw/master/vision/classification/caffenet/model/caffenet-9.onnx", ImageClassification::RcnnIlsvrc13 => "https://github.com/onnx/models/raw/master/vision/classification/rcnn_ilsvrc13/model/rcnn-ilsvrc13-9.onnx", ImageClassification::DenseNet121 => "https://github.com/onnx/models/raw/master/vision/classification/densenet-121/model/densenet-9.onnx", ImageClassification::ShuffleNet(version) => version.fetch_url(), ImageClassification::ZFNet512 => "https://github.com/onnx/models/raw/master/vision/classification/zfnet-512/model/zfnet512-9.onnx", ImageClassification::EfficientNetLite4 => "https://github.com/onnx/models/raw/master/vision/classification/efficientnet-lite4/model/efficientnet-lite4.onnx" } } } impl ModelUrl for InceptionVersion { fn fetch_url(&self) -> &'static str { match self { InceptionVersion::V1 => "https://github.com/onnx/models/raw/master/vision/classification/inception_and_googlenet/inception_v1/model/inception-v1-9.onnx", InceptionVersion::V2 => "https://github.com/onnx/models/raw/master/vision/classification/inception_and_googlenet/inception_v2/model/inception-v2-9.onnx", } } } impl ModelUrl for ResNet { fn fetch_url(&self) -> &'static str { match self { ResNet::V1(variant) => variant.fetch_url(), ResNet::V2(variant) => variant.fetch_url(), } } } impl ModelUrl for ResNetV1 { fn fetch_url(&self) -> &'static str { match self { ResNetV1::ResNet18 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet18-v1-7.onnx", ResNetV1::ResNet34 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet34-v1-7.onnx", ResNetV1::ResNet50 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet50-v1-7.onnx", ResNetV1::ResNet101 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet101-v1-7.onnx", ResNetV1::ResNet152 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet152-v1-7.onnx", } } } impl ModelUrl for ResNetV2 { fn fetch_url(&self) -> &'static str { match self { ResNetV2::ResNet18 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet18-v2-7.onnx", ResNetV2::ResNet34 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet34-v2-7.onnx", ResNetV2::ResNet50 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet50-v2-7.onnx", ResNetV2::ResNet101 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet101-v2-7.onnx", ResNetV2::ResNet152 => "https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet152-v2-7.onnx", } } } impl ModelUrl for Vgg { fn fetch_url(&self) -> &'static str { match self { Vgg::Vgg16 => "https://github.com/onnx/models/raw/master/vision/classification/vgg/model/vgg16-7.onnx", Vgg::Vgg16Bn => "https://github.com/onnx/models/raw/master/vision/classification/vgg/model/vgg16-bn-7.onnx", Vgg::Vgg19 => "https://github.com/onnx/models/raw/master/vision/classification/vgg/model/vgg19-7.onnx", Vgg::Vgg19Bn => "https://github.com/onnx/models/raw/master/vision/classification/vgg/model/vgg19-bn-7.onnx", } } } impl ModelUrl for ShuffleNetVersion { fn fetch_url(&self) -> &'static str { match self { ShuffleNetVersion::V1 => "https://github.com/onnx/models/raw/master/vision/classification/shufflenet/model/shufflenet-9.onnx", ShuffleNetVersion::V2 => "https://github.com/onnx/models/raw/master/vision/classification/shufflenet/model/shufflenet-v2-10.onnx", } } } impl From<ImageClassification> for AvailableOnnxModel { fn from(model: ImageClassification) -> Self { AvailableOnnxModel::Vision(Vision::ImageClassification(model)) } } impl From<ResNet> for AvailableOnnxModel { fn from(variant: ResNet) -> Self { AvailableOnnxModel::Vision(Vision::ImageClassification(ImageClassification::ResNet( variant, ))) } } impl From<Vgg> for AvailableOnnxModel { fn from(variant: Vgg) -> Self { AvailableOnnxModel::Vision(Vision::ImageClassification(ImageClassification::Vgg( variant, ))) } } impl From<InceptionVersion> for AvailableOnnxModel { fn from(variant: InceptionVersion) -> Self { AvailableOnnxModel::Vision(Vision::ImageClassification(ImageClassification::Inception( variant, ))) } } impl From<ShuffleNetVersion> for AvailableOnnxModel { fn from(variant: ShuffleNetVersion) -> Self { AvailableOnnxModel::Vision(Vision::ImageClassification( ImageClassification::ShuffleNet(variant), )) } }