MAGPIE: Agentic Multi-Reference Image Generation via Executable Scene Construction
Authors: Yifan Dai, Daili Hua, Bohan Zeng, Yuran Wang, Jialing Liu, Bozhou Li, Chengzhuo Tong, Yang Shi, Kai Zeng, Liu Yang, Xinyu Liu, Shujie Li, Yiyan Ji, Bingyin Mei, Yushuo Guan, Yuanxing Zhang, Fangcheng Fu, Wentao Zhang
Organizations: School of Artificial Intelligence, Shanghai Jiao Tong University · Peking University · Renmin University of China · KlingAI Research · SJTU · HKUST · HKU · NJU · THU
Multi-reference image generation requires a model to preserve the appearance of selected subjects while arranging them according to an instruction. Despite recent progress in reference-based generation and compositional control, reliably organizing selected subjects into the intended scene remains challenging. Although existing methods provide various forms of compositional guidance, the planned relationships are not always explicitly instantiated for inspection and refinement before image synthesis. To address this limitation, we introduce MAGPIE, which represents the intended composition as a simplified 3D scene defined by an executable Blender program. A coding agent links each scene instance to its reference, checks the geometry and rendered view against the instruction, and revises the program to correct discrepancies. The final proxy rendering serves as a visual plan for the image generator. Using MAGPIE-Instruct-3K, we train the generator to follow this plan while drawing each subject's appearance from its reference. MAGPIE improves both Qwen and FLUX on DreamOmni2 and SconeEval. With FLUX, it improves overall success on DreamOmni2 by 28.21 percentage points over the original backbone and achieves the highest overall score among the models evaluated on SconeEval.
Figures & tables
Figure 1: Comparison of representative existing methods and MAGPIE. (a) Existing methods provide semantic or spatial guidance without necessarily exposing an explicit scene for verification. (b) In contrast, MAGPIE instantiates compositional intent as an executable 3D proxy, enabling revision before reference-grounded appearance synthesis.
Figure 2: Overview of MAGPIE. The coding harness converts reference images and an instruction into an executable proxy scene through planning, procedural construction, and geometric and visual refinement. The generator combines the proxy’s structure with reference-specific appearance. MAGPIE-Instruct-3K supports lightweight adaptation to this conditioning.
Figure 3: Overview of MAGPIE-Instruct-3K. Across five compositional tasks, the dataset pairs reference images and instructions with proxy renderings and target images to teach generators to follow the proxy’s structure while preserving reference-specific appearance.
Method / Setting
Generation ↑
Editing ↑
Overall ↑
Concrete
Abstract
All
Concrete
Abstract
All
Proprietary Models
Gemini-2.5-flash-Image [ 7 ]
50.00
55.56
54.39
68.29
64.63
65.37
61.44
Seedream-4.0 [ 26 ]
66.67
73.33
71.93
73.17
65.85
67.32
68.97
Open Weight Models
UNO [ 34 ]
0.00
3.33
2.63
0.00
0.61
0.49
1.25
Table 1: Quantitative comparison on DreamOmni2. Small green numbers show percentage-point changes in the three summary metrics relative to the corresponding backbone. Best scores in each group are highlighted in bold.
Method / Setting
Composition ↑
Distinction ↑
Distinction & Composition ↑
Average ↑
Single
Multi
Cross
Intra
Cross
Intra
COM
COM
COM
DIS
COM
DIS
COM
DIS
COM
DIS
COM
DIS
Overall
Proprietary Models
Gemini-2.5-Flash-Image [ 7 ]
8.87
7.94
9.12
9.15
9.00
8.50
8.27
8.87
8.17
8.85
8.56
8.84
8.70
GPT-4o [ 17 ]
8.92
8.51
9.18
8.55
9.45
9.01
8.83
8.49
8.99
9.56
8.98
8.90
8.94
Open-Weight Models
Table 2: Quantitative comparison on SconeEval. Scores range from 0 to 10 (higher is better). COM and DIS denote composition and distinction. Best scores in each group are highlighted in bold.
Figure 4: Qualitative comparison of existing models on DreamOmni2 benchmark.
Method / Setting
Gen. All ↑
Edit. All ↑
Overall ↑
Qwen-Image-Edit-2511
45.61
40.00
42.01
+ Proxy only
35.09
26.34
29.47
+ Standard SFT
42.11
46.34
44.83
+ MAGPIE
67.54
62.44
64.26
FLUX.2-klein-base-9B
35.96
40.49
38.87
+ Proxy only
40.35
49.27
46.08
Table 3: Ablation study of MAGPIE and SFT on DreamOmni2Bench. We report aggregated generation, editing, and overall scores. Bold indicates the best result within each backbone group.
Method / Setting
Gen. Con ↑
Gen. Abs ↑
Gen. All ↑
Qwen-Image-Edit-2511
62.50
41.11
45.61
+ Text Scene
54.17
54.44
54.39
+ 2D Scene
50.00
56.67
55.26
+ 3D Scene (MAGPIE)
62.50
68.89
67.54
FLUX.2-klein-base-9B
70.83
26.67
35.96
+ Text Scene
58.33
58.89
58.77
Table 4: Comparison of different scene planning strategies on DreamOmni2Bench. We report generation scores on concrete and abstract tasks and their sample-weighted aggregate. Bold numeric values denote MAGPIE.
Figure 5: Generation and editing performance across refinement rounds. We visualize the progressive improvement in MAGPIE’s aggregate generation and editing scores on DreamOmni2Bench across 0, 3, and 6 rounds of proxy refinement.
Figure 6: Prompt template for selecting source examples suitable for executable proxy construction. The assessment uses the references, instruction, and target image before a proxy is constructed.
Figure 7: Prompt template for filtering proxy–target pairs by structural consistency. Appearance differences caused by the simplified proxy representation are excluded from the assessment.
Constraint
Operational rule
Inventory and ownership
Each planned entity has at least one executed mesh with its entity_id_ prefix. Declared contact endpoints must map to meshes of the specified subject and target.
Surface contact
For touch , hold , support , and wear , sample vertex-to-surface distances in both directions using bounding volume hierarchies (BVHs). The minimum sampled distance must satisfy d≤τ , with τ=max{10−5,0.025L,min(2p,0.15L)} . Here L is the smaller world-space bounding-box diagonal and p is the camera-derived world-space size of one render pixel at the contact.
Framing
For each frame-required entity, the union of projected mesh bounds must lie within [−0.015,1.015]2 , and no mesh vertex may lie behind the camera.
Entity visibility
Cast a 20×20 ray grid over the clipped projected bounding box. Among rays hitting the entity in isolation, the fraction whose first full-scene hit belongs to that entity must be at least 0.55 for humans and 0.28 otherwise. Named head meshes, when present, receive an additional test with thresholds 0.70 and 0.35 , respectively. Any part of the same entity counts as visible, including for head tests; zero-hit tests fail.
Projected readability
Frame-required entities tagged as humans, animals, or birds must occupy at least 0.20 , 0.13 , or 0.045 of image height, respectively, using clipped projected bounds.
Interaction visibility
Contact meshes named as a hand, handle, shaft, or glasses bridge require exact-part visibility of at least 0.22 : the first scene hit must be that mesh. Nonhuman entities participating in hold require entity visibility of at least 0.65 .
Table 5: Operational constraints for proxy verification. Tests apply to the entities and relations declared in the scene specification. Image coordinates are normalized to [0,1] . Entity visibility measures occlusion by other entities, whereas exact-part visibility distinguishes individual meshes. Visual review complements these approximate geometric diagnostics.
Figure 8: Prompt template for categorizing examples by their principal compositional requirement.
Benchmark
Method / Setting
Plan
Init.
Refine
Synth.
Total ↓
DreamOmni2Bench
Qwen
–
–
–
77.20
77.20
+ MAGPIE
20.65
56.32
195.20
103.01
375.18
FLUX
–
–
–
60.97
60.97
+ MAGPIE
20.65
56.32
195.20
84.55
356.72
SconeEval
Qwen
–
–
–
78.50
78.50
+ MAGPIE
27.33
85.18
224.72
107.00
444.23
Table 6: Inference time breakdown. Mean recorded stage time per example in seconds. Plan, Init., Refine, and Synth. denote scene planning, initial proxy construction, verification and refinement, and image synthesis, respectively. Total is the sum of the displayed stage means, excluding untimed overhead. Qwen and FLUX denote Qwen-Image-Edit-2511 and FLUX.2-klein-base-9B. A dash denotes an absent stage.
Method
COM ↑
DIS ↑
Overall ↑
Qwen-Image-Edit-2511
8.21
8.23
8.22
Budgeted base
8.59
8.50
8.54
+ MAGPIE
8.60
9.26
8.93
FLUX.2-klein-base-9B
8.20
7.93
8.07
Budgeted base
8.48
8.36
8.42
+ MAGPIE
8.68
9.43
9.05
Table 7: Comparison under comparable inference time budgets on SconeEval. Budgeted base uses best-of-six sampling with manual selection. Scores range from 0 to 10; bold marks the best score within each backbone group. Human selection time is excluded.
Max. rounds
Edit. ↑
Gen. ↑
Overall ↑
Proxy Time (s) ↓
0
54.63
51.75
53.61
76.97
3
60.98
61.40
61.13
211.44
6
66.83
67.54
67.08
272.17
Table 8: Refinement budget, performance, and construction time. The adapted FLUX generator is fixed across all settings. Edit., Gen., and Overall are DreamOmni2Bench success rates (%). Proxy time includes scene planning, initial proxy construction, and refinement. Best scores are highlighted in bold.
Figure 9: Proxy scenes across refinement budgets. Each row shows the reference images, instruction, and proxies selected with maximum budgets of 0, 3, and 6 refinement rounds.
Task group
N
Correct (%)
Minor issue (%)
Major error (%)
Cohen’s κ
Abstract editing
164
92.07
7.93
0.00
0.827
Concrete editing
41
95.12
4.88
0.00
0.787
Abstract generation
90
86.67
11.11
2.22
0.854
Concrete generation
24
100.00
0.00
0.00
-
Table 9: Human evaluation of proxy quality on DreamOmni2Bench. Each selected proxy receives one overall quality label. N denotes the number of audited examples. Percentages are computed within each task group. Cohen’s κ measures annotator agreement before disagreement resolution. A dash denotes an unavailable agreement statistic.
Figure 10: Qualitative results on SconeEval. Each row shows the reference images, instruction, selected proxy, and final image generated with MAGPIE. The examples cover multi-subject arrangements, articulated poses, and interactions.
Figure 11: Proxy scene comparison across coding agents. Each group shares the same reference images and instruction and compares the proxy renderings returned by six agents using the same MAGPIE harness. The examples compare subject inclusion, spatial arrangement, and the geometric realization of poses and interactions.
Multi-reference image generation aims to synthesize images by integrating attributes from multiple reference images under textual instructions. As the number of references increases, the task necessitates complex semantic comprehension, such as correctly associating attributes with the intended subjects and planing out coherent spatial arrangement between subjects and their environments. Existing approaches, which rely solely on natural language instruction, often fail to capture these complex intentions precisely, leading to semantic misalignment and inconsistent generation. We identify two key factors behind these limitations: natural language instructions are often verbose and ambiguous, and high-quality multi-reference data is scarce. To address these issues, we propose StructGen, which employs a structured, dictionary-like format to encode multiple reference images, thereby enabling explicit and unambiguous specification of generation intentions. To support this design, we construct a structured dataset based on high-quality real images and develop a corresponding training framework, along with a dedicated benchmark for challenging multi-reference scenarios. Extensive experiments on both public benchmarks and our proposed benchmark demonstrate that StructGen consistently outperforms existing methods on both semantic alignment and detailed reference-generation consistency, especially under complex instructions with multiple references. The code is available at https://jianingpeng0382.github.io/StructGen/
Jianing Peng, Mengyu Wang, Henghui Ding +6
Institute of Information Science, Beijing Jiaotong University, Beijing, China · Visual Intelligence + X International Joint Laboratory of the Ministry of Education, Beijing, China · MT Lab, Meitu Inc, Beijing, China +2
Recent image generation models can take multiple reference images as input and combine them into a new image. However, multi-reference image generation remains challenging: models may omit or duplicate subjects from the references, or produce images in which multiple subjects appear unnaturally pasted. Recent work has proposed image generation agents that combine image generation models, reasoning models, and a harness, which is an executable program that specifies how reference images are interpreted, how generation is performed, how outputs are diagnosed, and how the final image is selected. In multi-reference generation, however, references play different roles and outputs must satisfy many criteria at once, such as fidelity to each reference and the naturalness of the whole image, so many parts of the harness could be improved, from how references are processed to how outputs are diagnosed. This makes it hard to predict which changes will improve performance and by how much, and good harnesses difficult to design by hand; indeed, human-written harnesses vary widely in performance. We therefore propose AutoRef, which optimizes the harness automatically while keeping both models frozen: a coding agent iteratively rewrites the harness code. AutoRef separates the tasks whose feedback informs proposals from the tasks used to select candidates, and continues the search from a beam of the top-ranked harnesses on the selection tasks. Using this procedure, we discover AutoRef-Harness, which improves the open-weight FLUX.2 [klein] 4B from 5.72 to 7.37 on held-out four-reference tasks of the MultiBanana benchmark, matching or exceeding proprietary models including Nano Banana Pro and GPT-Image-1.5. Without re-optimization, the same harness also improves results when the generator, number of references, benchmark, evaluator, or reasoning model differs from those used in the search.
Multi-reference image generation aims to synthesize images from textual instructions while faithfully preserving subject identities from multiple reference images. Existing VLM-enhanced diffusion models commonly rely on decoupled visual conditioning: semantic ViT features are processed by the VLM for instruction understanding, whereas appearance-rich VAE features are injected later into the diffusion backbone. Despite its intuitive design, this separation makes it difficult for the model to associate each semantically grounded subject with visual details from the correct reference image. As a result, the model may recognize which subject is being referred to, but fail to preserve its identity and fine-grained appearance, leading to attribute leakage and cross-reference confusion in complex multi-reference settings. To address this issue, we propose UniCustom, a unified visual conditioning framework that fuses ViT and VAE features before VLM encoding. This early fusion exposes the VLM to both semantic cues and appearance-rich details, enabling its hidden states to jointly encode the referred subject and corresponding visual appearance with only a lightweight linear fusion layer. To learn such unified representations, we adopt a two-stage training strategy: reconstruction-oriented pretraining that preserves reference-specific appearance details in the fused hidden states, followed by supervised finetuning on single- and multi-reference generation tasks. We further introduce a slot-wise binding regularization that encourages each image slot to preserve low-level details of its corresponding reference, thereby reducing cross-reference entanglement. Experiments on two multi-reference generation benchmarks demonstrate that UniCustom consistently improves subject consistency, instruction following, and compositional fidelity over strong baselines.
Yiyan Xu, Qiulin Wang, Wenjie Wang +5
University of Science and Technology of China · Kling Team, Kuaishou Technology