PLantDetect-WA / README.md
thenukegun10x's picture
docs: add FP8 hardware warning to Server/Desktop GPU/CPU
05f0f04 verified
|
Raw
History Blame Contribute Delete
11.4 kB
---
language:
- en
license: cc-by-nc-4.0
tags:
- vision
- image-classification
- botany
- western-australia
- dinov3
- mixture-of-experts
- litert
- onnx
- adaround
- fp8
- int8
- android
- biodiversity
- flora
datasets:
- gbif
pipeline_tag: image-classification
---
# PlantDetect: Western Australia Plant Vision (999 Species)
<div align="center">
### Built with DINOv3
**Fine-grained botanical vision models specializing in the flora of Western Australia.**
[![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-yellow)](https://huggingface.co/thenukegun10x/wa-plant-identifier)
[![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
</div>
---
## 1. Multi-View Botanical Inference (Single vs. Multi-Photo)
In the field, plant species can be difficult to distinguish from a single photo. By providing multiple complementary angles of the same plant (e.g. Flower, Leaf, Habit, Fruit), the model achieves near-perfect classification accuracy:
| Photos Provided by User | Mobile Dense Student (`plant_dense_4view`) — `PlantDetect-Dense-4View-BF16` | Server MoE++ BEST (`PlantDetect-BF16`) | Real-World Botanical Impact |
| :--- | :--- | :--- | :--- |
| **1 Photo (Single-Shot)** | **`82.08% Top-1`** (`93.03% Top-5`) | **`89.31% Top-1`** (`96.14% Top-5`) | Fast single photo identification |
| **2 Photos (Dual-Angle)** | **`94.27% Top-1`** (`99.28% Top-5`) | **`97.11% Top-1`** (`99.66% Top-5`) | Flower + Leaf resolves 94%+ of species |
| **3 Photos (Tri-Angle)** | **`97.45% Top-1`** (`99.84% Top-5`) | **`98.77% Top-1`** (`99.95% Top-5`) | Flower + Leaf + Growth habit |
| **4 Photos (Quad-Angle)** | **`98.31% Top-1`** (`99.90% Top-5`) | **`99.42% Top-1`** (`100.00% Top-5`) | **`99.9% Top-5`** certainty in the field |
*Re-benched 2026-08-30 sequential `BF16` `27,673` val, `K-view mean logits` via `bench_multiview_finals.py` (`data/bench_multiview_finals.json`) — `PlantDetect-Dense-4View-BF16` / `PlantDetect-BF16`.*
---
## 2. Complete Model Artifact Catalog (Direct Download Links)
### A. Mobile Edge & Embedded Models (Dense ViT-Base)
*Optimized for Samsung Galaxy S24 (Exynos 2400 / Snapdragon 8 Gen 3), iOS, Windows DirectML, and Raspberry Pi.*
| Model File | Model Type | Runtime Target | Format / Precision | File Size | Top-1 (1-View) | Top-1 (4-View) | Target Hardware |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| [**`PlantDetect-Dense-INT8.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-Dense-INT8.safetensors) | Single-Shot | PyTorch / Python | **Standard W8A16 INT8** | **`93.3 MB`** | 83.02% | 97.34% | Ultra-compact Python edge |
| [**`PlantDetect-Dense-FP8-AdaRound.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-Dense-FP8-AdaRound.safetensors) | Single-Shot | PyTorch / Python | **AdaRound FP8 (E4M3)** | **`92.7 MB`** | 83.02% | 97.34% | GPU / Python lightweight |
| [**`PlantDetect-Dense-BF16.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-Dense-BF16.safetensors) | Single-Shot | PyTorch / Python | **Full `bfloat16`** | **`181.5 MB`** | 83.02% | 97.34% | Dense PyTorch reference |
| [**`PlantDetect-Dense-4View-INT8.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-Dense-4View-INT8.safetensors) | **4-View Distilled** | PyTorch / Python | **Standard W8A16 INT8** | **`93.3 MB`** | 82.08% | **98.31%** | Dedicated multi-photo mobile edge |
| [**`PlantDetect-Dense-4View-FP8-AdaRound.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-Dense-4View-FP8-AdaRound.safetensors) | **4-View Distilled** | PyTorch / Python | **AdaRound FP8 (E4M3)** | **`92.7 MB`** | 82.08% | **98.31%** | Dedicated multi-photo GPU edge |
| [**`PlantDetect-Dense-4View-BF16.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-Dense-4View-BF16.safetensors) | **4-View Distilled** | PyTorch / Python | **Full `bfloat16`** | **`181.5 MB`** | 82.08% | **98.31%** | Lossless 4-view dense reference |
| [**`onnx/PlantDetect-Dense-INT8.onnx`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/onnx/PlantDetect-Dense-INT8.onnx) | Single-Shot | ONNX Runtime | **Mixed-Precision INT8** | **`106.3 MB`** | 83.02% | 97.34% | Android, iOS CoreML, Windows |
| [**`onnx/PlantDetect-Dense-FP32.onnx`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/onnx/PlantDetect-Dense-FP32.onnx) | Single-Shot | ONNX Runtime | **Full FP32** | `363.3 MB` | 83.02% | 97.34% | Standard reference ONNX |
| [**`onnx/PlantDetect-Dense-4View-INT8.onnx`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/onnx/PlantDetect-Dense-4View-INT8.onnx) | **4-View Distilled** | ONNX Runtime | **Mixed-Precision INT8** | **`106.3 MB`** | 82.08% | **98.31%** | Multi-photo ONNX Runtime |
| [**`onnx/PlantDetect-Dense-4View-FP32.onnx`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/onnx/PlantDetect-Dense-4View-FP32.onnx) | **4-View Distilled** | ONNX Runtime | **Full FP32** | `363.3 MB` | 82.08% | **98.31%** | Multi-photo reference ONNX |
| [**`litert/PlantDetect-Dense-INT8.tflite`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/litert/PlantDetect-Dense-INT8.tflite) | Single-Shot | Google LiteRT (TFLite) | **Full Integer INT8** | **`387.0 MB`** | 83.02% | 97.34% | Samsung S24 NPU acceleration |
| [**`litert/PlantDetect-Dense-FP16.tflite`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/litert/PlantDetect-Dense-FP16.tflite) | Single-Shot | Google LiteRT (TFLite) | **Float16** | **`196.2 MB`** | 83.02% | 97.34% | Mobile GPU / XNNPACK CPU |
| [**`litert/PlantDetect-Dense-4View-INT8.tflite`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/litert/PlantDetect-Dense-4View-INT8.tflite) | **4-View Distilled** | Google LiteRT (TFLite) | **Full Integer INT8** | **`385.8 MB`** | 82.08% | **98.31%** | Samsung S24 Multi-View NPU |
| [**`litert/PlantDetect-Dense-4View-FP16.tflite`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/litert/PlantDetect-Dense-4View-FP16.tflite) | **4-View Distilled** | Google LiteRT (TFLite) | **Float16** | **`195.8 MB`** | 82.08% | **98.31%** | Multi-View Mobile GPU |
---
### B. Server / Desktop GPU Models (Mixture-of-Experts)
| Model File | Model Type | Architecture | Format | Size | Top-1 (1-View) | Top-1 (4-View) | Primary Use Case |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| [**`PlantDetect-FP8-AdaRound.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-FP8-AdaRound.safetensors) | Single-Shot | MoE++ (16 FFNs) | **AdaRound FP8 (E4M3)** | **`104.3 MB`** | **89.31%** | **99.42%** | **Fastest, ultra-compact GPU server inference** |
| [**`PlantDetect-BF16.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-BF16.safetensors) | Single-Shot | MoE++ (16 FFNs) | **Full `bfloat16`** | **`205.2 MB`** | **89.31%** | **99.42%** | Lossless baseline reference |
| [**`PlantDetect-4View-FP8-AdaRound.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-4View-FP8-AdaRound.safetensors) | **4-View Distilled** | MoE++ 4-View | **AdaRound FP8 (E4M3)** | **`104.3 MB`** | 85.15% | **99.07%** | Dedicated multi-photo teacher (FP8) |
| [**`PlantDetect-4View-BF16.safetensors`**](https://huggingface.co/thenukegun10x/wa-plant-identifier/resolve/main/PlantDetect-4View-BF16.safetensors) | **4-View Distilled** | MoE++ 4-View | **Full `bfloat16`** | **`205.2 MB`** | 85.15% | **99.07%** | Lossless multi-photo baseline |
> **⚠️ FP8 Hardware Compatibility:** `FP8 (E4M3)` requires recent GPU hardware with native FP8 support (NVIDIA Ada Lovelace / Hopper — e.g. RTX 40xx, L4, H100) and `CUDA 12+` / `PyTorch 2.1+`. **Not commonly supported** on older GPUs, CPUs, or mobile. Please check your hardware supports FP8 — **if unsure, use `BF16`** (identical `89.31%`/`99.42%` accuracy, `205MB` vs `104MB`). FP8 works via `bf16` autocast on unsupported hardware but without size/speed benefit.
> **Quantization Architecture Details:**
> * **FP8 Models (`*-FP8-AdaRound.safetensors`):** Quantized using **AdaRound FP8** with quadratic activation reconstruction loss $\min \|Wx - \tilde{W}(V)x\|_2^2$ over non-uniform E4M3 discrete grids (100% Top-1 FP32 match).
> * **INT8 Models (`*-INT8.safetensors` / `.onnx` / `.tflite`):** Quantized using **Symmetric Per-Channel W8A16 Dynamic Range Quantization**, delivering **`43.81 dB` SQNR** and **`0.999985` cosine similarity**.
---
## 3. 🖥️ Official Plant CLI Guide
### 1. Installation
```bash
git clone https://huggingface.co/thenukegun10x/wa-plant-identifier
cd wa-plant-identifier
pip install -r requirements.txt
```
### 2. Identify a Plant from a Single Photo
```bash
python plant_cli.py identify wild_flower.jpg --topk 5
```
### 3. Multi-View Botanical Identification (Flower + Leaf + Habit)
Achieves **97%–99% certainty** by averaging logits across complementary plant angles:
```bash
python plant_cli.py identify flower.jpg leaf.jpg habit.jpg fruit.jpg
```
### 4. Batch Directory Identification
Recursively process an entire field folder and export results to CSV:
```bash
python plant_cli.py batch --dir field_photos/ --pattern "*.jpg" --recursive --out results.csv
```
---
## 4. Python Quickstart Examples
### Multi-View Inference with PyTorch / Safetensors
```python
import torch
import numpy as np
from PIL import Image
from safetensors.torch import load_file
from src.models.plant_vit import PlantViT
# 1. Load model
model = PlantViT(stem_name="vit_base_patch16_dinov3", n_classes=999, use_moe=None)
sd = load_file("PlantDetect-Dense-BF16.safetensors")
model.load_state_dict(sd, strict=False)
model.eval()
# 2. Preprocess multiple photos of the same plant (e.g. Flower + Leaf)
def preprocess(path):
img = Image.open(path).convert("RGB").resize((383, 383))
crop = img.crop((23, 23, 359, 359))
arr = (np.array(crop, dtype=np.float32) / 255.0 - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]
return torch.from_numpy(arr.transpose(2, 0, 1)).unsqueeze(0)
photos = [preprocess("flower.jpg"), preprocess("leaf.jpg")]
# 3. Compute mean logits across all views
with torch.no_grad():
logits_list = [model(p)[0] for p in photos]
mean_logits = torch.stack(logits_list).mean(dim=0)
top_species_idx = mean_logits.argmax(dim=-1).item()
print(f"Identified Species Index: {top_species_idx}")
```
---
## Attribution & Licensing
* **Built with DINOv3:** Uses the DINOv3 vision backbone (`vit_base_patch16_dinov3.lvd1689m`) developed by Meta AI.
* **Dataset Attribution:** Observation data sourced from the **Global Biodiversity Information Facility (GBIF)** and **Western Australian Herbarium (FloraBase / DBCA)**.
* **License:** Released under **Creative Commons Non-Commercial (CC BY-NC 4.0)** for scientific and non-commercial research.