11#include "reusex/vision/sam3_prompt.hpp"
29 int image_w,
int image_h);
63 return valid == true_is_valid;
77 int encoder_max_boxes,
int text_len,
78 int decoder_max_len)
noexcept;
94 const std::array<float, 4> &det_xyxy,
const std::vector<SegmentBox> &boxes,
95 const std::vector<std::array<float, 2>> &points = {},
96 const std::function<bool(
float,
float)> &covers = {});
110 int image_w,
int image_h,
117std::vector<std::size_t>
119 const std::vector<std::vector<bool>> &covers);
127std::vector<std::size_t>
129 const std::vector<std::vector<bool>> &covers,
130 const std::vector<bool> &box_selected);
146 [[nodiscard]]
int consecutive() const noexcept {
return consecutive_; }
149 int consecutive_ = 0;
When a request's geometry path fails at run time (encode_boxes / decode with a geometry slot),...
static constexpr int kFailuresBeforeDisable
int consecutive() const noexcept
void record_success() noexcept
bool record_failure() noexcept
Record one failed request; true when geometry should now be disabled.
std::array< float, 4 > sam3_box_cxcywh(const std::array< float, 4 > &xyxy, int image_w, int image_h)
Pixel box [x1, y1, x2, y2] (corners in any order) -> the normalised [cx, cy, w, h] the SAM3 geometry ...
std::vector< std::size_t > sam3_best_detection_per_point(const std::vector< float > &scores, const std::vector< std::vector< bool > > &covers)
Which detections a click selects: for each point, the single highest- scoring detection that covers i...
int sam3_geometry_slot_len(int max_boxes) noexcept
Geometry tokens one prompt slot holds when the largest prompt in a decoder batch has max_boxes boxes:...
std::int64_t sam3_box_label(std::string_view polarity) noexcept
SAM3 box label: 1 for a positive ("pos") box, 0 for a negative one.
std::vector< std::uint8_t > sam3_geometry_slot_mask(int n_boxes, int slot_len)
Validity of one prompt's geometry slot of slot_len tokens holding n_boxes encoded boxes: 1 == a token...
const std::vector< float > & sam3_point_exemplar_fracs()
Exemplar box half-sizes, as fractions of the image's shorter side, a click point is tried at.
int sam3_geometry_capacity(int model_cap, int encoder_min_boxes, int encoder_max_boxes, int text_len, int decoder_max_len) noexcept
Most boxes per prompt the engines can take, or 0 when geometry prompting is unusable.
std::array< float, 4 > sam3_point_exemplar_box(const std::array< float, 2 > &point, int image_w, int image_h, float frac)
The exemplar box [x1, y1, x2, y2] for a click point: half-size frac of the image's shorter side,...
bool sam3_detection_selected(const std::array< float, 4 > &det_xyxy, const std::vector< SegmentBox > &boxes, const std::vector< std::array< float, 2 > > &points={}, const std::function< bool(float, float)> &covers={})
Does a detection with pixel box det_xyxy belong to a box-prompted selection?
int sam3_geometry_box_count(std::size_t requested, int capacity) noexcept
Boxes actually fed for a prompt with requested boxes when the model accepts at most capacity (0 = geo...
constexpr bool sam3_mask_value(bool valid, bool true_is_valid) noexcept
The bool an engine mask holds for a token that is valid, under the polarity sam3_mask_true_is_valid()...
std::vector< std::size_t > sam3_point_prompt_selection(const std::vector< float > &scores, const std::vector< std::vector< bool > > &covers, const std::vector< bool > &box_selected)
The detections a prompt with click points keeps: the UNION of.
std::optional< bool > sam3_mask_true_is_valid(const std::vector< std::uint8_t > &mask, int real_tokens)
Which way an export's bool token masks point, read off the text encoder's own output for an input who...