anaksor-ocr
Sokheng · Kit
Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…
Previews FLUX.2 image generation in real time with a tiny autoencoder that shares the FLUX.2 VAE's latent format. For image app developers and people with limited memory.
TAEF2 is a kit in the Developer category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page, a zip of its files. Nothing in it runs by itself.
pip install -U huggingface_hub hf download madebyollin/taef2
TAEF2 is a tiny autoencoder for FLUX.2, made by madebyollin. It speaks the same latent format as the FLUX.2 VAE, so it can stand in for it. The card names two uses: real-time previews while FLUX.2 generates, and encoding or decoding when resources are tight. This repository holds the weights as safetensors files.
It suits developers who build image generation tools on FLUX.2 and people who run it on limited hardware.
| Industry | Who uses it | How they use it | Example |
|---|---|---|---|
| Software | Image app developers | Show a live preview while FLUX.2 generates | Preview a render before it finishes |
| Hobby | People with small GPUs | Encode and decode latents with less memory | Run FLUX.2 Klein with CPU offloading |
| Research | Model researchers | Compare tiny and full autoencoders | Check TAEF2 against the full FLUX.2 VAE |
People who only want to make images with a ready app can skip it, since this is a component for pipelines.
| Use case | Who | What they get back |
|---|---|---|
| Live previews | App developers | A quick decoded image while generation runs |
| Low-memory decoding | Hobbyists | Images decoded with a much smaller model |
| Comparison tests | Researchers | Side-by-side results against two other autoencoders |
You need a few things first.
pip install -U huggingface_hub hf download madebyollin/taef2
TAEF2 is not properly integrated into diffusers yet, so you wrap it in a small class that looks like a diffusers VAE. Then you assign it to the pipeline's vae and generate as usual.
# Construction
from taesd import TAESD
import torch
import safetensors.torch as stt
from diffusers.utils.accelerate_utils import apply_forward_hook
def convert_diffusers_sd_to_taesd(sd):
out = {}
for k, v in sd.items():
encdec, _layers, index, *suffix = k.split(".")
offset = 0
if encdec == "decoder":
offset = +1
out[".".join([encdec, str(int(index)+offset), *suffix])] = v
return out
class DotDict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
class DiffusersTAEF2Wrapper(torch.nn.Module):
def __init__(self):
super().__init__()
self.dtype = torch.bfloat16
self.taesd = TAESD(encoder_path=None, decoder_path=None, latent_channels=32, arch_variant="flux_2").to(self.dtype)
self.taesd.load_state_dict(convert_diffusers_sd_to_taesd(stt.load_file("taef2.safetensors")))
self.bn = torch.nn.BatchNorm2d(128, affine=False, eps=0.0) # default bn
self.config = DotDict(batch_norm_eps=self.bn.eps)
@apply_forward_hook
def encode(self, x):
return DotDict(latent_dist=DotDict(sample=lambda : self.taesd.encoder(x.to(self.dtype).mul(0.5).add_(0.5)).to(x.dtype)))
@apply_forward_hook
def decode(self, x, return_dict=True):
x = self.taesd.decoder(x.to(self.dtype)).mul(2).sub_(1).clamp_(-1, 1).to(x.dtype)
return dict(sample=x) if return_dict else x,
taef2_diffusers = DiffusersTAEF2Wrapper().eval().requires_grad_(False)
# Usage
from diffusers import Flux2KleinPipeline
device = "cuda"
dtype = torch.bfloat16
pipe = Flux2KleinPipeline.from_pretrained("black-forest-labs/FLUX.2-klein-4B", torch_dtype=dtype)
pipe.vae = taef2_diffusers
pipe.enable_sequential_cpu_offload() # pipe.enable_model_cpu_offload() # pipe = pipe.to(device)
prompt = "A slice of delicious New York-style berry cheesecake"
image = pipe(
prompt=prompt,
height=1024,
width=1024,
guidance_scale=1.0,
num_inference_steps=4,
generator=torch.Generator(device="cpu").manual_seed(0)
).images[0]
image.save("flux-klein.png")
image| Tool | What it does |
|---|---|
| taesd.py | Provides the TAESD class that the wrapper builds on |
| taef2.safetensors | Holds the TAEF2 weights |
| DiffusersTAEF2Wrapper | Makes TAEF2 look like a diffusers VAE |
| Flux2KleinPipeline | The FLUX.2 Klein pipeline whose vae you replace |
| enable_sequential_cpu_offload | Moves parts of the model to the CPU to save GPU memory |
You ask the pipeline for a slice of New York-style berry cheesecake at 1024 by 1024 with 4 steps. The decoder you swapped in produces the picture, and the script saves it as flux-klein.png.
An autoencoder converts between pictures and the compact latent form that image models work in. If you are new, run the card's example as written and look at flux-klein.png.
Because TAEF2 keeps the same latent interface as the FLUX.2 VAE, you can swap it into a pipeline without changing anything else. The wrapper shifts decoder layer indices when it converts the diffusers weights, uses 32 latent channels with the flux_2 architecture variant, and runs in BF16.
Previews FLUX.2 image generation in real time with a tiny autoencoder that shares the FLUX.2 VAE's latent format. For image app developers and people with limited memory.
Made by madebyollin on Hugging Face. These notes are Mindket's, written from its model page and model card; the model's own files and license are on Hugging Face.
What it is: TAEF2 is a tiny autoencoder for FLUX.2, made by madebyollin. It speaks the same latent format as the FLUX.2 VAE, so it can stand in for it. The card names two uses: real-time previews while FLUX.2 generates, and encoding or decoding when resources are tight. This repository holds the weights as safetensors files.
Who it suits: It suits developers who build image generation tools on FLUX.2 and people who run it on limited hardware.
Industry | Who uses it | How they use it | Example
Software | Image app developers | Show a live preview while FLUX.2 generates | Preview a render before it finishes
Hobby | People with small GPUs | Encode and decode latents with less memory | Run FLUX.2 Klein with CPU offloading
Research | Model researchers | Compare tiny and full autoencoders | Check TAEF2 against the full FLUX.2 VAE
People who only want to make images with a ready app can skip it, since this is a component for pipelines.
Where to use it:
Use case | Who | What they get back
Live previews | App developers | A quick decoded image while generation runs
Low-memory decoding | Hobbyists | Images decoded with a much smaller model
Comparison tests | Researchers | Side-by-side results against two other autoencoders
How to set it up: You need a few things first.
pip install -U huggingface_hub
hf download madebyollin/taef2
How to use it: TAEF2 is not properly integrated into diffusers yet, so you wrap it in a small class that looks like a diffusers VAE. Then you assign it to the pipeline's vae and generate as usual.
# Construction
from taesd import TAESD
import torch
import safetensors.torch as stt
from diffusers.utils.accelerate_utils import apply_forward_hook
def convert_diffusers_sd_to_taesd(sd):
out = {}
for k, v in sd.items():
encdec, _layers, index, *suffix = k.split(".")
offset = 0
if encdec == "decoder":
offset = +1
out[".".join([encdec, str(int(index)+offset), *suffix])] = v
return out
class DotDict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
class DiffusersTAEF2Wrapper(torch.nn.Module):
def __init__(self):
super().__init__()
self.dtype = torch.bfloat16
self.taesd = TAESD(encoder_path=None, decoder_path=None, latent_channels=32, arch_variant="flux_2").to(self.dtype)
self.taesd.load_state_dict(convert_diffusers_sd_to_taesd(stt.load_file("taef2.safetensors")))
self.bn = torch.nn.BatchNorm2d(128, affine=False, eps=0.0) # default bn
self.config = DotDict(batch_norm_eps=self.bn.eps)
@apply_forward_hook
def encode(self, x):
return DotDict(latent_dist=DotDict(sample=lambda : self.taesd.encoder(x.to(self.dtype).mul(0.5).add_(0.5)).to(x.dtype)))
@apply_forward_hook
def decode(self, x, return_dict=True):
x = self.taesd.decoder(x.to(self.dtype)).mul(2).sub_(1).clamp_(-1, 1).to(x.dtype)
return dict(sample=x) if return_dict else x,
taef2_diffusers = DiffusersTAEF2Wrapper().eval().requires_grad_(False)
# Usage
from diffusers import Flux2KleinPipeline
device = "cuda"
dtype = torch.bfloat16
pipe = Flux2KleinPipeline.from_pretrained("black-forest-labs/FLUX.2-klein-4B", torch_dtype=dtype)
pipe.vae = taef2_diffusers
pipe.enable_sequential_cpu_offload() # pipe.enable_model_cpu_offload() # pipe = pipe.to(device)
prompt = "A slice of delicious New York-style berry cheesecake"
image = pipe(
prompt=prompt,
height=1024,
width=1024,
guidance_scale=1.0,
num_inference_steps=4,
generator=torch.Generator(device="cpu").manual_seed(0)
).images[0]
image.save("flux-klein.png")
image
Tool | What it does
taesd.py | Provides the TAESD class that the wrapper builds on
taef2.safetensors | Holds the TAEF2 weights
DiffusersTAEF2Wrapper | Makes TAEF2 look like a diffusers VAE
Flux2KleinPipeline | The FLUX.2 Klein pipeline whose vae you replace
enable_sequential_cpu_offload | Moves parts of the model to the CPU to save GPU memory
Example: You ask the pipeline for a slice of New York-style berry cheesecake at 1024 by 1024 with 4 steps. The decoder you swapped in produces the picture, and the script saves it as flux-klein.png.
For newcomers and experts: An autoencoder converts between pictures and the compact latent form that image models work in. If you are new, run the card's example as written and look at flux-klein.png.
Because TAEF2 keeps the same latent interface as the FLUX.2 VAE, you can swap it into a pipeline without changing anything else. The wrapper shifts decoder layer indices when it converts the diffusers weights, uses 32 latent channels with the flux_2 architecture variant, and runs in BF16.
FLUX.2 pipeline produces latents
Wrapper passes them to the TAEF2 decoder
Decoder returns pixels scaled to minus 1 to 1
Image is shown or saved as a file
Good to know:
Download its files with Hugging Face's command line:
pip install -U huggingface_hub
hf download madebyollin/taef2
Then follow the usage in its model card. Nothing in this kit runs by itself.
README.md 7 KB
Sokheng · Kit
Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…
Qwen · Kit
Qwen2.5-7B-Instruct as GGUF files in eight quantization sizes, to chat with locally through llama.cpp. For people who want a capable 7.6B model on their own co…
ACE-Step · Kit
Generates music from text with a 4B diffusion decoder, 50 steps and guidance control, aiming for higher audio quality than the base. For creators with a GPU of…
alirezarezvani · Skill
Adds 411 ready-made skills for Claude Code and other coding agents, grouped by role from engineering and product to marketing, finance and compliance. Installs…
block · Kit
Self-hostable workspace where people and AI agents share the same rooms, built on a Nostr relay that logs every action as a signed event. For teams that want t…
backnotprop · Kit
Opens your AI coding agent's plans, specs and code changes in a browser so you can annotate or comment on them and send the feedback straight back to the agent.