Spaces:
Configuration error
Configuration error
File size: 12,887 Bytes
4c35f0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
<h3 align="center">
<img src="assets/uso.webp" alt="Logo" style="vertical-align: middle; width: 95px; height: auto;">
</br>
Unified Style and Subject-Driven Generation via Disentangled and Reward Learning
</h3>
<p align="center">
<a href="https://bytedance.github.io/USO/"><img alt="Build" src="https://img.shields.io/badge/Project%20Page-USO-blue"></a>
<a href="https://arxiv.org/abs/2508.18966"><img alt="Build" src="https://img.shields.io/badge/Tech%20Report-USO-b31b1b.svg"></a>
<a href="https://huggingface.co/bytedance-research/USO"><img src="https://img.shields.io/static/v1?label=%F0%9F%A4%97%20Hugging%20Face&message=Model&color=green"></a>
<a href="https://huggingface.co/spaces/bytedance-research/USO"><img src="https://img.shields.io/static/v1?label=%F0%9F%A4%97%20Hugging%20Face&message=demo&color=orange"></a>
</p>
</p>
><p align="center"> <span style="color:#137cf3; font-family: Gill Sans">Shaojin Wu,</span><sup></sup></a> <span style="color:#137cf3; font-family: Gill Sans">Mengqi Huang,</span></a> <span style="color:#137cf3; font-family: Gill Sans">Yufeng Cheng,</span><sup></sup></a> <span style="color:#137cf3; font-family: Gill Sans">Wenxu Wu,</span><sup></sup> </a> <span style="color:#137cf3; font-family: Gill Sans">Jiahe Tian,</span><sup></sup></a> <span style="color:#137cf3; font-family: Gill Sans">Yiming Luo,</span><sup></sup></a> <span style="color:#137cf3; font-family: Gill Sans">Fei Ding,</span></a> <span style="color:#137cf3; font-family: Gill Sans">Qian He</span></a> <br>
><span style="font-size: 13.5px">UXO Team</span><br>
><span style="font-size: 12px">Intelligent Creation Lab, Bytedance</span></p>
### 🚩 Updates
* **2025.09.03** 🎉 USO is now natively supported in ComfyUI, see official tutorial [USO in ComfyUI](https://docs.comfy.org/tutorials/flux/flux-1-uso) and our provided examples in `./workflow`. More tips are available in the [README below](https://github.com/bytedance/USO#%EF%B8%8F-comfyui-examples).
<p align="center">
<img src="assets/usoxcomfyui_official.jpeg" width=1024 height="auto">
</p>
* **2025.08.28** 🔥 The [demo](https://huggingface.co/spaces/bytedance-research/USO) of USO is released. Try it Now! ⚡️
* **2025.08.28** 🔥 Update fp8 mode as a primary low vmemory usage support (please scroll down). Gift for consumer-grade GPU users. The peak Vmemory usage is ~16GB now.
* **2025.08.27** 🔥 The [inference code](https://github.com/bytedance/USO) and [model](https://huggingface.co/bytedance-research/USO) of USO are released.
* **2025.08.27** 🔥 The [project page](https://bytedance.github.io/USO) of USO is created.
* **2025.08.27** 🔥 The [technical report](https://arxiv.org/abs/2508.18966) of USO is released.
## 📖 Introduction
Existing literature typically treats style-driven and subject-driven generation as two disjoint tasks: the former prioritizes stylistic similarity, whereas the latter insists on subject consistency, resulting in an apparent antagonism. We argue that both objectives can be unified under a single framework because they ultimately concern the disentanglement and re-composition of “content” and “style”, a long-standing theme in style-driven research. To this end, we present USO, a Unified framework for Style driven and subject-driven GeneratiOn. First, we construct a large-scale triplet dataset consisting of content images, style images, and their corresponding stylized content images. Second, we introduce a disentangled learning scheme that simultaneously aligns style features and disentangles content from style through two complementary objectives, style-alignment training and content–style disentanglement training. Third, we incorporate a style reward-learning paradigm to further enhance the model’s performance.
<p align="center">
<img src="assets/teaser.webp" width="1024"/>
</p>
## ⚡️ Quick Start
### 🔧 Requirements and Installation
Install the requirements
```bash
## create a virtual environment with python >= 3.10 <= 3.12, like
python -m venv uso_env
source uso_env/bin/activate
## or
conda create -n uso_env python=3.10 -y
conda activate uso_env
## install torch
## recommended version:
pip install torch==2.4.0 torchvision==0.19.0 --index-url https://download.pytorch.org/whl/cu124
## then install the requirements by you need
pip install -r requirements.txt # legacy installation command
```
Then download checkpoints:
```bash
# 1. set up .env file
cp example.env .env
# 2. set your huggingface token in .env (open the file and change this value to your token)
HF_TOKEN=your_huggingface_token_here
#3. download the necessary weights (comment any weights you don't need)
pip install huggingface_hub
python ./weights/downloader.py
```
- **IF YOU HAVE WEIGHTS, COMMENT OUT WHAT YOU DON'T NEED IN ./weights/downloader.py**
### ✍️ Inference
* Start from the examples below to explore and spark your creativity. ✨
```bash
# the first image is a content reference, and the rest are style references.
# for subject-driven generation
python inference.py --prompt "The man in flower shops carefully match bouquets, conveying beautiful emotions and blessings with flowers. " --image_paths "assets/gradio_examples/identity1.jpg" --width 1024 --height 1024
# for style-driven generation
# please keep the first image path empty
python inference.py --prompt "A cat sleeping on a chair." --image_paths "" "assets/gradio_examples/style1.webp" --width 1024 --height 1024
# for style-subject driven generation (or set the prompt to empty for layout-preserved generation)
python inference.py --prompt "The woman gave an impassioned speech on the podium." --image_paths "assets/gradio_examples/identity2.webp" "assets/gradio_examples/style2.webp" --width 1024 --height 1024
# for multi-style generation
# please keep the first image path empty
python inference.py --prompt "A handsome man." --image_paths "" "assets/gradio_examples/style3.webp" "assets/gradio_examples/style4.webp" --width 1024 --height 1024
# for low vram:
python inference.py --prompt "your propmt" --image_paths "your_image.jpg" --width 1024 --height 1024 --offload --model_type flux-dev-fp8
```
* You can also compare your results with the results in the `assets/gradio_examples` folder.
* For more examples, visit our [project page](https://bytedance.github.io/USO) or try the live [demo](https://huggingface.co/spaces/bytedance-research/USO).
### 🌟 Gradio Demo
```bash
python app.py
```
**For low vmemory usage**, please pass the `--offload` and `--name flux-dev-fp8` args. The peak memory usage will be 16GB (Single reference) ~ 18GB (Multi references).
```bash
# please use FLUX_DEV_FP8 replace FLUX_DEV
export FLUX_DEV_FP8="YOUR_FLUX_DEV_PATH"
python app.py --offload --name flux-dev-fp8
```
## 🌈 More examples
We provide some prompts and results to help you better understand the model. You can check our [paper](https://arxiv.org/abs/2508.18966) or [project page](https://bytedance.github.io/USO/) for more visualizations.
#### Subject/Identity-driven generation
<details>
<summary>If you want to place a subject into new scene, please use natural language like "A dog/man/woman is doing...". If you only want to transfer the style but keep the layout, please an use instructive prompt like "Transform the style into ... style". For portraits-preserved generation, USO excels at producing high skin-detail images. A practical guideline: use half-body close-ups for half-body prompts, and full-body images when the pose or framing changes significantly. </summary>
<p align="center">
<img src="assets/show_case1.webp" width="1024"/>
<p>
<p align="center">
<img src="assets/show_case2.webp" width="1024"/>
</p>
<p align="center">
<img src="assets/show_case3.webp" width="1024"/>
</p>
<p align="center">
<img src="assets/show_case4.webp" width="1024"/>
</p>
</details>
#### Style-driven generation
<details>
<summary>Just upload one or two style images, and use natural language to create want you want. USO will generate images follow your prompt and match the style you uploaded. </summary>
<p align="center">
<img src="assets/show_case5.webp" width="1024"/>
<p>
<p align="center">
<img src="assets/show_case6.webp" width="1024"/>
</p>
</details>
#### Style-subject driven generation
<details>
<summary>USO can stylize a single content reference with one or two style refs. For layout-preserved generation, just set the prompt to empty. </summary>
`Layout-preserved generation`
<p align="center">
<img src="assets/show_case7.webp" width="1024"/>
<p>
`Layout-shifted generation`
<p align="center">
<img src="assets/show_case8.webp" width="1024"/>
</p>
</details>
## ⚙️ ComfyUI examples
We’re pleased that USO now has native support in ComfyUI. For a quick start, please refer to the official tutorials [USO in ComfyUI](https://docs.comfy.org/tutorials/flux/flux-1-uso). To help you reproduce and match the results, we’ve provided several examples in `./workflows`, including **workflows** and their **inputs** and outputs, so you can quickly get familiar with what USO can do. With USO now fully compatible with the ComfyUI ecosystem, you can combine it with other plugins like ControlNet and LoRA. **We welcome community contributions of more workflows and examples.**
Now you can easily run USO in ComfyUI. Just update ComfyUI to the latest version (0.3.57), and you’ll find USO in the official templates.
<p align="center">
<img src="assets/comfyui_template.png" width=1024 height="auto">
</p>
More examples are provided below:
<p align="center">
<img src="assets/usoxcomfyui.webp" width=1024 height="auto">
</p>
**Identity preserved**
<p align="center">
<img src="workflow/example1.png" width=1024 height="auto">
</p>
Download the image above and drag it into ComfyUI to load the corresponding [workflow](workflow/example1.json). Input images can be found in `./workflow`
**Identity stylized**
<p align="center">
<img src="workflow/example3.png" width=1024 height="auto">
</p>
Download the image above and drag it into ComfyUI to load the corresponding [workflow](workflow/example3.json). Input images can be found in `./workflow`
**Identity + style reference**
<p align="center">
<img src="workflow/example2.png" width=1024 height="auto">
</p>
Download the image above and drag it into ComfyUI to load the corresponding [workflow](workflow/example2.json). Input images can be found in `./workflow`
**Single style reference**
<p align="center">
<img src="workflow/example4.png" width=1024 height="auto">
</p>
Download the image above and drag it into ComfyUI to load the corresponding [workflow](workflow/example4.json). Input images can be found in `./workflow`
<p align="center">
<img src="workflow/example6.png" width=1024 height="auto">
</p>
Download the image above and drag it into ComfyUI to load the corresponding [workflow](workflow/example6.json). Input images can be found in `./workflow`
**Multiple style reference**
<p align="center">
<img src="workflow/example5.png" width=1024 height="auto">
</p>
Download the image above and drag it into ComfyUI to load the corresponding [workflow](workflow/example5.json). Input images can be found in `./workflow`
## 📄 Disclaimer
<p>
We open-source this project for academic research. The vast majority of images
used in this project are either generated or from open-source datasets. If you have any concerns,
please contact us, and we will promptly remove any inappropriate content.
Our project is released under the Apache 2.0 License. If you apply to other base models,
please ensure that you comply with the original licensing terms.
<br><br>This research aims to advance the field of generative AI. Users are free to
create images using this tool, provided they comply with local laws and exercise
responsible usage. The developers are not liable for any misuse of the tool by users.</p>
## 🚀 Updates
For the purpose of fostering research and the open-source community, we plan to open-source the entire project, encompassing training, inference, weights, dataset etc. Thank you for your patience and support! 🌟
- [x] Release technical report.
- [x] Release github repo.
- [x] Release inference code.
- [x] Release model checkpoints.
- [x] Release huggingface space demo.
- Release training code.
- Release dataset.
## Citation
If USO is helpful, please help to ⭐ the repo.
If you find this project useful for your research, please consider citing our paper:
```bibtex
@article{wu2025uso,
title={USO: Unified Style and Subject-Driven Generation via Disentangled and Reward Learning},
author={Shaojin Wu and Mengqi Huang and Yufeng Cheng and Wenxu Wu and Jiahe Tian and Yiming Luo and Fei Ding and Qian He},
year={2025},
eprint={2508.18966},
archivePrefix={arXiv},
primaryClass={cs.CV},
}
``` |