🚀 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