Tagger
Tags images with a TaggingBackend, asking about each category in a Vocabulary. The model can only answer with values you define. Create one and reuse it.
class TaggerExample
const tagger = new Tagger({ backend: new AmosBackend(), vocabulary: { setting: { type: "multi", values: { beach: null, mountains: null, city: null } }, night: { type: "flag", question: "Was the photo taken at night?" }, },});
const result = await tagger.tag({ image: { data: await readFile("getxo.jpg"), mimeType: "image/jpeg" }, context: "Lead photo for a travel guide to Getxo, Spain.",});result.labels; // ["setting:beach", "setting:city"]Constructor
new Tagger(options: TaggerOptions)Checks the vocabulary. Throws a TaggingError with code invalid-configuration if it's invalid.
Parameters
- optionsrequired
TaggerOptions
Methods
tag()
tag(request: TaggingRequest): Promise<TaggingResult>Tags one image. Throws a TaggingError when the image or request is invalid, the backend fails, or its answers don't match the questions.
Parameters
- requestrequired
TaggingRequest
ReturnsPromise<TaggingResult>
evaluate()
evaluate(records: Iterable<DecisionRecord>): EvaluationScores saved records against their expected answers, applying this
tagger's thresholds to the recorded probabilities. Nothing is sent to
the backend.
Parameters
- recordsrequired
Iterable<DecisionRecord>
ReturnsEvaluation
image-tagger is a Ben Hodgson projectGitHub