Downloads · 30 days
12
12% of all-time downloads
TrungNt14/EMAVQ-16384-f8-d256
EMAVQ-16384-f8-d256 is a image-to-image model from TrungNt14. Use it when you need one image transformed into another. The card lists the license as apache-2.0.
This repository contains the official pre-trained weights for EMA-VQGAN-16384-f8-d256 (Stage 1 Image Quantization Model), serving as the visual discrete token backbone for the TextArtT5 project.
Downloads · 30 days
12
12% of all-time downloads
All-time downloads
99
Public
Parameters
94.5M
1.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors378 MB · 100%
From the Hugging Face model README
This repository contains the official pre-trained weights for EMA-VQGAN-16384-f8-d256 (Stage 1 Image Quantization Model), serving as the visual discrete token backbone for the TextArtT5 project.
For full source code, training pipelines, dataset details, and the Stage 2 Autoregressive Transformer, please visit our main GitHub repository:
Make sure you have cloned the TextArtT5 GitHub repository to access the model architecture classes.
import torch
from PIL import Image
from torchvision.transforms import v2
from src.model.vq_model import EMAVQModel
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.is_bf16_supported() else torch.float32
# 1. Load Pre-trained Model directly from Hugging Face
model = EMAVQModel.from_pretrained("TrungNt14/EMAVQ-16384-f8-d256").to(device=device, dtype=dtype)
model.eval()
# 2. Image Preprocessing Pipeline
image_size = (256, 256)
transform = v2.Compose([
v2.Resize(max(image_size), interpolation=v2.InterpolationMode.BICUBIC),
v2.CenterCrop(image_size),
v2.ToImage(),
v2.ToDtype(dtype, scale=True),
v2.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
])
# 3. Process Input Image
img = Image.open("path/to/your/image.png").convert("RGB")
img_tensor = transform(img).unsqueeze(0).to(device)
# 4. Quantize & Reconstruct
with torch.no_grad():
# Encode to discrete codebook latents
quant, _, info = model.encode(img_tensor)
# Decode back to image space
reconstruction = model.decode(quant)