Views
No views yet
1# 1. Clone the repo
2git clone https://github.com/jiaosiyuu/ThinkGen.git
3cd ThinkGen
4
5# 2. (Optional) Create a clean Python environment
6conda create -n thinkgen python=3.11
7conda activate thinkgen
8
9# 3. Install dependencies
10pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124
11pip install -r req.txt
12
13# ThinkGen runs even without flash-attn, though we recommend install it for best performance.
14pip install --no-cache-dir flash-attn==2.7.4.post1 --no-build-isolation1from ThinkGen.model import ThinkGen_Chat
2import os
3
4model_path = "JSYuuu/ThinkGen-stage3"
5
6chat_model = ThinkGen_Chat(
7 model_path=model_path,
8 dtype='bf16',
9 height=1024,
10 width=1024
11)
12
13# 1. Image Generation
14messages = [
15 {"type": "text", "value": "A young woman wearing a straw hat, standing in a golden wheat field."}
16]
17results = chat_model.generate_image(messages)
18results.images[0].save("result.png")
19
20# 2. Image Generation with Thinking (CoT)
21# This enables the MLLM's CoT reasoning for generation
22results_think = chat_model.generate_image(messages, think=True)
23print(f"cot & rewrite prompt:
24{results_think.prompt_cot}")
25results_think.images[0].save("result_think.png")
26
27# 3. Image Understanding
28messages_und = [
29 {"type": "image", "value": "images/teaser.png"},
30 {"type": "text", "value": "Describe this image"}
31]
32response = chat_model.generate_text(messages_und)
33print(response)1@article{jiao2025thinkgen,
2 title={ThinkGen: Generalized Thinking for Visual Generation},
3 author={Jiao, Siyu and Lin, Yiheng and Zhong, Yujie and She, Qi and Zhou, Wei and Lan, Xiaohan and Huang, Zilong and Yu, Fei and Yu, Yingchen and Zhao, Yunqing and Zhao, Yao and Wei, Yunchao},
4 journal={arXiv preprint arXiv:2512.23568},
5 year={2025}
6}