Built a 24MB offline ML app with Burn + Tauri - runs on my iPhone at 80ms inference
Hey r/rust,
Just finished a project I wanted to share - a plant disease detection AI built entirely in Rust using the Burn framework, deployed to my iPhone 12 via Tauri.
TL;DR numbers:
- 24MB total deployment (vs 7.1GB for equivalent PyTorch)
- 0.39ms inference / 2,579 FPS on desktop GPU (RTX 3060)
- ~80ms inference on iPhone 12 via Tauri
- 38 disease classes, trained with 30% labeled data (semi-supervised)
Why Rust over Python?
The use case required offline inference on devices farmers already own - no cloud, no dedicated hardware. PyTorch was a non-starter: 7GB dependencies, 3s cold start, installation hell. Burn compiles to a single binary and targets wgpu (native GPU), ndarray (CPU), and WASM (browser) from one codebase.
The Model (Burn)
The CNN is pretty standard, but Burn's derive macros make it clean:
#[derive(Module, Debug)]
pub struct PlantClassifier<B: Backend> {
conv1: ConvBlock<B>,
conv2: ConvBlock<B>,
conv3: ConvBlock<B>,
conv4: ConvBlock<B>,
global_pool: AdaptiveAvgPool2d,
fc1: Linear<B>,
dropout: Dropout,
fc2: Linear<B>,
}
4 conv blocks (32→64→128→256), BatchNorm + ReLU, GlobalAvgPool, then FC layers. The #[derive(Module)] macro handles all the weight serialization and device placement automatically.
The Semi-Supervised Learning Part
Labeled agricultural data is expensive (~€2/image for expert annotation). We used pseudo-labeling with a configurable confidence threshold:
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PseudoLabelConfig {
pub confidence_threshold: f64, // Default: 0.9
pub max_per_class: Option<usize>, // Prevent class imbalance
pub retrain_threshold: usize, // Min samples before retrain
pub curriculum_learning: bool, // Start strict, relax over time
}
Train on 30% labeled → predict on 70% unlabeled → accept predictions >90% confidence → retrain. Result: accuracy comparable to 60% fully-labeled.
The Tauri Deployment
This was the fun part. Tauri 2.0 wraps the Burn model in a native iOS app:
cargo tauri ios build
80ms inference on the A14 chip. The Rust backend does all the ML, the UI is just HTML/JS. It's actually running Rust on an iPhone.
What I learned:
- Burn is genuinely production-ready for inference workloads
burn-cudawith the0.20.0-prerelease has solid CUDA 13 support- WASM performance is better than expected (~80ms on mobile Safari)
- Compile times are... Rust compile times.
lto = true+codegen-units = 1= 5+ min release builds - Tauri mobile is legit - one codebase, native perf
Links:
- Full writeup with benchmarks: https://snaetwarre.github.io/My-Portofolio/blog/intelligent-disease-detection.html
- Source code: https://github.com/SnaetWarre/Research_Project_Rust_Semi-Supervised_Learning (still working on orginazing this, also the mobile tauri code is yet to be put on here, figuring out on how to do this nicely without breaking it on my laptop)