diff --git a/README.md b/README.md index 4a70ebb..b4e36d5 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ In addition, some models can be evaluated directly through [Akida Cloud](https:/ | Vision | Classification | [MobileNetV2 1.0](vision/classification/mobilenetv2/imagenet) | 224 | ImageNet | 3.5M | 8 | 70.35% | | | 7 | | Vision | Classification | [MobileNetV2 0.75](vision/classification/mobilenetv2/imagenet) | 160 | ImageNet | 2.6M | 8 | 62.85% | | | 4 ☁️ | | Vision | Classification | [MobileNetV2 0.35](vision/classification/mobilenetv2/imagenet) | 96 | ImageNet | 1.2M | 8 | 43.47% | | | 2 ☁️ | +| Vision | Classification | [MobileNetV2 0.5](vision/classification/mobilenetv2/plant_village) | 224 | Plant Village | 0.7M | 8 | 99.12% | | | 4 | | Vision | Classification | [MobileNetV4 1.0](vision/classification/mobilenetv4/imagenet) | 224 | ImageNet | 3.77M | 8 | 71.86% | | | 8 | | Vision | Classification | [MobileNetV2_1.0](vision/classification/mobilenetv2/cifar10) | 128 | CIFAR-10 | 2.25M | 8 | 93.96% | | | 5 ☁️ | | Vision | Classification | [MobileNetV2_1.0](vision/classification/mobilenetv2/oxford_flowers) | 224 | Oxford_Flower | 2.4M | 8 | 91.97% | | | 7 | diff --git a/vision/classification/mobilenetv2/plant_village/README.md b/vision/classification/mobilenetv2/plant_village/README.md new file mode 100644 index 0000000..7675051 --- /dev/null +++ b/vision/classification/mobilenetv2/plant_village/README.md @@ -0,0 +1,69 @@ +# MobileNetV2 0.5 — Plant Village + +## Source +- **Backbone**: [MobileNetV2](https://www.tensorflow.org/api_docs/python/tf/keras/applications/MobileNetV2) (tf.keras), ImageNet pretrained +- **Alpha**: `MBV2_ALPHA = 0.5` +- **Input resolution**: 224 × 224 × 3 +- **Classes**: 38 (Plant Village) +- **Quantization**: 8-bit weights / 8-bit activations (QAT, `_i8_w8_a8.h5`) + +## Performance + +| Variant | Top-1 accuracy | +|-----------------------|----------------| +| Float | 99.47% | +| Quantized 8w8a8 (QAT) | 99.12% | + +Quantized-model sparsity — ReLU: 89%, overall: 53%. + +## Environment + +Install the exact versions used to export and convert these checkpoints — older +or newer versions may fail to round-trip the `quantizeml` custom layers or produce +a different Akida layer graph: + +```bash +pip install \ + akida==2.17.0 \ + cnn2snn==2.17.0 \ + quantizeml==1.0.1 +``` + +## Files + +- `mobilenet_v2_0.5_plant_village.h5` — float Keras model +- `mobilenet_v2_0.5_plant_village_i8_w8_a8.h5` — QAT 8w8a8 Keras model + +## Load the quantized model and convert to Akida + +```python +import quantizeml +from cnn2snn import convert, set_akida_version, AkidaVersion + +keras_model = quantizeml.load_model("mobilenet_v2_0.5_plant_village_i8_w8_a8.h5") + +with set_akida_version(AkidaVersion.v2): + akida_model = convert(keras_model) + +akida_model.summary() +# Input shape: [224, 224, 3] +# Output shape: [1, 1, 38] +``` + +## Map on device (optional) + +```python +import akida + +device = akida.SixNodesIPv2() # or akida.devices()[0] for an Akida 2.0 FPGA +akida_model.map(device, hw_only=True) +akida_model.summary() +``` + +## References +- MobileNetV2 — [Inverted Residuals and Linear Bottlenecks](https://arxiv.org/abs/1801.04381) +- Dataset — [PlantVillage](https://www.tensorflow.org/datasets/catalog/plant_village) +- TensorFlow [MobileNetV2 docs](https://www.tensorflow.org/api_docs/python/tf/keras/applications/MobileNetV2) + +## License +Apache 2.0 License (models only) diff --git a/vision/classification/mobilenetv2/plant_village/mobilenet_v2_0.5_plant_village.h5 b/vision/classification/mobilenetv2/plant_village/mobilenet_v2_0.5_plant_village.h5 new file mode 100644 index 0000000..88e4d68 --- /dev/null +++ b/vision/classification/mobilenetv2/plant_village/mobilenet_v2_0.5_plant_village.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05757210d78957cc96cb6bb981fc655d62de227832b883a5527c85d3ea7ee46e +size 3510320 diff --git a/vision/classification/mobilenetv2/plant_village/mobilenet_v2_0.5_plant_village_i8_w8_a8.h5 b/vision/classification/mobilenetv2/plant_village/mobilenet_v2_0.5_plant_village_i8_w8_a8.h5 new file mode 100644 index 0000000..e3a0609 --- /dev/null +++ b/vision/classification/mobilenetv2/plant_village/mobilenet_v2_0.5_plant_village_i8_w8_a8.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41b6b107772f453f3637653b25b523ef84da81db349c3a2c06f6dadab843ea5d +size 3430208