Quick Start
Hook API
useClassification(props)
Manages a classification model instance.
Parameters
Model configuration object
Prevent automatic model loading. Useful for lazy loading.
Returns
Error object if model loading or inference fails
Whether the model is loaded and ready for inference
Whether the model is currently processing an image
Model download progress (0-1)
Execute classification on an image. Returns a dictionary mapping category names to confidence scores (0-1).
Available Models
EFFICIENTNET_V2_S
EfficientNetV2-S optimized for mobile devices.- Categories: 1000 ImageNet classes
- Architecture: EfficientNetV2-Small
- Backend: CoreML (iOS), XNNPACK (Android)
- Accuracy: Top-1 ~84%
- Inference Time: ~50-100ms on modern devices
Complete Example
Use Cases
Image Organization
Automatically categorize photos in gallery apps:Content Moderation
Filter inappropriate content:Product Recognition
Identify products in retail applications:Performance Tips
Image Preprocessing
The model automatically handles image preprocessing, but you can optimize by:- Using appropriately sized images (224x224 to 512x512)
- Avoiding extremely large images that need significant downscaling
- Using JPEG format for better compression
Batch Classification
Process multiple images efficiently:Confidence Thresholds
Filter low-confidence predictions:Custom Models
Use your own classification model:Custom models must be in ExecuTorch
.pte format and follow the classification model interface. See the Custom Models guide for details.Troubleshooting
Model fails to load
- Check internet connectivity for first-time downloads
- Verify sufficient storage space
- Check error code:
error.code
Low accuracy
- Ensure images are clear and well-lit
- Verify the subject is the main focus of the image
- Check that the category exists in ImageNet-1K classes
Slow inference
- Reduce image resolution before processing
- Ensure device has sufficient available memory
- Avoid running multiple models simultaneously
Type Reference
Related
- Object Detection - Detect and localize objects
- Image Embeddings - Extract feature vectors
- Custom Models - Use your own models