Files
scene-actor-extraction/src/inference/face_embedder.hpp
T

33 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "types.hpp"
#include <memory>
#include <vector>
// ── IFaceEmbedder ─────────────────────────────────────────────────────────────
// Backend-agnostic ArcFace embedder interface. The core application produces
// 512-d L2-normalised embeddings through this interface without knowing whether
// the implementation is ONNX Runtime or raw TensorRT.
//
// The concrete implementation is selected at compile time by CMake
// (SAE_INFERENCE_BACKEND): exactly one of backends/ort_backend.cpp or
// backends/trt_backend.cpp is compiled and provides make_face_embedder().
struct Config;
struct IFaceEmbedder {
virtual ~IFaceEmbedder() = default;
// Embed a batch of 112×112 BGR crops → one L2-normalised 512-d embedding
// each, parallel to the input.
virtual std::vector<Embedding> embed(const std::vector<cv::Mat>& crops) = 0;
// Largest batch the backend accepts in a single embed() call. TRT engines
// are capped by their build profile; ORT reports the configured batch size.
virtual int max_batch() const = 0;
Embedding embed_one(const cv::Mat& crop) { return embed({crop}).front(); }
};
// Construct the embedder for the compiled-in backend. Reads cfg.arcface_model,
// cfg.arcface_engine, cfg.embed_batch_size and cfg.trt.
std::unique_ptr<IFaceEmbedder> make_face_embedder(const Config& cfg);