Skip to main content

Model

Model is the top-level API for loading a compiled model (.tar.gz) and exposing reusable stage fragments.

Use Model when you want model-aware graph assembly without manually wiring every model plugin.

What Model gives you

  • graph(): full model path as a reusable Graph fragment.
  • preprocess(), inference(), postprocess(): reusable node-stage fragments.
  • input_specs() and output_specs(): full tensor-contract lists for multi-input / multi-output models.
  • build(...) / run(...): direct convenience execution via Model::Runner.

Reference:

Typical usage inside a Graph

simaai::neat::Model model("yolov8s_model.tar.gz");

simaai::neat::Graph graph;
graph.add(model.graph());

Inspect specs and run directly

Before composing a Graph you can introspect the model's tensor contracts with input_specs() / output_specs() (and metadata()), then run a frame straight through with run(...) — no Graph required.

simaai::neat::Model model("yolov8s_model.tar.gz");

// Tensor contracts the model expects (input) and produces (output).
const auto inputs = model.input_specs();
const auto outputs = model.output_specs();

for (std::size_t i = 0; i < inputs.size(); ++i) {
const auto& input_shape = inputs[i].shape;
}
for (std::size_t i = 0; i < outputs.size(); ++i) {
const auto& output_shape = outputs[i].shape;
}
const auto metadata = model.metadata();

// Run one frame directly via Model::Runner (no Graph required).
simaai::neat::TensorList result = model.run(std::vector<cv::Mat>{frame}, /*timeout_ms=*/2000);

Failure handling

Model-driven Graphs use the same diagnostics contract as raw Graph:

  • NeatError.report().error_code for terminal failures
  • NeatError.report().repro_note for actionable context + hints
  • NeatError.report().bus for plugin/runtime detail

Start triage from error_code (misconfig.*, build.*, runtime.*, io.*) before inspecting detailed bus logs.

See also

Tutorials