Views
No views yet
1from diffusers.models import AutoencoderKL
2from flextok.utils.demo import imgs_from_urls
3
4vae = AutoencoderKL.from_pretrained(
5 'EPFL-VILAB/flextok_vae_c16', low_cpu_mem_usage=False
6).eval()
7
8# Load example images of shape (B, 3, H, W), normalized to [-1,1]
9imgs = imgs_from_urls(urls=['https://storage.googleapis.com/flextok_site/nb_demo_images/0.png'])
10
11# Autoencode with the VAE
12latents = vae.encode(imgs).latent_dist.sample() # Shape (B, 8, H//8, W//8)
13reconst = vae.decode(latents).sample # Shape (B, 3, H, W)@article{flextok,
title={{FlexTok}: Resampling Images into 1D Token Sequences of Flexible Length},
author={Roman Bachmann and Jesse Allardice and David Mizrahi and Enrico Fini and O{\u{g}}uzhan Fatih Kar and Elmira Amirloo and Alaaeldin El-Nouby and Amir Zamir and Afshin Dehghan},
journal={arXiv 2025},
year={2025},
}