Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,185 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
## Model Details
|
| 13 |
|
| 14 |
-
### Model Description
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
-
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
### Out-of-Scope Use
|
| 53 |
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 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 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
datasets:
|
| 5 |
+
- Franklin0/ReasonGen-R1-RL-Geneval-12k
|
| 6 |
+
- Franklin0/ReasonGen-R1-RL-DPG-5k
|
| 7 |
+
- Franklin0/ReasonGen-R1-RL-T2I-11k
|
| 8 |
+
base_model:
|
| 9 |
+
- deepseek-ai/Janus-Pro-7B
|
| 10 |
---
|
| 11 |
|
| 12 |
# Model Card for Model ID
|
| 13 |
|
| 14 |
+
An autoregressive image generation with text-based chain-of-thought.
|
| 15 |
+
Official checkpoint for the paper "[ReasonGen-R1: Cot for Autoregressive Image generation models through SFT and RL](xxx)".
|
| 16 |
|
| 17 |
+
Website: https://aka.ms/reasongen
|
| 18 |
|
| 19 |
+
Code: https://github.com/Franklin-Zhang0/Image-RL
|
| 20 |
|
|
|
|
| 21 |
|
|
|
|
| 22 |
|
| 23 |
+
<div align="center">
|
| 24 |
+
<h1>🚀 ReasonGen-R1: Cot for Autoregressive Image generation models through SFT and RL</h1>
|
| 25 |
|
| 26 |
+
</div>
|
| 27 |
|
| 28 |
+
<div align="center">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
<a href="https://www.deepseek.com/" target="_blank">
|
| 31 |
+
<img alt="Homepage" src="https://img.shields.io/badge/HomePage-blue" />
|
| 32 |
+
</a>
|
| 33 |
+
</a>
|
| 34 |
+
<a href="https://huggingface.co/collections/Franklin0/reasongen-r1-6836ed61fc4f6db543c0d368" target="_blank">
|
| 35 |
+
<img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-ReasonGen%20R1-ffc107?color=ffc107&logoColor=white" />
|
| 36 |
+
</a>
|
| 37 |
|
| 38 |
+
</div>
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
|
|
|
|
| 41 |
|
|
|
|
| 42 |
|
| 43 |
+
<p align="center">
|
| 44 |
+
<a href="#2-model-download"><b>📥 Model Download</b></a> |
|
| 45 |
+
<a href="#3-quick-start"><b>⚡ Quick Start</b></a> |
|
| 46 |
+
<a href="#4-license"><b>📜 License</b></a> |
|
| 47 |
+
<a href="#5-citation"><b>📖 Citation</b></a> <br>
|
| 48 |
+
📄 <a href="xxxxxx"><b>Paper Link</b></a>
|
| 49 |
+
<!-- 🤗 Online Demo (<a href="https://huggingface.co/spaces/deepseek-ai/Janus-Pro-7B"><b>Janus-Pro-7B</b></a>, <a href="https://huggingface.co/spaces/deepseek-ai/Janus-1.3B"><b>Janus</b></a>, <a href="https://huggingface.co/spaces/deepseek-ai/JanusFlow-1.3B"><b>JanusFlow</b></a>) -->
|
| 50 |
+
</p>
|
| 51 |
|
| 52 |
+
## 1. Introduction
|
| 53 |
|
| 54 |
+
Although chain-of-thought (CoT) reasoning and reinforcement learning (RL) have driven breakthroughs in NLP, their integration into generative vision models remains underexplored. We introduce ReasonGen-R1, a two-stage framework that first imbues an autoregressive image generator with explicit text-based “thinking” skills via supervised fine-tuning (SFT) on a newly generated reasoning dataset of written rationales, and then refines its outputs using Generation-Reward Proximal Optimization (GRPO).
|
| 55 |
+
Text-based CoT reasoning dataset for image synthesis. We automatically generate and release a corpus of step-by-step, model-crafted rationales paired with visual prompts, enabling controlled planning of object layouts, styles, and scene compositions.
|
| 56 |
+
RL refinement with GRPO. Our GRPO algorithm uses reward signals from a pretrained vision–language model to assess overall visual quality, optimizing the policy in each update.
|
| 57 |
+
Evaluations on Geneval, DPG, and the T2I benchmark demonstrate that ReasonGen-R1 consistently outperforms strong baselines and prior state-of-the-art models. We will open-source our generated reasoning dataset and training code to accelerate further advances in text-based reasoning–driven image generation.
|
| 58 |
|
| 59 |
+
<div align="center">
|
| 60 |
+
<img alt="image" src="images/model_structure_white_bg.png" style="width:90%;">
|
| 61 |
+
<br>
|
| 62 |
+
<img alt="image" src="images/benchmark_and_comparison_white_bg.png" style="width:90%; margin-top: 10px;">
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
## 2. Model Download
|
| 67 |
|
| 68 |
+
We release ReasonGen-R1 to the public to support a broader and more diverse range of research within both academic and commercial communities.
|
| 69 |
+
Please note that the use of this model is subject to the terms outlined in [License section](#5-license). Commercial usage is
|
| 70 |
+
permitted under these terms.
|
| 71 |
+
|
| 72 |
+
### Huggingface
|
| 73 |
|
| 74 |
+
| Model | Download |
|
| 75 |
+
|-----------------------|-----------------------------------------------------------------------------|
|
| 76 |
+
| ReasonGen-R1 | [🤗 Hugging Face](https://huggingface.co/Franklin0/ReasonGen-R1) |
|
| 77 |
+
| ReasonGen-R1-SFT-Only | [🤗 Hugging Face](https://huggingface.co/Franklin0/ReasonGen-R1-SFT) |
|
| 78 |
|
|
|
|
| 79 |
|
|
|
|
| 80 |
|
| 81 |
+
## 3. Quick Start
|
| 82 |
|
| 83 |
+
### Installation
|
| 84 |
+
|
| 85 |
+
You can install the necessary dependencies by running the following command:
|
| 86 |
+
|
| 87 |
+
```shell
|
| 88 |
+
cd ~
|
| 89 |
+
mkdir project
|
| 90 |
+
cd project
|
| 91 |
+
conda create -n image_rl python==3.12 -y
|
| 92 |
+
conda activate image_rl
|
| 93 |
+
pip3 install torch==2.6.0 torchvision --index-url https://download.pytorch.org/whl/cu124
|
| 94 |
+
pip3 install flash-attn --no-build-isolation
|
| 95 |
+
git clone https://github.com/Franklin-Zhang0/Image-RL.git
|
| 96 |
+
cd Image-RL
|
| 97 |
+
pip install -r requirements.txt
|
| 98 |
+
pip install -e .
|
| 99 |
+
pip install -e ./Janus
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
<details>
|
| 103 |
+
<summary><h3>Evaluation Environment Installation (Optional)</h3></summary>
|
| 104 |
+
If you want to run the evaluation code, you can install the evaluation environment by running the following commands:
|
| 105 |
+
|
| 106 |
+
```shell
|
| 107 |
+
# Geneval
|
| 108 |
+
cd ~
|
| 109 |
+
mkdir project
|
| 110 |
+
cd project
|
| 111 |
+
git clone https://github.com/djghosh13/geneval.git
|
| 112 |
+
cd geneval
|
| 113 |
+
conda deactivate
|
| 114 |
+
conda create -n geneval python=3.9 -y
|
| 115 |
+
conda activate geneval
|
| 116 |
+
pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1
|
| 117 |
+
pip install mmcv-full==1.7.0 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13/index.html
|
| 118 |
+
pip install mmengine==0.7.3
|
| 119 |
+
|
| 120 |
+
pip install pandas
|
| 121 |
+
pip install numpy==1.23.1
|
| 122 |
+
|
| 123 |
+
pip install open-clip-torch
|
| 124 |
+
pip install clip-benchmark
|
| 125 |
+
|
| 126 |
+
git clone https://github.com/open-mmlab/mmdetection.git
|
| 127 |
+
cd mmdetection; git checkout 2.x
|
| 128 |
+
pip install -v -e .
|
| 129 |
+
|
| 130 |
+
cd ../
|
| 131 |
+
bash ./evaluation/download_models.sh "./models"
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
```shell
|
| 135 |
+
# DPG
|
| 136 |
+
cd ~
|
| 137 |
+
cd project
|
| 138 |
+
git clone https://github.com/TencentQQGYLab/ELLA.git
|
| 139 |
+
cd ELLA
|
| 140 |
+
cp ~/project/ReasonGen-R1/requirements-for-dpg_bench.txt .
|
| 141 |
+
conda deactivate
|
| 142 |
+
conda create -n dpg_test python=3.9 -y
|
| 143 |
+
conda activate dpg_test
|
| 144 |
+
conda install conda-forge::fairseq -y
|
| 145 |
+
pip install -r requirements-for-dpg_bench.txt
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
Once the eval environment is setup, you can use the following commands to run the evaluation:
|
| 149 |
+
```shell
|
| 150 |
+
bash -i benchmark/geneval.sh
|
| 151 |
+
bash -i benchmark/dpg_eval.sh
|
| 152 |
+
```
|
| 153 |
+
</details>
|
| 154 |
+
|
| 155 |
+
### Inference
|
| 156 |
+
To inference with the ReasonGen-R1 model, you can use the following command:
|
| 157 |
+
```shell
|
| 158 |
+
python Image-RL/Janus/cot_generate_inference.py
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
### SFT Training
|
| 162 |
+
To train the SFT model from Janus-Pro-7B model on the ReasonGen-R1-SFT-200k dataset, you can use the following command:
|
| 163 |
+
```shell
|
| 164 |
+
bash Image-RL/examples/janus_sft.sh
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
### RL Training
|
| 168 |
+
To train the RL model from the ReasonGen-R1-SFT model, you can use the following command:
|
| 169 |
+
```shell
|
| 170 |
+
bash Image-RL/Janus/janus_rl.py
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
## 5. Acknowledgements
|
| 175 |
+
We would like to thank <a href="https://github.com/volcengine/verl">Verl</a>, upon which our repo is built.
|
| 176 |
+
|
| 177 |
+
## 4. Citation
|
| 178 |
+
|
| 179 |
+
```bibtex
|
| 180 |
+
@article{yu2025reasongen,
|
| 181 |
+
title={ReasonGen-R1: Cot for Autoregressive Image generation models through SFT and RL},
|
| 182 |
+
author={Yu Zhang, Yunqi Li, Yifan Yang, Rui Wang, Yuqin Yang, Qi Dai, Jianming Bao, Dongdong Chen, Chong Luo, Lili Qiu},
|
| 183 |
+
year={2025}
|
| 184 |
+
}
|
| 185 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|