# Leffa: Controllable Person Image Generation with Flow Fields in Attention

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/franciszzj-leffa
Generated for open source discovery and AI-assisted research.

Leffa is a unified framework for controllable person image generation, enabling precise manipulation of appearance through virtual try-on and pose via pose transfer. This project addresses the common issue of fine-grained textural detail distortion by learning flow fields in attention, guiding target queries to correct reference keys. It achieves state-of-the-art performance, maintaining high image quality while significantly reducing detail distortion.

GitHub: https://github.com/franciszzj/Leffa
OSRepos URL: https://osrepos.com/repo/franciszzj-leffa

## Summary

Leffa is a unified framework for controllable person image generation, enabling precise manipulation of appearance through virtual try-on and pose via pose transfer. This project addresses the common issue of fine-grained textural detail distortion by learning flow fields in attention, guiding target queries to correct reference keys. It achieves state-of-the-art performance, maintaining high image quality while significantly reducing detail distortion.

## Topics

- Python
- Computer Vision
- Image Generation
- Deep Learning
- Virtual Try-on
- Pose Transfer
- Diffusion Models
- CVPR 2025

## Repository Information

Last analyzed by OSRepos: Sun Oct 12 2025 02:40:34 GMT+0100 (Western European Summer Time)
Detail views: 3
GitHub clicks: 1

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

**Leffa** (Learning Flow Fields in Attention) is a cutting-edge, unified framework designed for controllable person image generation. Accepted to CVPR 2025, Leffa enables precise manipulation of both appearance, through virtual try-on, and pose, via pose transfer. Traditional methods often struggle with distorting fine-grained textural details from reference images, despite achieving high overall image quality. Leffa tackles this by explicitly guiding the target query to attend to the correct reference key within the attention layer during training, using a regularization loss on top of the attention map. This innovative approach significantly reduces fine-grained detail distortion while maintaining exceptional image quality.

<div align="center">
  <img src="https://huggingface.co/franciszzj/Leffa/resolve/main/assets/teaser.png" alt="Leffa Teaser Image" width="100%" height="auto"/>
</div>

## Installation

To get started with Leffa, follow these steps to set up your environment:

shell
conda create -n leffa python==3.10
conda activate leffa
cd Leffa
pip install -r requirements.txt


## Examples

Leffa offers robust capabilities for both virtual try-on and pose transfer. The project includes a Gradio application for easy local execution and demonstration. You can also explore the official HuggingFace demo for interactive use. The visualization below showcases Leffa's ability to generate high-quality images with greatly reduced distortion of fine-grained details compared to other methods.

<div align="center">
  <img src="https://huggingface.co/franciszzj/Leffa/resolve/main/assets/vis_result.png" alt="Leffa Visualization Results" width="100%" height="auto"/>
</div>

To run the Gradio app locally:

shell
python app.py


## Why Use Leffa?

Leffa stands out as a powerful tool for person image generation due to several key advantages:

*   **State-of-the-Art Performance:** Achieves superior results in both virtual try-on and pose transfer tasks.
*   **Reduced Detail Distortion:** Its unique "flow fields in attention" mechanism effectively preserves fine-grained textural details from reference images.
*   **Unified Framework:** Provides a single, cohesive solution for two major controllable person image generation tasks.
*   **Model-Agnostic Loss:** The proposed regularization loss can be applied to improve other diffusion models, showcasing its versatility.
*   **Active Development:** Regularly updated with performance improvements and new features, as seen in the project's news section.

## Links

*   **GitHub Repository:** [Leffa](https://github.com/franciszzj/Leffa)
*   **Paper:** [Learning Flow Fields in Attention for Controllable Person Image Generation](https://arxiv.org/abs/2412.08486)
*   **HuggingFace Demo:** [Leffa Demo](https://huggingface.co/spaces/franciszzj/Leffa)
*   **HuggingFace Models:** [Leffa Models](https://huggingface.co/franciszzj/Leffa)