Emuru

blowing-up-groundhogs
Texto a imagen

Emuru es un modelo generativo condicional presentado en CVPR 2025 para generación de imágenes estilizadas. Combina un decodificador basado en T5 con un autoencoder variacional AutoencoderKL para generar imágenes a partir de texto y una imagen de estilo de referencia. El modelo codifica el texto de estilo, el texto de generación y la imagen de estilo, predice tokens latentes autoregresivamente y los decodifica como una imagen sintetizada.

Como usar

Ejemplo mínimo de uso en Python:

import torch
from PIL import Image
from transformers import AutoModel
from huggingface_hub import hf_hub_download
from torchvision.transforms import functional as F

def load_image(img_path):
    img = Image.open(img_path).convert("RGB")
    # Resize the image to have a fixed height of 64 pixels
    img = img.resize((img.width * 64 // img.height, 64))
    img = F.to_tensor(img)
    img = F.normalize(img, [0.5], [0.5])
    return img

# 1. Load the model
model = AutoModel.from_pretrained("blowing-up-groundhogs/emuru", trust_remote_code=True)
model.cuda() # Move to GPU if available

# 2. Prepare your inputs
style_text = 'THE JOLLY IS "U"'
gen_text = 'EMURU'
img_path = hf_hub_download(repo_id="blowing-up-groundhogs/emuru", filename="sample.png")
style_img = load_image(img_path)
style_img = style_img.cuda()

# 3. Generate an image
generated_pil_image = model.generate(
    style_text=style_text,
    gen_text=gen_text,
    style_img=style_img,
    max_new_tokens=64
)

# 4. Save the result
generated_pil_image.save("generated_image.png")

Generación por lotes:

style_texts = ['THE JOLLY IS "U"', 'THE JOLLY IS "M"', 'THE JOLLY IS "R"']
gen_texts = ['EMURU', 'EMURU', 'EMURU']
style_imgs = torch.stack([style_img, style_img, style_img], dim=0) # shape: (batch_size, C, H, W)
lengths = [style_img.size(-1), style_img.size(-1), style_img.size(-1)]

output_images = model.generate_batch(
    style_texts=style_texts,
    gen_texts=gen_texts,
    style_imgs=style_imgs,
    lengths=lengths,
    max_new_tokens=64
)

# `output_images` is a list of PIL images
for idx, pil_img in enumerate(output_images):
    pil_img.save(f"batch_generated_image_{idx}.png")

Funcionalidades

Generación de imagen condicionada por texto e imagen de estilo.
Arquitectura con T5ForConditionalGeneration como decodificador textual y AutoencoderKL como VAE.
Permite fusionar texto de estilo, texto de contenido y una imagen de referencia.
Soporta generación individual con generate y generación por lotes con generate_batch.
Distribuido en formato Safetensors con licencia MIT.
Modelo de 0.7B parámetros en tensor F32.

Casos de uso

Generación de imágenes estilizadas a partir de una imagen de referencia y prompts textuales.
Manipulación visual y prototipado de diseño basado en descripciones textuales.
Creación de texto visual o imágenes tipográficas con estilo transferido.
Demostraciones educativas o de investigación sobre modelado generativo autoregresivo con T5 y VAE.