class LabelBotService

Methods

array
getLabelsForAnnotation(Annotation $annotation, int $volumeId, Request $request)

Get the suggested labels of a new annotation either by using a label_id or a feature_vector from the request.

enforceRateLimit($user)

No description

array
getLabelTreeIds(mixed $user, int $volumeId)

Get all label trees that are used by all projects which are visible to the user.

array
performVectorSearch(vector $featureVector, int[] $trees, string $model)

Perform vector search using the ANN-Iterative-Fallback technique (ANN-Itr-FB).

array
performAnnSearch(Vector $featureVector, int[] $trees, string $model, int $k)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW index with Post-Subquery Filtering (PSF).

ImageAnnotationLabelFeatureVector|VideoAnnotationLabelFeatureVector>
getFeatureVectorModelFor(Annotation $annotation)

Get the correct model class for the annotation type.

Details

at line 27
array getLabelsForAnnotation(Annotation $annotation, int $volumeId, Request $request)

Get the suggested labels of a new annotation either by using a label_id or a feature_vector from the request.

Parameters

Annotation $annotation
int $volumeId
Request $request

Return Value

array

at line 64
protected enforceRateLimit($user)

No description

Parameters

$user

at line 85
protected array getLabelTreeIds(mixed $user, int $volumeId)

Get all label trees that are used by all projects which are visible to the user.

Parameters

mixed $user
int $volumeId

Return Value

array

at line 120
protected array performVectorSearch(vector $featureVector, int[] $trees, string $model)

Perform vector search using the ANN-Iterative-Fallback technique (ANN-Itr-FB).

The search process first attempts to retrieve (top K) results using an Approximate Nearest Neighbor (ANN) search via the HNSW index. If the ANN search returns no results, the iterative index scan is triggered and the ANN search is performed again as a fallback with K = 2 * K.

Parameters

vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

string $model

Class name of the feature vector model to use

Return Value

array

The array of top N labels that are the closest to the input feature vector.

at line 165
protected array performAnnSearch(Vector $featureVector, int[] $trees, string $model, int $k)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW index with Post-Subquery Filtering (PSF).

The search uses the HNSW index to find the top K nearest neighbors of the input feature vector, and then applies filtering based on the label_tree_id values. If no results are found or if the filtering removes all results, an empty array is returned.

Parameters

Vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

string $model

Class name of the annotation type.

int $k

Number of desired results.

Return Value

array

The array of label IDs representing the top nearest neighbors.

at line 190
protected ImageAnnotationLabelFeatureVector|VideoAnnotationLabelFeatureVector> getFeatureVectorModelFor(Annotation $annotation)

Get the correct model class for the annotation type.

Parameters

Annotation $annotation

Return Value

ImageAnnotationLabelFeatureVector|VideoAnnotationLabelFeatureVector>