ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
reusex::vision::onnx::ONNXSam3 Class Reference

SAM3 segmentation model using ONNX Runtime for CPU/GPU inference. More...

#include <Sam3.hpp>

Inheritance diagram for reusex::vision::onnx::ONNXSam3:
Collaboration diagram for reusex::vision::onnx::ONNXSam3:

Public Member Functions

 ONNXSam3 (const std::filesystem::path &model_dir, bool use_cuda=false)
 Construct and load a SAM3 model from a directory.
std::vector< IDataset::Pairforward (const std::span< IDataset::Pair > &input) override
 Run SAM3 inference on a batch of images.
Public Member Functions inherited from reusex::vision::IModel
virtual ~IModel ()=default

Static Public Member Functions

static std::unique_ptr< ONNXSam3create (const std::filesystem::path &model_dir, bool use_cuda=false)
 Factory method for creating an ONNXSam3 instance.
Static Public Member Functions inherited from reusex::vision::IModel
static std::unique_ptr< IModelcreate (const std::filesystem::path &model_path, bool use_gpu=false)

Detailed Description

SAM3 segmentation model using ONNX Runtime for CPU/GPU inference.

Loads three ONNX sub-models (vision encoder, text encoder, decoder) from a directory and implements the IModel interface for use with the backend-agnostic annotation pipeline.

Optionally uses CUDA execution provider when available, with automatic fallback to CPU.

Definition at line 30 of file Sam3.hpp.

Constructor & Destructor Documentation

◆ ONNXSam3()

reusex::vision::onnx::ONNXSam3::ONNXSam3 ( const std::filesystem::path & model_dir,
bool use_cuda = false )
explicit

Construct and load a SAM3 model from a directory.

Parameters
model_dirDirectory containing vision-encoder.onnx, text-encoder.onnx, decoder.onnx, and tokenizer.json.
use_cudaWhether to attempt CUDA execution provider.

Member Function Documentation

◆ create()

std::unique_ptr< ONNXSam3 > reusex::vision::onnx::ONNXSam3::create ( const std::filesystem::path & model_dir,
bool use_cuda = false )
static

Factory method for creating an ONNXSam3 instance.

Parameters
model_dirDirectory with ONNX model files.
use_cudaWhether to use CUDA (defaults to false).
Returns
Unique pointer to the created model.

◆ forward()

std::vector< IDataset::Pair > reusex::vision::onnx::ONNXSam3::forward ( const std::span< IDataset::Pair > & input)
overridevirtual

Run SAM3 inference on a batch of images.

Each input Pair must contain an ONNXSam3Data with a raw image and text prompts. Output Pairs contain the same data type with the image field set to the label image (CV_32S, -1 for background).

Parameters
inputSpan of (data, index) pairs from the dataset.
Returns
Vector of (data, index) pairs with label images.

Implements reusex::vision::IModel.


The documentation for this class was generated from the following file:
  • libs/reusex/include/vision/onnx/Sam3.hpp