Views
No views yet
npm i @huggingface/transformersXenova/swin2SR-compressed-sr-x4-48.1import { pipeline } from '@huggingface/transformers';
2
3// Create image-to-image pipeline
4const upscaler = await pipeline('image-to-image', 'Xenova/swin2SR-compressed-sr-x4-48', {
5 dtype: 'fp32', // Options: 'fp32', 'fp16', 'q8', 'q4'
6});
7
8// Upscale an image
9const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/butterfly.jpg';
10const output = await upscaler(url);
11// RawImage {
12// data: Uint8Array(3145728) [ ... ],
13// width: 1024,
14// height: 1024,
15// channels: 3
16// }
17
18// (Optional) Save the upscaled image
19output.save('upscaled.png');

onnx).