This release adds support for image-to-image translation (e.g., super-resolution) with Swin2SR models.
| Side-by-side (full) | Animated (zoomed) |
|---|---|
As always, you can get started in just a few lines of code!
import { pipeline } from '@xenova/transformers';
let url = 'https://huggingface.co/spaces/jjourney1125/swin2sr/resolve/main/testsets/real-inputs/0855.jpg';
let upscaler = await pipeline('image-to-image', 'Xenova/swin2SR-compressed-sr-x4-48');
let output = await upscaler(url);
// RawImage {
// data: Uint8Array(12582912) [165, 166, 163, ...],
// width: 2048,
// height: 2048,
// channels: 3
// }
We also added support for 4 new architectures, bringing the total up to 57! ๐คฏ
TrOCR for optical character recognition (OCR).
import { pipeline } from '@xenova/transformers';
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/handwriting.jpg';
let captioner = await pipeline('image-to-text', 'Xenova/trocr-small-handwritten');
let output = await captioner(url);
// [{ generated_text: 'Mr. Brown commented icily.' }]
Added in https://github.com/xenova/transformers.js/pull/375. See here for the list of available models.
Swin2SR for super-resolution and image restoration.
import { pipeline } from '@xenova/transformers';
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/butterfly.jpg';
let upscaler = await pipeline('image-to-image', 'Xenova/swin2SR-classical-sr-x2-64');
let output = await upscaler(url);
// RawImage {
// data: Uint8Array(786432) [ 41, 31, 24, 43, ... ],
// width: 512,
// height: 512,
// channels: 3
// }
Added in https://github.com/xenova/transformers.js/pull/381. See here for the list of available models.
Mistral and Falcon for text-generation. Added in https://github.com/xenova/transformers.js/pull/379. Note: Other than testing models, we haven't yet converted any of the larger (โฅ7B parameter) models. Stay tuned for more updates on this!
text2text-generation pipeline output inconsistency w/ python library in https://github.com/xenova/transformers.js/pull/384Full Changelog: https://github.com/xenova/transformers.js/compare/2.7.0...2.8.0
Fetched April 7, 2026