HunyuanImage-2.1

Tencent-Hunyuan长期未更新

腾讯混元开源的 2K 高分辨率文生图扩散模型,能根据文字直接生成高清图像,兼顾生成效率与画质。

HunyuanImage-2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation​

暂无版本676star55fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/Tencent-Hunyuan/HunyuanImage-2.1.git
cd HunyuanImage-2.1
pip install -r requirements.txt
pip install flash-attn==2.7.3 --no-build-isolation
硬件要求按 README 说明

需支持 CUDA 的 NVIDIA GPU,仅支持 Linux;开启 CPU offload 与 FP8 量化时,生成 2048x2048 图像最低需 24GB 显存,显存充足可关闭 offload 提速。

24G 显存可跑支持 Apple Silicon需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

腾讯 17B 文生图扩散模型,专注生成 2K 高分辨率图像,支持中英文提示词

腾讯混元开源的 2K 高分辨率文生图扩散模型,能根据文字直接生成高清图像,兼顾生成效率与画质。

核心能力

  • 两阶段架构:基础文生图模型加 Refiner 提升清晰度
  • 双文本编码器:MLLM 对齐语义,ByT5 增强多语言文字渲染
  • 支持 1:1、16:9、9:16、4:3、3:4、3:2、2:3 多种宽高比
  • 提供蒸馏版模型,8 步推理即可出图
  • 内置 Prompt 增强,自动改写提示词提升画质

容易踩的坑

需按 ckpts/checkpoints-download.md 单独下载预训练权重;模型仅支持 2K 生成,用 1K 分辨率会产生伪影;flash-attn 需指定 2.7.3 版本并加 --no-build-isolation 安装。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    中文阅读

    HunyuanImage-2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation​


    This repo contains PyTorch model definitions, pretrained weights and inference/sampling code for our HunyuanImage-2.1. You can directly try our model on Official website(官网) and find more visualizations on our project page.

    🔥🔥🔥 Latest Updates

    • September 18, 2025: ✨ Try the PromptEnhancer-32B model for higher-quality prompt enhancement!​.
    • September 18, 2025: ✨ ComfyUI workflow of HunyuanImage-2.1 is available now!
    • September 16, 2025: 👑 We achieved the Top1 on Arena's leaderboard for text-to-image open-source models. Leaderboard
    • September 12, 2025: 🚀 Released FP8 quantized models! Making it possible to generate 2K images with only 24GB GPU memory!
    • September 8, 2025: 🚀 Released inference code and model weights for HunyuanImage-2.1.

    Introduction

    We are excited to introduce HunyuanImage-2.1, a 17B text-to-image model that is capable of generating 2K (2048 × 2048) resolution images.

    Our architecture consists of two stages:

    1. ​Base text-to-image Model:​​ The first stage is a text-to-image model that utilizes two text encoders: a multimodal large language model (MLLM) to improve image-text alignment, and a multi-language, character-aware encoder to enhance text rendering across various languages.
    2. Refiner Model: The second stage introduces a refiner model that further enhances image quality and clarity, while minimizing artifacts.

    👑 We achieved the Top1 on Arena's leaderboard for text-to-image open-source models.

    🎉 HunyuanImage-2.1 Key Features

    • High-Quality Generation: Efficiently produces ultra-high-definition (2K) images with cinematic composition.
    • Multilingual Support: Provides native support for both Chinese and English prompts.
    • Advanced Architecture: Built on a multi-modal, single- and dual-stream combined DiT (Diffusion Transformer) backbone.
    • Glyph-Aware Processing: Utilizes ByT5's text rendering capabilities for improved text generation accuracy.
    • Flexible Aspect Ratios: Supports a variety of image aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3).
    • Prompt Enhancement: Automatically rewrites prompts to improve descriptive accuracy and visual quality.

    📜 System Requirements

    Hardware and OS Requirements:

    • NVIDIA GPU with CUDA support.

      Minimum requrement for now: 24 GB GPU memory for 2048x2048 image generation.

      Note: The memory requirements above are measured with model CPU offloading and FP8 quantization enabled. If your GPU has sufficient memory, you may disable offloading for improved inference speed.

    • Supported operating system: Linux.

    🛠️ Dependencies and Installation

    1. Clone the repository:
    git clone https://github.com/Tencent-Hunyuan/HunyuanImage-2.1.git
    cd HunyuanImage-2.1
    
    1. Install dependencies:
    pip install -r requirements.txt
    pip install flash-attn==2.7.3 --no-build-isolation
    

    🧱 Download Pretrained Models

    The details of download pretrained models are shown here.

    🔑 Usage

    Prompt Enhancement

    Prompt enhancement plays a crucial role in enabling our model to generate high-quality images. By writing longer and more detailed prompts, the generated image will be significantly improved. We encourage you to craft comprehensive and descriptive prompts to achieve the best possible image quality.

    We highly recommend you to try the PromptEnhancer-32B model for higher-quality prompt enhancement.

    Text to Image

    HunyuanImage-2.1 only supports 2K image generation (e.g. 2048x2048 for 1:1 images, 2560x1536 for 16:9 images, etc.). Generating images with 1K resolution will result in artifacts.

    Additionally, we highly recommend using the full generation pipeline for better quality (i.e. enabling prompt enhancement and refinment).

    model typemodel namedescriptionnum_inference_stepsguidance_scaleshift
    Base text-to-image Modelhunyuanimage2.1Undistilled model for the best quality.503.55
    Distilled text-to-image Modelhunyuanimage2.1-distilledDistilled model for faster inference83.254
    Refinerhunyuanimage-refinerThe refiner modelN/AN/AN/A
    import os
    os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
    import torch
    from hyimage.diffusion.pipelines.hunyuanimage_pipeline import HunyuanImagePipeline
    
    # Supported model_name: hunyuanimage-v2.1, hunyuanimage-v2.1-distilled
    model_name = "hunyuanimage-v2.1"
    pipe = HunyuanImagePipeline.from_pretrained(model_name=model_name, use_fp8=True)
    pipe = pipe.to("cuda")
    
    # The input prompt
    prompt = "A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, wearing a red knitted scarf and a red beret with the word \"Tencent\" on it, holding a paintbrush with a focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."
    
    
    # Generate with different aspect ratios
    aspect_ratios = {
        "16:9": (2560, 1536),
        "4:3": (2304, 1792),
        "1:1": (2048, 2048),
        "3:4": (1792, 2304),
        "9:16": (1536, 2560),
    }
    
    width, height = aspect_ratios["1:1"]
    
    image = pipe(
        prompt=prompt,
        width=width,
        height=height,
        # disable the reprompt if you already use the prompt enhancement to enhance the prompt
        use_reprompt=False,  # Enable prompt enhancement (which may result in higher GPU memory usage)
        use_refiner=True,   # Enable refiner model
        # For the distilled model, use 8 steps for faster inference.
        # For the non-distilled model, use 50 steps for better quality.
        num_inference_steps=8 if "distilled" in model_name else 50, 
        guidance_scale=3.25 if "distilled" in model_name else 3.5,
        shift=4 if "distilled" in model_name else 5,
        seed=649151,
    )
    
    image.save("generated_image.png")
    

    More Cases

    Our model can follow complex instructions to generate high‑quality, creative images.

    We recommend using longer, more detailed prompts. You can also try the prompts we provide.

    To improve the quality and detail of generated images, we use a prompt rewriting model. This model automatically enhances user-provided text prompts by adding detailed and descriptive information.

    📈 Comparisons

    SSAE Evaluation

    SSAE (Structured Semantic Alignment Evaluation) is an intelligent evaluation metric for image-text alignment based on advanced multimodal large language models (MLLMs). We extracted 3500 key points across 12 categories, then used multimodal large language models to automatically evaluate and score by comparing the generated images with these key points based on the visual content of the images. Mean Image Accuracy represents the image-wise average score across all key points, while Global Accuracy directly calculates the average score across all key points.

    From the SSAE evaluation results, our model has currently achieved the optimal performance among open-source models in terms of semantic alignment, and is very close to the performance of closed-source commercial models (GPT-Image).

    GSB Evaluation

    We adopted the GSB evaluation method commonly used to assess the relative performance between two models from an overall image perception perspective. In total, we utilized 1000 text prompts, generating an equal number of image samples for all compared models in a single run. For a fair comparison, we conducted inference only once for each prompt, avoiding any cherry-picking of results. When comparing with the baseline methods, we maintained the default settings for all selected models. The evaluation was performed by more than 100 professional evaluators. From the results, HunyuanImage 2.1 achieved a relative win rate of -1.36% against Seedream3.0 (closed-source) and 2.89% outperforming Qwen-Image (open-source). The GSB evaluation results demonstrate that HunyuanImage 2.1, as an open-source model, has reached a level of image generation quality comparable to closed-source commercial models (Seedream3.0), while showing certain advantages in comparison with similar open-source models (Qwen-Image). This fully validates the technical advancement and practical value of HunyuanImage 2.1 in text-to-image generation tasks.

    Contact

    Feel free to join our Discord server or join our WeChat groups—not only to exchange ideas and explore collaboration, but also to ask any questions you might have. You're welcome to open an issue or submit a pull request on GitHub. Your feedback is valuable to us and helps drive HunyuanImage forward. Thank you for being a part of our community!

    🔗 BibTeX

    If you find this project useful for your research and applications, please cite as:

    @misc{HunyuanImage-2.1,
      title={HunyuanImage 2.1: An Efficient Diffusion Model for High-Resolution (2K) Text-to-Image Generation},
      author={Tencent Hunyuan Team},
      year={2025},
      howpublished={\url{https://github.com/Tencent-Hunyuan/HunyuanImage-2.1}},
    }
    

    Acknowledgements

    We would like to thank the following open-source projects and communities for their contributions to open research and exploration: Qwen, FLUX, diffusers and HuggingFace.

    Github Star History