dl::NeuroSAMModel
dl::NeuroSAMModel
Concrete ModelBase subclass wrapping the NeuroSAM ExecuTorch model. More…
#include <NeuroSAMModel.hpp>
Inherits from dl::ModelBase
Public Functions
| Name | |
|---|---|
| NeuroSAMModel() | |
| ~NeuroSAMModel() override | |
| NeuroSAMModel(NeuroSAMModel const & ) =delete | |
| NeuroSAMModel & | operator=(NeuroSAMModel const & ) =delete |
| NeuroSAMModel(NeuroSAMModel && ) | |
| NeuroSAMModel & | operator=(NeuroSAMModel && ) |
| virtual std::string | modelId() const override Unique string identifier for this model class (e.g. “neurosam”). |
| virtual std::string | displayName() const override Human-readable display name (e.g. “NeuroSAM”). |
| virtual std::string | description() const override Description for UI tooltip. |
| virtual std::vector< TensorSlotDescriptor > | inputSlots() const override Input slot descriptors (ordered). |
| virtual std::vector< TensorSlotDescriptor > | outputSlots() const override Output slot descriptors (ordered). |
| virtual void | loadWeights(std::filesystem::path const & path) override Load weights from a file (e.g. a .pte ExecuTorch program or a TorchScript model). |
| virtual bool | isReady() const override Whether weights are loaded and model is ready for inference. |
| virtual int | preferredBatchSize() const override Preferred batch size. |
| virtual int | maxBatchSize() const override Maximum batch size the model supports. |
| virtual dl::BatchMode | batchMode() const override Batch mode describing the model’s batch-size constraints. |
| virtual std::unordered_map< std::string, at::Tensor > | forward(std::unordered_map< std::string, at::Tensor > const & inputs) override Run inference. |
Public Attributes
| Name | |
|---|---|
| int | kModelSize |
| int | kImageChannels |
| int | kMaskChannels |
| int | kOutputChannels |
| char const * | kEncoderImageSlot |
| char const * | kMemoryImagesSlot |
| char const * | kMemoryMasksSlot |
| char const * | kProbabilityMapSlot |
Additional inherited members
Public Functions inherited from dl::ModelBase
| Name | |
|---|---|
| virtual | ~ModelBase() =default |
| virtual std::string | recommendedPostEncoderModule() const Recommended post-encoder module key for the UI (e.g. “global_avg_pool”). |
Detailed Description
class dl::NeuroSAMModel;Concrete ModelBase subclass wrapping the NeuroSAM ExecuTorch model.
NeuroSAM is a Segment-Anything-style model for neural data that predicts a probability map from a current frame and a set of memory frames. It operates in a feedback loop where the output probability map is fed back as a memory mask for the next frame, requiring single-frame (batch=1) inference.
Input slots:
- “encoder_image” : [3, 256, 256] — current video frame (RGB)
- “memory_images” : [3, 256, 256] — memory encoder frames (static, per-slot)
- “memory_masks” : [1, 256, 256] — memory ROI masks (static, per-slot)
Output slots:
- “probability_map”: [1, 256, 256] — probability map (decode as mask or point)
The non-sequence variant treats each memory slot as a separate tensor input. The UI/SlotAssembler handles stacking multiple memory entries.
Public Functions Documentation
function NeuroSAMModel
NeuroSAMModel()function ~NeuroSAMModel
~NeuroSAMModel() overridefunction NeuroSAMModel
NeuroSAMModel(
NeuroSAMModel const &
) =deletefunction operator=
NeuroSAMModel & operator=(
NeuroSAMModel const &
) =deletefunction NeuroSAMModel
NeuroSAMModel(
NeuroSAMModel &&
)function operator=
NeuroSAMModel & operator=(
NeuroSAMModel &&
)function modelId
virtual std::string modelId() const overrideUnique string identifier for this model class (e.g. “neurosam”).
Reimplements: dl::ModelBase::modelId
function displayName
virtual std::string displayName() const overrideHuman-readable display name (e.g. “NeuroSAM”).
Reimplements: dl::ModelBase::displayName
function description
virtual std::string description() const overrideDescription for UI tooltip.
Reimplements: dl::ModelBase::description
function inputSlots
virtual std::vector< TensorSlotDescriptor > inputSlots() const overrideInput slot descriptors (ordered).
Reimplements: dl::ModelBase::inputSlots
Each describes one named tensor the model expects. Does not include the batch dimension.
function outputSlots
virtual std::vector< TensorSlotDescriptor > outputSlots() const overrideOutput slot descriptors (ordered).
Reimplements: dl::ModelBase::outputSlots
Each describes one named tensor the model produces. Does not include the batch dimension.
function loadWeights
virtual void loadWeights(
std::filesystem::path const & path
) overrideLoad weights from a file (e.g. a .pte ExecuTorch program or a TorchScript model).
Reimplements: dl::ModelBase::loadWeights
function isReady
virtual bool isReady() const overrideWhether weights are loaded and model is ready for inference.
Reimplements: dl::ModelBase::isReady
function preferredBatchSize
virtual int preferredBatchSize() const overridePreferred batch size.
Reimplements: dl::ModelBase::preferredBatchSize
0 = model decides; 1 = single-frame (e.g. NeuroSAM with output→input feedback); N = process N frames at once. UI uses this as the default for the “Batch Size” spinbox.
function maxBatchSize
virtual int maxBatchSize() const overrideMaximum batch size the model supports.
Reimplements: dl::ModelBase::maxBatchSize
0 = unlimited.
function batchMode
virtual dl::BatchMode batchMode() const overrideBatch mode describing the model’s batch-size constraints.
Reimplements: dl::ModelBase::batchMode
The default returns [DynamicBatch](/api_generated/Classes/structdl_1_1DynamicBatch.md){1, 0} (any batch size). Override in subclasses to report [FixedBatch](/api_generated/Classes/structdl_1_1FixedBatch.md), [RecurrentOnlyBatch](/api_generated/Classes/structdl_1_1RecurrentOnlyBatch.md), or a [DynamicBatch](/api_generated/Classes/structdl_1_1DynamicBatch.md) with specific limits.
The widget uses this to configure the batch-size spinbox and to auto-select the correct weights variant for multi-variant models.
function forward
virtual std::unordered_map< std::string, at::Tensor > forward(
std::unordered_map< std::string, at::Tensor > const & inputs
) overrideRun inference.
Parameters:
- inputs Map of slot_name → Tensor, each with a leading batch dimension.
Return: Map of slot_name → Tensor for each output slot.
Reimplements: dl::ModelBase::forward
Tensors have a leading batch dimension whose size is controlled by the caller (and bounded by [maxBatchSize()](/api_generated/Classes/classdl_1_1NeuroSAMModel.md#function-maxbatchsize)).
Public Attributes Documentation
variable kModelSize
static int kModelSize = 256;The spatial resolution expected by the model for all image/mask inputs.
variable kImageChannels
static int kImageChannels = 3;Number of input channels for image inputs (RGB).
variable kMaskChannels
static int kMaskChannels = 1;Number of channels for mask inputs.
variable kOutputChannels
static int kOutputChannels = 1;Number of channels for the output probability map.
variable kEncoderImageSlot
static char const * kEncoderImageSlot = "encoder_image";variable kMemoryImagesSlot
static char const * kMemoryImagesSlot = "memory_images";variable kMemoryMasksSlot
static char const * kMemoryMasksSlot = "memory_masks";variable kProbabilityMapSlot
static char const * kProbabilityMapSlot = "probability_map";Updated on 2026-11-13 at 20:25:42 +0000