- 2025-06-24: Technical Report is available.
- 2025-06-23: We’ve updated our code and HF model—OmniGen2 now runs without
flash-attn
. Users can still install it for optimal performance. - 2025-06-20: Updated resource requirements, adding CPU offload support for devices with limited VRAM.
- 2025-06-16: Gradio and Jupyter is available. Online Gradio Demo: Demo1; Chat-Demo1; see more demo links in gradio section
- 2025-06-16: We release OmniGen2, a multimodal generation model, model weights can be accessed in huggingface and modelscope.
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:
- Visual Understanding: Inherits the robust ability to interpret and analyze image content from its Qwen-VL-2.5 foundation.
- Text-to-Image Generation: Creates high-fidelity and aesthetically pleasing images from textual prompts.
- Instruction-guided Image Editing: Executes complex, instruction-based image modifications with high precision, achieving state-of-the-art performance among open-source models.
- In-context Generation: A versatile capability to process and flexibly combine diverse inputs—including humans, reference objects, and scenes—to produce novel and coherent visual outputs.
We will release the training code and dataset. Stay tuned!
Some good cases of OmniGen2:
Good demonstrations of OmniGen2's image editing capabilities.
Good demonstrations of OmniGen2's in-context generation capabilities.
- Technical report.
- Support CPU offload and improve inference efficiency.
- In-context generation benchmark: OmniContext.
- Integration of diffusers.
- Training datasets.
- Training data construction pipeline.
- ComfyUI Demo (commuity support will be greatly appreciated!).
# 1. Clone the repo
git clone [email protected]: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:
- Run Locally:
# 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.- The Trade-off: A higher value makes the output more faithful to the reference image's structure and style, but it might ignore parts of your text prompt. A lower value (~1.5) gives the text prompt more influence.
- Tip: For image editing task, we recommend to set it between 1.2 and 2.0; for in-context generateion task, a higher image_guidance_scale will maintian more details in input images, and we recommend to set it between 2.5 and 3.0.
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.- Tip: Default value is 1024*1024. You can reduce this value if you encounter memory issues.
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.- Example: blurry, low quality, text, watermark
- Tip: For the best results, try experimenting with different negative prompts. If you're not sure, just use the default negative prompt.
enable_model_cpu_offload
: Reduces VRAM usage by nearly 50% with a negligible impact on speed.- This is achieved by offloading the model weights to CPU RAM when they are not in use.
- See: Model Offloading
enable_sequential_cpu_offload
: Minimizes VRAM usage to less than 3GB, but at the cost of significantly slower performance.- This works by offloading the model in submodules and loading them onto the GPU sequentially as needed.
- See: CPU Offloading
cfg_range_start
,cfg_range_end
: Define the timestep range where CFG is applied. Per this paper, reducingcfg_range_end
can significantly decrease inference time with a negligible impact on quality.scheduler
: Choose between[euler, dpmsolver++]
. Default iseuler
. For potentially better performance with fewer steps, trydpmsolver++
.num_inference_step
: Number of discretization steps for the ODE solver. Default is50
.
Some suggestions for improving generation quality:
- Use High-Quality Images
- Provide clear images, preferably with a resolution greater than 512×512 pixels.
- Small or blurry inputs will result in low-quality outputs.
- Be Specific with Instructions
- Clearly describe both what to change and how you want it changed.
-
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:
- Use images with larger size, as well as images in which people occupy a larger proportion of the frame.
- Increase the Image Guidance Scale, for example to 3.0. The trade-off may be slight overexposure or a greasy look in the image.
- When using a single input image, you can try to use the following prompt template: "she/he ..., maintaining her/his facial features, hairstyle, and other attributes."
- Increase the parameter--Number of images per prompt to generate more outputs, giving you a better chance to find one with stronger subject consistency and a more satisfactory result.
- Longer prompts generally yield better results than shorter ones. More detailed descriptions of the scene and character interactions can provide additional benefits.
- For in-context edit (edit based multiple images), we recommend using the following prompt format: "Edit the first image: add/replace (the [object] with) the [object] from the second image. [descripton for your target image]." For example: "Edit the first image: add the man from the second image. The man is talking with a woman in the kitchen". The descition for your target image should be as detailed as possible.
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.):
- ComfyUI:
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}
}