Quick Start
Hook API
useSemanticSegmentation<C>(props)
Manages a semantic segmentation model instance.
Type Parameters
Model configuration type that determines available labels
Parameters
Model configuration object
Prevent automatic model loading
Returns
Error object if loading or inference fails
Whether the model is loaded and ready
Whether the model is currently processing
Download progress (0-1)
forward
<K>(imageSource: string, classesOfInterest?: K[], resizeToInput?: boolean) => Promise<Record<'ARGMAX', Int32Array> & Record<K, Float32Array>>
Perform semantic segmentation on an image.Parameters:
imageSource: Image URIclassesOfInterest: Optional array of label keys to include probability masks forresizeToInput: Whether to resize output to input dimensions (default: true)
ARGMAX: Int32Array of per-pixel class indices- Per-class probability masks as Float32Array (0-1) for requested classes
Available Models
DeepLab V3 Models
State-of-the-art semantic segmentation with multiple backbones.DEEPLAB_V3_RESNET50
- Backbone: ResNet-50
- Classes: 21 PASCAL VOC classes
- Inference Time: ~300-400ms
- mIoU: ~76%
DEEPLAB_V3_RESNET101
- Backbone: ResNet-101
- Classes: 21 PASCAL VOC classes
- Inference Time: ~400-500ms
- mIoU: ~78%
DEEPLAB_V3_MOBILENET_V3_LARGE
- Backbone: MobileNetV3-Large
- Classes: 21 PASCAL VOC classes
- Inference Time: ~200-250ms
- mIoU: ~72%
FCN Models
Fully Convolutional Networks for segmentation.FCN_RESNET50
FCN_RESNET101
LRASPP Model
Lightweight segmentation for mobile devices.LRASPP_MOBILENET_V3_LARGE
- Backbone: MobileNetV3-Large
- Classes: 21 PASCAL VOC classes
- Inference Time: ~150-200ms
- mIoU: ~70%
Quantized Models
All models available in quantized (INT8) versions for reduced memory:Selfie Segmentation
Specialized model for person segmentation.SELFIE_SEGMENTATION
- Classes: 2 (SELFIE, BACKGROUND)
- Inference Time: ~50-100ms
- Use Case: Portrait mode, background replacement
Segmentation Labels
DeepLab Labels
PASCAL VOC 21 classes:Selfie Segmentation Labels
Complete Example
Use Cases
Background Removal
Remove background using selfie segmentation:Object Isolation
Isolate specific objects from scenes:Scene Understanding
Analyze scene composition:Augmented Reality Effects
Apply effects to segmented regions:Performance Tips
Model Selection
Choose based on requirements:- Real-time needs: LRASPP_MOBILENET_V3_LARGE or quantized models
- High accuracy: DEEPLAB_V3_RESNET101
- Balanced: DEEPLAB_V3_MOBILENET_V3_LARGE
- Portrait/selfie only: SELFIE_SEGMENTATION
Request Only Needed Classes
Resize Control
Memory Management
Process masks efficiently:Visualization
Render segmentation masks:Type Reference
Related
- Object Detection - Bounding box detection
- Classification - Image categorization
- Style Transfer - Artistic effects