News | Quick Start | Usage Tips | Limitations | Online Demos | Citation
flash-attn. Users can still install it for optimal performance.OmniGen2 is a powerful and efficient generative model. Unlike OmniGen v1, OmniGen2 features two distinct decoding pathways for text and image modalities, utilizing unshared parameters and a decoupled image tokenizer. OmniGen2 has competitive performance across four primary capabilities:
We will release the training code and dataset. Stay tuned!
Some good cases of OmniGen2:
Demonstrations.
Good demonstrations of OmniGen2's image editing capabilities.
Good demonstrations of OmniGen2's in-context generation capabilities.
# 1. Clone the repo
git clone git@github.com:VectorSpaceLab/OmniGen2.git
cd OmniGen2
# 2. (Optional) Create a clean Python environment
conda create -n omnigen2 python=3.11
conda activate omnigen2
# 3. Install dependencies
# 3.1 Install PyTorch (choose correct CUDA version)
pip install torch==2.6.0 torchvision --extra-index-url https://download.pytorch.org/whl/cu124
# 3.2 Install other required packages
pip install -r requirements.txt
# Note: Version 2.7.4.post1 is specified for compatibility with CUDA 12.4.
# Feel free to use a newer version if you use CUDA 12.6 or they fixed this compatibility issue.
# OmniGen2 runs even without flash-attn, though we recommend install it for best performance.
pip install flash-attn==2.7.4.post1 --no-build-isolation
# Install PyTorch from a domestic mirror
pip install torch==2.6.0 torchvision --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu124
# Install other dependencies from Tsinghua mirror
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Note: Version 2.7.4.post1 is specified for compatibility with CUDA 12.4.
# Feel free to use a newer version if you use CUDA 12.6 or they fixed this compatibility issue.
# OmniGen2 runs even without flash-attn, though we recommend install it for best performance.
pip install flash-attn==2.7.4.post1 --no-build-isolation -i https://pypi.tuna.tsinghua.edu.cn/simple
# Visual Understanding
bash example_understanding.sh
# Text-to-image generation
bash example_t2i.sh
# Instruction-guided image editing
bash example_edit.sh
# In-context generation
bash example_in_context_generation.sh
Online Demo: HF Spaces. Beyond Hugging Face Spaces, we are temporarily allocating additional GPU resources to ensure smooth access to the online demos. If you notice a long queue for a particular link, please try other links:
Web Application: You can also try the self-hosted OmniGen2 web application by visiting this link or scanning the QR code below:
OmniGen2 web.
# for only generating image
pip install gradio
python app.py
# Optional: Share demo with public link (You need to be able to access huggingface)
python app.py --share
# for generating image or text
pip install gradio
python app_chat.py
To achieve optimal results with OmniGen2, you can adjust the following key hyperparameters based on your specific use case.
text_guidance_scale: Controls how strictly the output adheres to the text prompt (Classifier-Free Guidance).image_guidance_scale: This controls how much the final image should resemble the input reference image.
max_pixels: Automatically resizes images when their total pixel count (width × height) exceeds this limit, while maintaining its aspect ratio. This helps manage performance and memory usage.
max_input_image_side_length: Maximum side length for input images.negative_prompt: Tell the model what you don't want to see in the image.
enable_model_cpu_offload: Reduces VRAM usage by nearly 50% with a negligible impact on speed.
enable_sequential_cpu_offload: Minimizes VRAM usage to less than 3GB, but at the cost of significantly slower performance.
cfg_range_start, cfg_range_end: Define the timestep range where CFG is applied. Per this paper, reducing cfg_range_end can significantly decrease inference time with a negligible impact on quality.scheduler: Choose between [euler, dpmsolver++]. Default is euler. For potentially better performance with fewer steps, try dpmsolver++.num_inference_step: Number of discretization steps for the ODE solver. Default is 50.enable_teacache: Whether or not enable teacache for faster inference.teacache_rel_l1_thresh: The threshold for accumulated L1 distance for the timestep embedding-modulated noisy input. It serves as an indicator of whether to cache the model output. You can modify the teacache_rel_l1_thresh parameter to achieve your desired trade-off between latency and visual quality. The default value of 0.05 provides approximately a 30% speedup compared to the baseline. Increasing this value can further reduce latency, but may result in some loss of detail.enable_taylorseer: Whether or not enable taylorseer for faster inference. When enabled, inference speed can improve by up to 2X, with negligible quality loss compared to the baseline.Some suggestions for improving generation quality:
Prioritize English The model currently performs best with English prompts.
Change instructions to enhance subject consistency. When the generated image does not align well with the input image, you can try the following methods to improve subject consistency:
See fine-tuning for details.
The current model sometimes does not follow instructions. You can increase the "Number of images per prompt" to generate multiple images at once, so you can choose the result you are satisfied with, or try different prompts. In our own experience, being as detailed as possible tends to work better.
The current model cannot decide the output image size by itself; the default size is 1024×1024. You need to set a specific size if you require a different one. When you input an image, we will set the output size to match the input image (this works best for editing tasks). If you want to modify just one image out of several, you should also set the output size to match the image you want to edit; otherwise, it may lead to low-quality outputs.
The in-context generation capability sometimes produces objects that differ from the original ones. Some suggested improvements are: increasing image_guidance_scale (it is recommended to set it to 3) can help alleviate this issue; using high-resolution images, increasing the size of the input image, and ensuring that the object to be used occupies a larger proportion of the image; and modifying the prompt. However, there is still a gap compared to GPT-4o.
Compared to OmniGen 1.0, although OmniGen 2 has made some improvements, many issues still remain. It may take multiple attempts to achieve a satisfactory result.
OmniGen2 natively requires an NVIDIA RTX 3090 or an equivalent GPU with approximately 17GB of VRAM. For devices with less VRAM, you can enable CPU Offload to run the model.
Performance Tip: To improve inference speed, consider decreasing the cfg_range_end parameter. Within a reasonable range, this has a negligible impact on output quality.
The following table details the inference performance of OmniGen2 on an A800 GPU:
Inference Efficiency of OmniGen2.
We’re honored and grateful for the support from the open source community. Here are some unofficial implementations contributed by the community(Currently, we have not confirmed whether there are no bugs. Please try to use the our official demo as much as possible.):
If you find this repository or our work useful, please consider giving a star ⭐ and citation 🦖, which would be greatly appreciated:
@article{wu2025omnigen2,
title={OmniGen2: Exploration to Advanced Multimodal Generation},
author={Chenyuan Wu and Pengfei Zheng and Ruiran Yan and Shitao Xiao and Xin Luo and Yueze Wang and Wanli Li and Xiyan Jiang and Yexin Liu and Junjie Zhou and Ze Liu and Ziyi Xia and Chaofan Li and Haoge Deng and Jiahao Wang and Kun Luo and Bo Zhang and Defu Lian and Xinlong Wang and Zhongyuan Wang and Tiejun Huang and Zheng Liu},
journal={arXiv preprint arXiv:2506.18871},
year={2025}
}
Jupyter Notebook
91.2%
Python
8.4%
News | Quick Start | Usage Tips | Limitations | Online Demos | Citation
flash-attn. Users can still install it for optimal performance.OmniGen2 is a powerful and efficient generative model. Unlike OmniGen v1, OmniGen2 features two distinct decoding pathways for text and image modalities, utilizing unshared parameters and a decoupled image tokenizer. OmniGen2 has competitive performance across four primary capabilities:
We will release the training code and dataset. Stay tuned!
Some good cases of OmniGen2:
Demonstrations.
Good demonstrations of OmniGen2's image editing capabilities.
Good demonstrations of OmniGen2's in-context generation capabilities.
# 1. Clone the repo
git clone git@github.com:VectorSpaceLab/OmniGen2.git
cd OmniGen2
# 2. (Optional) Create a clean Python environment
conda create -n omnigen2 python=3.11
conda activate omnigen2
# 3. Install dependencies
# 3.1 Install PyTorch (choose correct CUDA version)
pip install torch==2.6.0 torchvision --extra-index-url https://download.pytorch.org/whl/cu124
# 3.2 Install other required packages
pip install -r requirements.txt
# Note: Version 2.7.4.post1 is specified for compatibility with CUDA 12.4.
# Feel free to use a newer version if you use CUDA 12.6 or they fixed this compatibility issue.
# OmniGen2 runs even without flash-attn, though we recommend install it for best performance.
pip install flash-attn==2.7.4.post1 --no-build-isolation
# Install PyTorch from a domestic mirror
pip install torch==2.6.0 torchvision --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu124
# Install other dependencies from Tsinghua mirror
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Note: Version 2.7.4.post1 is specified for compatibility with CUDA 12.4.
# Feel free to use a newer version if you use CUDA 12.6 or they fixed this compatibility issue.
# OmniGen2 runs even without flash-attn, though we recommend install it for best performance.
pip install flash-attn==2.7.4.post1 --no-build-isolation -i https://pypi.tuna.tsinghua.edu.cn/simple
# Visual Understanding
bash example_understanding.sh
# Text-to-image generation
bash example_t2i.sh
# Instruction-guided image editing
bash example_edit.sh
# In-context generation
bash example_in_context_generation.sh
Online Demo: HF Spaces. Beyond Hugging Face Spaces, we are temporarily allocating additional GPU resources to ensure smooth access to the online demos. If you notice a long queue for a particular link, please try other links:
Web Application: You can also try the self-hosted OmniGen2 web application by visiting this link or scanning the QR code below:
OmniGen2 web.
# for only generating image
pip install gradio
python app.py
# Optional: Share demo with public link (You need to be able to access huggingface)
python app.py --share
# for generating image or text
pip install gradio
python app_chat.py
To achieve optimal results with OmniGen2, you can adjust the following key hyperparameters based on your specific use case.
text_guidance_scale: Controls how strictly the output adheres to the text prompt (Classifier-Free Guidance).image_guidance_scale: This controls how much the final image should resemble the input reference image.
max_pixels: Automatically resizes images when their total pixel count (width × height) exceeds this limit, while maintaining its aspect ratio. This helps manage performance and memory usage.
max_input_image_side_length: Maximum side length for input images.negative_prompt: Tell the model what you don't want to see in the image.
enable_model_cpu_offload: Reduces VRAM usage by nearly 50% with a negligible impact on speed.
enable_sequential_cpu_offload: Minimizes VRAM usage to less than 3GB, but at the cost of significantly slower performance.
cfg_range_start, cfg_range_end: Define the timestep range where CFG is applied. Per this paper, reducing cfg_range_end can significantly decrease inference time with a negligible impact on quality.scheduler: Choose between [euler, dpmsolver++]. Default is euler. For potentially better performance with fewer steps, try dpmsolver++.num_inference_step: Number of discretization steps for the ODE solver. Default is 50.enable_teacache: Whether or not enable teacache for faster inference.teacache_rel_l1_thresh: The threshold for accumulated L1 distance for the timestep embedding-modulated noisy input. It serves as an indicator of whether to cache the model output. You can modify the teacache_rel_l1_thresh parameter to achieve your desired trade-off between latency and visual quality. The default value of 0.05 provides approximately a 30% speedup compared to the baseline. Increasing this value can further reduce latency, but may result in some loss of detail.enable_taylorseer: Whether or not enable taylorseer for faster inference. When enabled, inference speed can improve by up to 2X, with negligible quality loss compared to the baseline.Some suggestions for improving generation quality:
Prioritize English The model currently performs best with English prompts.
Change instructions to enhance subject consistency. When the generated image does not align well with the input image, you can try the following methods to improve subject consistency:
See fine-tuning for details.
The current model sometimes does not follow instructions. You can increase the "Number of images per prompt" to generate multiple images at once, so you can choose the result you are satisfied with, or try different prompts. In our own experience, being as detailed as possible tends to work better.
The current model cannot decide the output image size by itself; the default size is 1024×1024. You need to set a specific size if you require a different one. When you input an image, we will set the output size to match the input image (this works best for editing tasks). If you want to modify just one image out of several, you should also set the output size to match the image you want to edit; otherwise, it may lead to low-quality outputs.
The in-context generation capability sometimes produces objects that differ from the original ones. Some suggested improvements are: increasing image_guidance_scale (it is recommended to set it to 3) can help alleviate this issue; using high-resolution images, increasing the size of the input image, and ensuring that the object to be used occupies a larger proportion of the image; and modifying the prompt. However, there is still a gap compared to GPT-4o.
Compared to OmniGen 1.0, although OmniGen 2 has made some improvements, many issues still remain. It may take multiple attempts to achieve a satisfactory result.
OmniGen2 natively requires an NVIDIA RTX 3090 or an equivalent GPU with approximately 17GB of VRAM. For devices with less VRAM, you can enable CPU Offload to run the model.
Performance Tip: To improve inference speed, consider decreasing the cfg_range_end parameter. Within a reasonable range, this has a negligible impact on output quality.
The following table details the inference performance of OmniGen2 on an A800 GPU:
Inference Efficiency of OmniGen2.
We’re honored and grateful for the support from the open source community. Here are some unofficial implementations contributed by the community(Currently, we have not confirmed whether there are no bugs. Please try to use the our official demo as much as possible.):
If you find this repository or our work useful, please consider giving a star ⭐ and citation 🦖, which would be greatly appreciated:
@article{wu2025omnigen2,
title={OmniGen2: Exploration to Advanced Multimodal Generation},
author={Chenyuan Wu and Pengfei Zheng and Ruiran Yan and Shitao Xiao and Xin Luo and Yueze Wang and Wanli Li and Xiyan Jiang and Yexin Liu and Junjie Zhou and Ze Liu and Ziyi Xia and Chaofan Li and Haoge Deng and Jiahao Wang and Kun Luo and Bo Zhang and Defu Lian and Xinlong Wang and Zhongyuan Wang and Tiejun Huang and Zheng Liu},
journal={arXiv preprint arXiv:2506.18871},
year={2025}
}
Jupyter Notebook
91.2%
Python
8.4%