@nhtio/adk/batteries/specialists/caption/transformers_js/adapter
transformers.js (ONNX, dual-environment) Caption (image-to-text) specialist adapter battery.
Remarks
Image-captioning battery backed by transformers.js's image-to-text pipeline (the documented reference model is Xenova/vit-gpt2-image-captioning). Environment-neutral — runs in Node (via onnxruntime-node) and the browser (via onnxruntime-web / WebGPU), auto-selected by the package; there is no WebGPU requirement.
Same shape as the transformers.js Embeddings battery: eager constructor validation, a required model (no default), a lazily-imported/single-flight peer, preload() / reset() / dispose(), and the shared lifecycle hooks.
Image input: @nhtio/adk/batteries/specialists/_shared!toBytes normalizes the accepted @nhtio/adk/batteries/specialists/_shared!SpecialistImageInput forms (bytes / bytes+mime / media-like) to plain bytes + an optional MIME type. Those bytes become a plain Blob — the image-to-text pipeline's ImageInput union directly accepts Blob (verified against the installed @huggingface/transformers 4.2.0 type declarations, alongside string | RawImage | URL | HTMLCanvasElement | OffscreenCanvas), so building a Blob needs no peer import at all — Blob is a cross-env global (Node 18+ and every browser). This keeps the adapter's hot path peer-free until the pipeline itself is resolved, and means fake-pipeline unit tests never load @huggingface/transformers.
@huggingface/transformers is an optional peer dependency, imported lazily (only inside makeDefaultCreatePipeline, i.e. only when no pipeline/createPipeline override is supplied).
Classes
| Class | Description |
|---|---|
| TransformersJsCaptionAdapter | Caption (image-to-text) adapter for transformers.js's image-to-text pipeline. |