🚀 OmniGen: 統一画像生成
OmniGenは、多様な画像を多モーダルプロンプトから生成できる統一画像生成モデルです。シンプルで柔軟かつ使いやすく設計されています。
関連リンク
目次
1. News
✨ 主な機能
OmniGenは、多様な画像生成タスクを実行できる統一画像生成モデルです。テキストから画像生成、主題駆動型生成、Identity-Preserving生成、画像編集、画像条件付き生成などのタスクをサポートしています。OmniGenは追加のプラグインや操作を必要とせず、テキストプロンプトに基づいて入力画像の特徴(必要なオブジェクト、人物のポーズ、深度マッピングなど)を自動的に識別できます。
📦 インストール
OmniGenの使用
GitHubからインストールするには、以下のコマンドを実行します。
git clone https://github.com/staoxiao/OmniGen.git
cd OmniGen
pip install -e .
コンフリクトを避けるために新しい環境を作成することもできます。
conda create -n omnigen python=3.10.12
conda activate omnigen
pip install torch==2.3.1+cu118 torchvision --extra-index-url https://download.pytorch.org/whl/cu118
git clone https://github.com/staoxiao/OmniGen.git
cd OmniGen
pip install -e .
💻 使用例
基本的な使用法
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,
guidance_scale=2.5,
img_guidance_scale=1.6,
seed=0
)
images[0].save("example_ti2i.png")
高度な使用法
Diffusersの使用
近日公開予定です。
Gradioデモ
Huggingface でオンラインデモを構築しています。
ローカルのGradioデモを使用するには、pip install gradio spaces
をインストールし、以下のコマンドを実行します。
pip install gradio spaces
python app.py
Google Colabの使用
Google Colabで使用するには、以下のコマンドを使用してください。
!git clone https://github.com/staoxiao/OmniGen.git
%cd OmniGen
!pip install -e .
!pip install gradio spaces
!python app.py --share
📚 ドキュメント
ファインチューニング
OmniGenをファインチューニングするための学習スクリプト train.py
を提供しています。
以下はLoRAファインチューニングの簡単な例です。
accelerate launch --num_processes=1 train.py \
--model_name_or_path Shitao/OmniGen-v1 \
--batch_size_per_device 2 \
--condition_dropout_prob 0.01 \
--lr 1e-3 \
--use_lora \
--lora_rank 8 \
--json_file ./toy_data/toy_subject_data.jsonl \
--image_path ./toy_data/images \
--max_input_length_limit 18000 \
--keep_raw_resolution \
--max_image_size 1024 \
--gradient_accumulation_steps 1 \
--ckpt_every 10 \
--epochs 200 \
--log_every 1 \
--results_dir ./results/toy_finetune_lora
詳細(例えば、完全なファインチューニング)については、docs/fine-tuning.md を参照してください。
貢献者
すべての貢献者の努力に感謝し、新しいメンバーの参加を心から歓迎します!
📄 ライセンス
このリポジトリは 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}
}