RepViTSAM<T>
Models & Types · AiDotNet.ComputerVision.Segmentation.Efficient
RepViT-SAM: Real-time SAM with RepViT backbone.
Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → PromptableSegmentationBase<T> → RepViTSAM<T>
For Beginners
Real-time segment anything. Mobile and edge SAM inference.
Common use cases:
- Real-time segment anything
- Mobile and edge SAM inference
- Interactive segmentation on devices
- Low-latency promptable segmentation
How It Works
Technical Details:
- RepViT (Re-parameterized Vision Transformer) backbone
- Structural re-parameterization for inference speed
- Multi-scale feature extraction for SAM decoder
- Achieves real-time SAM on mobile devices
Reference: Wang et al., “RepViT-SAM: Towards Real-Time Segmenting Anything”, arXiv 2024.
Example
// Create a RepViT-SAM model for real-time promptable segmentation
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.ThreeDimensional,
taskType: NeuralNetworkTaskType.BinaryClassification,
inputHeight: 1024, inputWidth: 1024, inputDepth: 3, outputSize: 1);
var model = new RepViTSAM<double>(architecture);
// Every tunable is now set through the options object; these are the defaults:
var custom = new RepViTSAM<double>(architecture,
options: new RepViTSAMOptions { NumClasses = 1, DropRate = 0 });
Constructors
| Constructor | Summary |
|---|---|
RepViTSAM(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, RepViTSAMOptions options) |
Initializes RepViTSAM in native (trainable) mode. |
RepViTSAM(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, RepViTSAMOptions options) |
Initializes RepViTSAM in ONNX (inference-only) mode. |
Methods
| Method | Summary |
|---|---|
List<PromptedSegmentationResult<T>> SegmentEverything() |
|
ModelMetadata<T> GetModelMetadata() |
Collects metadata describing this model’s configuration. |
PromptedSegmentationResult<T> SegmentFromBox(Tensor<T> box) |
|
PromptedSegmentationResult<T> SegmentFromMask(Tensor<T> mask) |
|
PromptedSegmentationResult<T> SegmentFromPoints(Tensor<T> points, Tensor<T> labels) |
|
void SetImage(Tensor<T> image) |