🚀 OmniGen:统一图像生成
OmniGen 是一个统一的图像生成模型,它能够根据多模态提示生成各种图像。该模型设计简洁、灵活且易于使用,为用户提供了便捷的图像生成体验。
🚀 快速开始
使用 OmniGen
通过 Github 安装(推荐):
git clone https://github.com/staoxiao/OmniGen.git
cd OmniGen
pip install -e .
或者通过 pypi 安装:
pip install OmniGen
以下是一些使用示例:
from OmniGen import OmniGenPipeline
pipe = OmniGenPipeline.from_pretrained("Shitao/OmniGen-v1")
images = pipe(
prompt="A curly-haired man in a red shirt is drinking tea.",
height=1024,
width=1024,
guidance_scale=2.5,
seed=0,
)
images[0].save("example_t2i.png")
images = pipe(
prompt="A man in a black shirt is reading a book. The man is the right man in <img><|image_1|></img>.",
input_images=["./imgs/test_cases/two_man.jpg"],
height=1024,
width=1024,
separate_cfg_infer=False,
guidance_scale=3,
img_guidance_scale=1.6
)
images[0].save("example_ti2i.png")
有关推理参数的更多详细信息,请参考 docs/inference.md。
有关更多图像生成示例,你可以参考 inference.ipynb 和 inference_demo.ipynb。
使用 Diffusers
即将推出。
Gradio 演示
我们在 Huggingface 上构建了一个在线演示。
对于本地 Gradio 演示,你可以运行:
python app.py
✨ 主要特性
- 统一图像生成:OmniGen 是一个统一的图像生成模型,可根据多模态提示生成各种图像,无需额外的插件或操作。
- 简单灵活:设计简洁、灵活且易于使用,用户可以通过简单的步骤探索其更多功能。
- 多任务支持:能够执行多种任务,包括但不限于文本到图像生成、主题驱动生成、身份保留生成、图像编辑和图像条件生成。
📦 安装指南
通过 Github 安装(推荐)
git clone https://github.com/staoxiao/OmniGen.git
cd OmniGen
pip install -e .
通过 pypi 安装
pip install OmniGen
💻 使用示例
基础用法
from OmniGen import OmniGenPipeline
pipe = OmniGenPipeline.from_pretrained("Shitao/OmniGen-v1")
images = pipe(
prompt="A curly-haired man in a red shirt is drinking tea.",
height=1024,
width=1024,
guidance_scale=2.5,
seed=0,
)
images[0].save("example_t2i.png")
高级用法
images = pipe(
prompt="A man in a black shirt is reading a book. The man is the right man in <img><|image_1|></img>.",
input_images=["./imgs/test_cases/two_man.jpg"],
height=1024,
width=1024,
separate_cfg_infer=False,
guidance_scale=3,
img_guidance_scale=1.6
)
images[0].save("example_ti2i.png")
📚 详细文档
模型概述
OmniGen 是一个统一的图像生成模型,能够从多模态提示中生成广泛的图像。它旨在简单、灵活且易于使用。我们提供了 推理代码,以便每个人都能探索 OmniGen 的更多功能。
模型能力
OmniGen 可以执行多种任务,包括但不限于文本到图像生成、主题驱动生成、身份保留生成、图像编辑和图像条件生成。它无需额外的插件或操作,可根据文本提示自动识别输入图像中的特征(例如所需对象、人体姿势、深度映射)。
模型微调
我们提供了一个训练脚本 train.py
来微调 OmniGen。有关更多详细信息(例如全量微调),请参考 docs/finetune.md。
🔧 技术细节
现有图像生成模型通常需要加载多个额外的网络模块(如 ControlNet、IP - Adapter、Reference - Net 等),并执行额外的预处理步骤(如人脸检测、姿势估计、裁剪等)才能生成令人满意的图像。而 OmniGen 致力于打造更简单灵活的未来图像生成范式,即通过任意多模态指令直接生成各种图像,无需额外的插件和操作,类似于 GPT 在语言生成中的工作方式。
📄 许可证
本仓库遵循 MIT 许可证。
引用
如果你觉得这个仓库有用,请考虑给它点个星 ⭐ 并引用:
@article{xiao2024omnigen,
title={Omnigen: Unified image generation},
author={Xiao, Shitao and Wang, Yueze and Zhou, Junjie and Yuan, Huaying and Xing, Xingrun and Yan, Ruiran and Wang, Shuting and Huang, Tiejun and Liu, Zheng},
journal={arXiv preprint arXiv:2409.11340},
year={2024}
}
更多信息请参考我们的 Github 仓库:https://github.com/VectorSpaceLab/OmniGen