Views
No views yet



1# 1. First install PyTorch (CUDA 12.8 Version)
2pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128
3
4# 2. Install tencentcloud-sdk for Prompt Enhancement (PE) only for HunyuanImage-3.0 not HunyuanImage-3.0-Instruct
5pip install -i https://mirrors.tencent.com/pypi/simple/ --upgrade tencentcloud-sdk-python
6
7# 3. Then install other dependencies
8pip install -r requirements.txt1# FlashInfer for optimized moe inference. v0.5.0 is tested.
2pip install flashinfer-python==0.5.0💡Installation Tips: It is critical that the CUDA version used by PyTorch matches the system's CUDA version. FlashInfer relies on this compatibility when compiling kernels at runtime. GCC version >=9 is recommended for compiling FlashAttention and FlashInfer.
⚡ Performance Tips: These optimizations can significantly speed up your inference!
💡Notation: When FlashInfer is enabled, the first inference may be slower (about 10 minutes) due to kernel compilation. Subsequent inferences on the same machine will be much faster.
1# Download from HuggingFace and rename the directory.
2# Notice that the directory name should not contain dots, which may cause issues when loading using Transformers.
3hf download tencent/HunyuanImage-3.0-Instruct --local-dir ./HunyuanImage-3-Instruct1from transformers import AutoModelForCausalLM
2
3# Load the model
4model_id = "./HunyuanImage-3-Instruct"
5# Currently we can not load the model using HF model_id `tencent/HunyuanImage-3.0-Instruct` directly
6# due to the dot in the name.
7
8kwargs = dict(
9 attn_implementation="sdpa",
10 trust_remote_code=True,
11 torch_dtype="auto",
12 device_map="auto",
13 moe_impl="eager", # Use "flashinfer" if FlashInfer is installed
14 moe_drop_tokens=True,
15)
16
17model = AutoModelForCausalLM.from_pretrained(model_id, **kwargs)
18model.load_tokenizer(model_id)
19
20# Image-to-Image generation (TI2I)
21prompt = "基于图一的logo,参考图二中冰箱贴的材质,制作一个新的冰箱贴"
22
23input_img1 = "./assets/demo_instruct_imgs/input_1_0.png"
24input_img2 = "./assets/demo_instruct_imgs/input_1_1.png"
25imgs_input = [input_img1, input_img2]
26
27cot_text, samples = model.generate_image(
28 prompt=prompt,
29 image=imgs_input,
30 seed=42,
31 image_size="auto",
32 use_system_prompt="en_unified",
33 bot_task="think_recaption", # Use "think_recaption" for reasoning and enhancement
34 infer_align_image_size=True, # Align output image size to input image size
35 diff_infer_steps=50,
36 verbose=2
37)
38
39# Save the generated image
40samples[0].save("image_edit.png")1git clone https://github.com/Tencent-Hunyuan/HunyuanImage-3.0.git
2cd HunyuanImage-3.0/1# Download from HuggingFace
2hf download tencent/HunyuanImage-3.0-Instruct --local-dir ./HunyuanImage-3-Instructrun_demo_instruct.sh.1export MODEL_PATH="./HunyuanImage-3-Instruct"
2bash run_demo_instruct.sh| Arguments | Description | Recommended |
|---|---|---|
--prompt | Input prompt | (Required) |
--image | Image to run. For multiple images, use comma-separated paths (e.g., 'img1.png,img2.png') | (Required) |
--model-id | Model path | (Required) |
--attn-impl | Attention implementation. Now only support 'sdpa' | sdpa |
--moe-impl | MoE implementation. Either eager or flashinfer | flashinfer |
--seed | Random seed for image generation. Use None for random seed | None |
--diff-infer-steps | Number of inference steps | 50 |
--image-size | Image resolution. Can be auto, like 1280x768 or 16:9 | auto |
--use-system-prompt | System prompt type. Options: None, dynamic, en_vanilla, en_recaption, en_think_recaption, en_unified, custom | en_unified |
--system-prompt | Custom system prompt. Used when --use-system-prompt is custom | None |
--bot-task | Task type. image for direct generation; auto for text; recaption for re-write->image; think_recaption for think->re-write->image | think_recaption |
--save | Image save path | image.png |
--verbose | Verbose level | 2 |
--reproduce | Whether to reproduce the results | True |
--infer-align-image-size | Whether to align the target image size to the src image size | True |
--max_new_tokens | Maximum number of new tokens to generate | 2048 |
--use-taylor-cache | Use Taylor Cache when sampling | False |
--diff-infer-steps 8, while keeping all other recommended parameter values unchanged.1# Download HunyuanImage-3.0-Instruct-Distil from HuggingFace
2hf download tencent/HunyuanImage-3.0-Instruct-Distil --local-dir ./HunyuanImage-3-Instruct-Distil
3
4# Run the demo with 8 steps to samples
5export MODEL_PATH="./HunyuanImage-3-Instruct-Distil"
6bash run_demo_instruct_Distil.sh1# Download from HuggingFace and rename the directory.
2# Notice that the directory name should not contain dots, which may cause issues when loading using Transformers.
3hf download tencent/HunyuanImage-3.0 --local-dir ./HunyuanImage-31from transformers import AutoModelForCausalLM
2
3# Load the model
4model_id = "./HunyuanImage-3"
5# Currently we can not load the model using HF model_id `tencent/HunyuanImage-3.0` directly
6# due to the dot in the name.
7
8kwargs = dict(
9 attn_implementation="sdpa", # Use "flash_attention_2" if FlashAttention is installed
10 trust_remote_code=True,
11 torch_dtype="auto",
12 device_map="auto",
13 moe_impl="eager", # Use "flashinfer" if FlashInfer is installed
14)
15
16model = AutoModelForCausalLM.from_pretrained(model_id, **kwargs)
17model.load_tokenizer(model_id)
18
19# generate the image
20prompt = "A brown and white dog is running on the grass"
21image = model.generate_image(prompt=prompt, stream=True)
22image.save("image.png")1git clone https://github.com/Tencent-Hunyuan/HunyuanImage-3.0.git
2cd HunyuanImage-3.0/1# Download from HuggingFace
2hf download tencent/HunyuanImage-3.0 --local-dir ./HunyuanImage-31# Without PE
2export MODEL_PATH="./HunyuanImage-3"
3python3 run_image_gen.py \
4 --model-id $MODEL_PATH \
5 --verbose 1 \
6 --prompt "A brown and white dog is running on the grass" \
7 --bot-task image \
8 --image-size "1024x1024" \
9 --save ./image.png \
10 --moe-impl flashinfer
11
12# With PE
13export DEEPSEEK_KEY_ID="your_deepseek_key_id"
14export DEEPSEEK_KEY_SECRET="your_deepseek_key_secret"
15export MODEL_PATH="./HunyuanImage-3"
16python3 run_image_gen.py \
17 --model-id $MODEL_PATH \
18 --verbose 1 \
19 --prompt "A brown and white dog is running on the grass" \
20 --bot-task image \
21 --image-size "1024x1024" \
22 --save ./image.png \
23 --moe-impl flashinfer \
24 --rewrite 1
25| Arguments | Description | Recommended |
|---|---|---|
--prompt | Input prompt | (Required) |
--model-id | Model path | (Required) |
--attn-impl | Attention implementation. Either sdpa or flash_attention_2. | sdpa |
--moe-impl | MoE implementation. Either eager or flashinfer | flashinfer |
--seed | Random seed for image generation | None |
--diff-infer-steps | Diffusion infer steps | 50 |
--image-size | Image resolution. Can be auto, like 1280x768 or 16:9 | auto |
--save | Image save path. | image.png |
--verbose | Verbose level. 0: No log; 1: log inference information. | 0 |
--rewrite | Whether to enable rewriting | 1 |
pip install gradio>=4.21.01# Set your model path
2export MODEL_ID="path/to/your/model"
3
4# Optional: Configure GPU usage (default: 0,1,2,3)
5export GPUS="0,1,2,3"
6
7# Optional: Configure host and port (default: 0.0.0.0:443)
8export HOST="0.0.0.0"
9export PORT="443"sh run_app.sh1# Use both optimizations for maximum performance
2sh run_app.sh --moe-impl flashinfer --attn-impl flash_attention_2🌐 Web Interface: Open your browser and navigate tohttp://localhost:443(or your configured port)
| Model | Params | Download | Recommended VRAM | Supported |
|---|---|---|---|---|
| HunyuanImage-3.0 | 80B total (13B active) | HuggingFace | ≥ 3 × 80 GB | ✅ Text-to-Image |
| HunyuanImage-3.0-Instruct | 80B total (13B active) | HuggingFace | ≥ 8 × 80 GB | ✅ Text-to-Image ✅ Text-Image-to-Image ✅ Prompt Self-Rewrite ✅ CoT Think |
| HunyuanImage-3.0-Instruct-Distil | 80B total (13B active) | HuggingFace | ≥ 8 × 80 GB | ✅ Text-to-Image ✅ Text-Image-to-Image ✅ Prompt Self-Rewrite ✅ CoT Think ✅ Fewer sampling steps (8 steps recommended) |






Prompt: 3D 毛绒质感拟人化马,暖棕浅棕肌理,穿藏蓝西装、白衬衫,戴深棕手套;疲惫带期待,坐于电脑前,旁置印 "HAPPY AGAIN" 的马克杯。橙红渐变背景,配超大号藏蓝粗体 "马上下班",叠加米黄 "Happy New Year" 并标 "(2026)"。橙红为主,藏蓝米黄撞色,毛绒温暖柔和。





1@article{cao2025hunyuanimage,
2 title={HunyuanImage 3.0 Technical Report},
3 author={Cao, Siyu and Chen, Hangting and Chen, Peng and Cheng, Yiji and Cui, Yutao and Deng, Xinchi and Dong, Ying and Gong, Kipper and Gu, Tianpeng and Gu, Xiusen and others},
4 journal={arXiv preprint arXiv:2509.23951},
5 year={2025}
6}