CACTUS: Dynamically Switchable Context-aware micro-Classifiers for Efficient IoT Inference

Mohammad Mehdi Rastikerdar, Jin Huang, Shiwei Fang, Hui Guan, Deepak Ganesan

TL;DR

CACTUS introduces a context-aware inference paradigm for resource-constrained IoT devices by replacing large, all-class deep learning models with dynamically swapped "micro-classifiers" ($\mu$Classifiers) tailored to the immediate environment. By exploiting temporal locality (e.g., a camera seeing only a few distinct species over a given period), it achieves up to a 5.0$\times$ speedup and a 5.4% accuracy boost on low-power hardware.

What Problem Does This Paper Address?

Deploying deep learning models on edge IoT devices—like trail cameras, smart doorbells, or industrial monitors—is heavily bottlenecked by strict compute, memory, and energy constraints. Standard approaches try to "squeeze" the full model via pruning, quantization, or early-exit architectures. However, these compressed models are still forced to recognize all possible classes at once.

The authors point out that real-world IoT deployments exhibit high temporal locality. A trail camera in a forest might only see deer, turkeys, and raccoons for days before a new animal appears. Forcing the device to always run a massive all-class model wastes precious resources and hurts accuracy due to the unnecessarily large search space.

Methods

The authors propose CACTUS (Context-Aware Classification Through Ultrafast Switching), a framework that breaks context-aware inference down into several specialized components:

  1. Micro-Classifiers ($\mu$Classifiers): Small, highly optimized models trained to recognize only the small subset of classes active in the current context.
  2. Configuration Predictor: To avoid the exponential explosion of training and testing every possible combination of classes and model configurations, CACTUS uses an inter-class similarity metric (based on the cosine similarity of embeddings). A $k$-nearest neighbor ($k$NN) regressor uses this metric to cheaply predict the optimal model configuration (input resolution, pruning level) for any new context without retraining.
  3. Context Change Detector: A lightweight regression head attached directly to the active $\mu$Classifier. It shares the feature extractor and outputs a value near 0 for known context classes and near 1 for unseen classes, triggering a context switch with negligible overhead.
  4. Context Predictor: A heavyweight all-class model (run locally or offloaded to the edge cloud) that runs only when a context change is detected to identify the new class and select the next $\mu$Classifier.
  5. Hybrid Context Switching Policy: An algorithmic policy that dynamically balances the trade-off between using smaller, faster $\mu$Classifiers versus slightly larger ones that reduce the frequency of future context switches.

Datasets

The framework was evaluated using five datasets:

  • STL-10: A standard image recognition dataset (10 classes) used to synthesize controlled temporal sequences.
  • PLACES365 / PLACE20: A subset of 20 scene categories used for core evaluation, scaled up to 100 classes to test the system's scalability.
  • Camera Trap Datasets: Three real-world temporal datasets featuring natural context changes: Enonkishu (9 classes), Camdeboo (11 classes), and Serengeti (season 4) (18 classes).

Key Insights and Ideas

  • Fewer Classes = Better Performance: Reducing the number of classes simplifies the decision boundary, boosting accuracy. Crucially, the authors show that standard compression techniques (pruning, quantization, early exits) do not diminish this advantage; the performance gap between a $\mu$Classifier and an all-class model actually widens as resources become scarcer.
Figure 1: Context-aware micro-classifiers provide substantial performance advantages over all-class models, and this gap is maintained or expanded when applying pruning or early exits.
  • Similarity Tracks Difficulty: Inter-class similarity maps directly to model complexity. If a context contains visually similar classes (e.g., deer, elk, and moose), the configuration predictor automatically selects a higher-capacity model configuration to handle the harder task.
  • Decoupled Detection and Prediction: By separating detecting a context change (via a cheap regression head) from identifying the new class (via the expensive all-class model), the system keeps the critical path incredibly fast and lightweight.

Key Results

  • Hardware Speedups: In end-to-end deployments on real IoT hardware, CACTUS achieved speedups of 1.6$\times$ to 3.5$\times$ on a Raspberry Pi Zero W and 2.0$\times$ to 5.0$\times$ on a RISC-V (GAP8) processor compared to an All-Class EfficientNet-B0 baseline.
  • Accuracy Boost: CACTUS delivered up to a 5.4% accuracy gain over the all-class model because the specialized micro-classifiers make fewer mistakes within their narrow domains.
  • Storage Optimization: By freezing and sharing the feature extractor weights across $\mu$Classifiers of the same size, storing 60 different local $\mu$Classifiers on an unattended device requires only 28 MB of storage space.

Limitations and Future Work

  • Frequent Context Changes: If the deployment environment is highly chaotic and the context changes constantly (e.g., every few frames), the overhead of repeatedly invoking the heavyweight all-class model will degrade the speedup benefits.
  • Frozen Feature Extractors: Currently, the feature extractors are trained once on all classes and frozen. Fine-tuning the feature extractors specifically for each context could yield even higher accuracy, though it would significantly increase training and deployment overhead.
  • Application Scope: While highly optimized for vision tasks with clear temporal locality (like trail cameras), extending this paradigm to fast-moving, safety-critical environments like autonomous driving remains an open challenge.

Summary updated

BibTeX
@inproceedings{rastikerdar2024cactus,
  author = {Mohammad Mehdi Rastikerdar and Jin Huang and Shiwei Fang and Hui Guan and Deepak Ganesan},
  title = {{CACTUS: Dynamically Switchable Context-aware micro-Classifiers for Efficient IoT Inference}},
  booktitle = {MobiSys},
  year = {2024},
  doi = {10.1145/3643832.3661888},
}
Figure