Skip to content

Conversation

@xenova
Copy link
Collaborator

@xenova xenova commented Mar 20, 2024

This PR fixes a bug encountered when padding non-square images for swin2sr-like models. It also adds support for the new APISR super-resolution models.

Example: Upscale an image with Xenova/4x_APISR_GRL_GAN_generator-onnx.

import { pipeline } from '@xenova/transformers';

// Create image-to-image pipeline
const upscaler = await pipeline('image-to-image', 'Xenova/4x_APISR_GRL_GAN_generator-onnx', {
    quantized: false,
});

// Upscale an image
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/anime.png';
const output = await upscaler(url);
// RawImage {
//   data: Uint8Array(16588800) [ ... ],
//   width: 2560,
//   height: 1920,
//   channels: 3
// }

// (Optional) Save the upscaled image
output.save('upscaled.png');
See example output

Input image:
image

Output image:
image

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova xenova merged commit 40cdd36 into main Mar 20, 2024
@xenova xenova deleted the fix-channel-format branch July 10, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants