diff --git a/LoRAs/3D_Chibi_rank128_bf16.safetensors b/LoRAs/3D_Chibi_rank128_bf16.safetensors new file mode 100644 index 0000000..51309ed --- /dev/null +++ b/LoRAs/3D_Chibi_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54cffb3ef725a516990c750e7b5cd4c9d64965ac764fcf4d092712c458289d17 +size 135 diff --git a/LoRAs/American_Cartoon_rank128_bf16.safetensors b/LoRAs/American_Cartoon_rank128_bf16.safetensors new file mode 100644 index 0000000..b3df056 --- /dev/null +++ b/LoRAs/American_Cartoon_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b7a972ada75da32497bea33254645b3b5c29755b60658a519782be0af413163 +size 135 diff --git a/LoRAs/Chinese_Ink_rank128_bf16.safetensors b/LoRAs/Chinese_Ink_rank128_bf16.safetensors new file mode 100644 index 0000000..6fadda0 --- /dev/null +++ b/LoRAs/Chinese_Ink_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01313a8bfc8a021580d2929cc892a61a34f1ded30f946e725df4a8e8e6bee42e +size 135 diff --git a/LoRAs/Clay_Toy_rank128_bf16.safetensors b/LoRAs/Clay_Toy_rank128_bf16.safetensors new file mode 100644 index 0000000..6e6d8f1 --- /dev/null +++ b/LoRAs/Clay_Toy_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d36087246a4c7d16bb27151281bbecc82b27987c9e5e1cf54b4505d4f268300 +size 135 diff --git a/LoRAs/Fabric_rank128_bf16.safetensors b/LoRAs/Fabric_rank128_bf16.safetensors new file mode 100644 index 0000000..eb2b43a --- /dev/null +++ b/LoRAs/Fabric_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3973c71e448d10664d2038dbe8b04edbe43a90917aaf87f3e139a9a4d8c5c7a5 +size 135 diff --git a/LoRAs/Ghibli_rank128_bf16.safetensors b/LoRAs/Ghibli_rank128_bf16.safetensors new file mode 100644 index 0000000..8cc7bd9 --- /dev/null +++ b/LoRAs/Ghibli_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ca593028dbef295dee5938f2e2e77e1cc5cf56d4f03a91f57d9c80b628fdeb4 +size 135 diff --git a/LoRAs/Irasutoya_rank128_bf16.safetensors b/LoRAs/Irasutoya_rank128_bf16.safetensors new file mode 100644 index 0000000..621ecfa --- /dev/null +++ b/LoRAs/Irasutoya_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9c83c82c6eb20997444352152f4c92a18f484a5e2283baaea0ea71aa39cf82c +size 135 diff --git a/LoRAs/Jojo_rank128_bf16.safetensors b/LoRAs/Jojo_rank128_bf16.safetensors new file mode 100644 index 0000000..0a77168 --- /dev/null +++ b/LoRAs/Jojo_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64d0765f2c76624e69a09186d83385b911fb6f4b72dfe5a0f2c903ffa9653a7e +size 135 diff --git a/LoRAs/LEGO_rank128_bf16.safetensors b/LoRAs/LEGO_rank128_bf16.safetensors new file mode 100644 index 0000000..d68cf47 --- /dev/null +++ b/LoRAs/LEGO_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbf16c0f6e07141587a38d9c00bc56b2de015abbe08944ea316091c00e1642fe +size 135 diff --git a/LoRAs/Line_rank128_bf16.safetensors b/LoRAs/Line_rank128_bf16.safetensors new file mode 100644 index 0000000..7edec12 --- /dev/null +++ b/LoRAs/Line_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5106845d06901b52dcd2b1c4a4be4ac1d2c1519415286b581809123f8b56781b +size 135 diff --git a/LoRAs/Macaron_rank128_bf16.safetensors b/LoRAs/Macaron_rank128_bf16.safetensors new file mode 100644 index 0000000..82f8430 --- /dev/null +++ b/LoRAs/Macaron_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0198a949f0996c069fd502841e06e78dd9bb2407c51bab96240e0664dff2c1a9 +size 135 diff --git a/LoRAs/Oil_Painting_rank128_bf16.safetensors b/LoRAs/Oil_Painting_rank128_bf16.safetensors new file mode 100644 index 0000000..ba17b72 --- /dev/null +++ b/LoRAs/Oil_Painting_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9527b1eac44c7662c0f27a7f33b5366ab4551db483b365c6e6529fda0c38d71 +size 135 diff --git a/LoRAs/Origami_rank128_bf16.safetensors b/LoRAs/Origami_rank128_bf16.safetensors new file mode 100644 index 0000000..3972c3d --- /dev/null +++ b/LoRAs/Origami_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0a14da326dc7c692f1c00eb499a051dace1f66c05611c515ec4c4ad6981eb5d +size 135 diff --git a/LoRAs/Paper_Cutting_rank128_bf16.safetensors b/LoRAs/Paper_Cutting_rank128_bf16.safetensors new file mode 100644 index 0000000..e2fb5d9 --- /dev/null +++ b/LoRAs/Paper_Cutting_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d58eecd8aa36f291be7f837ddcdf5678930c36e8e94f489a35805b8313ac7f96 +size 135 diff --git a/LoRAs/Picasso_rank128_bf16.safetensors b/LoRAs/Picasso_rank128_bf16.safetensors new file mode 100644 index 0000000..01d0249 --- /dev/null +++ b/LoRAs/Picasso_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42c5666e5c63eb75613519ee4150d5b8b8691f069a108771c8c0eb3d107ea63c +size 135 diff --git a/LoRAs/Pixel_rank128_bf16.safetensors b/LoRAs/Pixel_rank128_bf16.safetensors new file mode 100644 index 0000000..e675d9a --- /dev/null +++ b/LoRAs/Pixel_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f0144eff91de8cb128c15a9fc47359dc0e3d16113f5b22deb5f3666f0d45beb +size 135 diff --git a/LoRAs/Poly_rank128_bf16.safetensors b/LoRAs/Poly_rank128_bf16.safetensors new file mode 100644 index 0000000..e6bb133 --- /dev/null +++ b/LoRAs/Poly_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2de25f7912dfa941c8cd20da429e3109c2e34fac57291a993d54f7495bd4394 +size 135 diff --git a/LoRAs/Pop_Art_rank128_bf16.safetensors b/LoRAs/Pop_Art_rank128_bf16.safetensors new file mode 100644 index 0000000..b7d57c5 --- /dev/null +++ b/LoRAs/Pop_Art_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6770e0422657b3bc35d65d68f3c3663ce137d134726ceff211a3c59d806fd02d +size 135 diff --git a/LoRAs/Rick_Morty_rank128_bf16.safetensors b/LoRAs/Rick_Morty_rank128_bf16.safetensors new file mode 100644 index 0000000..8ffd4ed --- /dev/null +++ b/LoRAs/Rick_Morty_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87ea211a08af23c801517b0c700d212eaf350d439e38949b7218188049d3c893 +size 135 diff --git a/LoRAs/Snoopy_rank128_bf16.safetensors b/LoRAs/Snoopy_rank128_bf16.safetensors new file mode 100644 index 0000000..79b971c --- /dev/null +++ b/LoRAs/Snoopy_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfb3bc98b05c4e89c8c6ad2137ebf78f8fdebd72d8e68d4f8ff2644eab527d3d +size 135 diff --git a/LoRAs/Van_Gogh_rank128_bf16.safetensors b/LoRAs/Van_Gogh_rank128_bf16.safetensors new file mode 100644 index 0000000..268368b --- /dev/null +++ b/LoRAs/Van_Gogh_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57520703570c175b4d673800c681e2291ff8f3b351fd4ab107693776f613e606 +size 135 diff --git a/LoRAs/Vector_rank128_bf16.safetensors b/LoRAs/Vector_rank128_bf16.safetensors new file mode 100644 index 0000000..306e282 --- /dev/null +++ b/LoRAs/Vector_rank128_bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8852bd02852994a4146707a662c6d30767d6843b19e0753784a54ffc059f12ad +size 135 diff --git a/OmniConsistency.safetensors b/OmniConsistency.safetensors new file mode 100644 index 0000000..48059a6 --- /dev/null +++ b/OmniConsistency.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:429484cf85bfa73f04b16c95b43a72cddf377c7c4306771f2064f133ab75e5cb +size 134 diff --git a/README.md b/README.md index 9f3cdbf..a628f48 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,170 @@ --- -license: Apache License 2.0 - -#model-type: -##如 gpt、phi、llama、chatglm、baichuan 等 -#- gpt - -#domain: -##如 nlp、cv、audio、multi-modal -#- nlp - -#language: -##语言代码列表 https://help.aliyun.com/document_detail/215387.html?spm=a2c4g.11186623.0.0.9f8d7467kni6Aa -#- cn - -#metrics: -##如 CIDEr、Blue、ROUGE 等 -#- CIDEr - -#tags: -##各种自定义,包括 pretrained、fine-tuned、instruction-tuned、RL-tuned 等训练方法和其他 -#- pretrained - -#tools: -##如 vllm、fastchat、llamacpp、AdaSeq 等 -#- vllm +base_model: +- black-forest-labs/FLUX.1-dev +license: mit +pipeline_tag: image-to-image +title: OmniConsistency +emoji: 🚀 +colorFrom: gray +colorTo: pink +sdk: gradio +sdk_version: 5.31.0 +app_file: app.py +pinned: false +short_description: Generate styled image from reference image and external LoRA --- -### 当前模型的贡献者未提供更加详细的模型介绍。模型文件和权重,可浏览“模型文件”页面获取。 -#### 您可以通过如下git clone命令,或者ModelScope SDK来下载模型 -SDK下载 +**OmniConsistency: Learning Style-Agnostic +Consistency from Paired Stylization Data** +
+ [Yiren Song](https://scholar.google.com.hk/citations?user=L2YS0jgAAAAJ), + [Cheng Liu](https://scholar.google.com.hk/citations?hl=zh-CN&user=TvdVuAYAAAAJ), + and + [Mike Zheng Shou](https://sites.google.com/view/showlab) +
+ [Show Lab](https://sites.google.com/view/showlab), National University of Singapore +
+ +[[Official Code]](https://github.com/showlab/OmniConsistency) +[[Paper]](https://huggingface.co/papers/2505.18445) +[[Dataset]](https://huggingface.co/datasets/showlab/OmniConsistency) + + +## Installation + +We recommend using Python 3.10 and PyTorch with CUDA support. To set up the environment: + ```bash -#安装ModelScope -pip install modelscope -``` -```python -#SDK模型下载 -from modelscope import snapshot_download -model_dir = snapshot_download('showlab/OmniConsistency') -``` -Git下载 -``` -#Git模型下载 -git clone https://www.modelscope.cn/showlab/OmniConsistency.git +# Create a new conda environment +conda create -n omniconsistency python=3.10 +conda activate omniconsistency + +# Install other dependencies +pip install -r requirements.txt ``` -

如果您是本模型的贡献者,我们邀请您根据模型贡献文档,及时完善模型卡片内容。

\ No newline at end of file +## Download + +You can download the OmniConsistency model and pretrained LoRAs directly from [Hugging Face](https://huggingface.co/showlab/OmniConsistency). +Or download using Python script: + +### OmniConsistency Model + +```python +from huggingface_hub import hf_hub_download +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/3D_Chibi_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/American_Cartoon_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Chinese_Ink_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Clay_Toy_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Fabric_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Ghibli_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Irasutoya_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Jojo_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/LEGO_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Line_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Macaron_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Oil_Painting_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Origami_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Paper_Cutting_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Picasso_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Pixel_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Poly_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Pop_Art_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Rick_Morty_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Snoopy_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Van_Gogh_rank128_bf16.safetensors", local_dir="./LoRAs") +hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Vector_rank128_bf16.safetensors", local_dir="./LoRAs") +``` +### Pretrained LoRAs +```python +from huggingface_hub import hf_hub_download +hf_hub_download(repo_id="showlab/OmniConsistency", filename="OmniConsistency.safetensors", local_dir="./Model") +``` + +## Usage +Here's a basic example of using OmniConsistency: + +### Model Initialization +```python +import time +import torch +from PIL import Image +from src_inference.pipeline import FluxPipeline +from src_inference.lora_helper import set_single_lora + +def clear_cache(transformer): + for name, attn_processor in transformer.attn_processors.items(): + attn_processor.bank_kv.clear() + +# Initialize model +device = "cuda" +base_path = "/path/to/black-forest-labs/FLUX.1-dev" +pipe = FluxPipeline.from_pretrained(base_path, torch_dtype=torch.bfloat16).to("cuda") + +# Load OmniConsistency model +set_single_lora(pipe.transformer, + "/path/to/OmniConsistency.safetensors", + lora_weights=[1], cond_size=512) + +# Load external LoRA +pipe.unload_lora_weights() +pipe.load_lora_weights("/path/to/lora_folder", + weight_name="lora_name.safetensors") +``` + +### Style Inference +```python +image_path1 = "figure/test.png" +prompt = "3D Chibi style, Three individuals standing together in the office." + +subject_images = [] +spatial_image = [Image.open(image_path1).convert("RGB")] + +width, height = 1024, 1024 + +start_time = time.time() + +image = pipe( + prompt, + height=height, + width=width, + guidance_scale=3.5, + num_inference_steps=25, + max_sequence_length=512, + generator=torch.Generator("cpu").manual_seed(5), + spatial_images=spatial_image, + subject_images=subject_images, + cond_size=512, +).images[0] + +end_time = time.time() +elapsed_time = end_time - start_time +print(f"code running time: {elapsed_time} s") + +# Clear cache after generation +clear_cache(pipe.transformer) + +image.save("results/output.png") +``` + +## Datasets +Our datasets have been uploaded to the [Hugging Face](https://huggingface.co/datasets/showlab/OmniConsistency). and is available for direct use via the datasets library. + +You can easily load any of the 22 style subsets like this: +```python +from datasets import load_dataset + +# Load a single style (e.g., Ghibli) +ds = load_dataset("showlab/OmniConsistency", split="Ghibli") +print(ds[0]) +``` + +## Citation +``` +@inproceedings{Song2025OmniConsistencyLS, + title={OmniConsistency: Learning Style-Agnostic Consistency from Paired Stylization Data}, + author={Yiren Song and Cheng Liu and Mike Zheng Shou}, + year={2025}, + url={https://api.semanticscholar.org/CorpusID:278905729} +} +``` \ No newline at end of file diff --git a/configuration.json b/configuration.json new file mode 100644 index 0000000..7f3861d --- /dev/null +++ b/configuration.json @@ -0,0 +1 @@ +{"framework": "pytorch", "task": "image-to-image", "allow_remote": true} \ No newline at end of file diff --git a/figure/teaser.png b/figure/teaser.png new file mode 100644 index 0000000..382ea77 Binary files /dev/null and b/figure/teaser.png differ diff --git a/figure/test.png b/figure/test.png new file mode 100644 index 0000000..053bc90 Binary files /dev/null and b/figure/test.png differ