Manuscript Offprint
arXiv:2610.36506GarmentSegAgent: Autonomous Garment Segmentation for Web Fashion Images via Textual Self-Refinement
Abstract
Web fashion images support applications such as visual product search and consumer-to-shop matching, yet their visual heterogeneity makes reliable garment segmentation challenging. Despite advances in promptable segmentation, autonomously identifying and correcting garment-specific errors without human-provided spatial prompts remains difficult. We propose GarmentSegAgent, an autonomous framework that integrates semantic planning, spatial execution, and visual evaluation through iterative textual self-refinement. At its core, we introduce CAST (Constrained Attribution-guided Selective TextGrad), which connects visual error attribution with targeted textual optimization. CAST identifies instruction components responsible for segmentation errors, selectively updates them through textual gradients, and validates the resulting instructions against garment-specific constraints. This enables image-specific error correction at inference time while keeping the underlying foundation models frozen. Experiments on DeepFashion2, ModaNet, and Fashionpedia demonstrate consistent improvements in region overlap and boundary accuracy, alongside more reliable refinement than conventional TextGrad. By enabling visual feedback to guide controlled instruction updates, GarmentSegAgent offers a promising direction for autonomous garment understanding, with potential applications in scalable fashion content analysis, visual retrieval, and consumer-to-shop matching on the Web.
Keywords
garment segmentation, agentic segmentation, visual error attribution, textual optimization, web fashion images
Visual segmentation has progressed from garment-specific architectures, such as FashionFormer [26], to promptable foundation models [4] including SAM [12] and SAM 2 [21]. Grounding DINO [15] and LISA [13] further support language-guided object localization and segmentation, respectively, while SAM-REF [29] improves segmentation details through image-prompt interaction. Despite these advances, generating accurate masks from spatial or textual prompts does not necessarily address errors in the instructions guiding segmentation. In heterogeneous Web fashion images, ambiguous targets, occlusions, and overlapping garments can lead to incorrect target selection or incomplete garment coverage. Reliable autonomous segmentation therefore requires not only effective mask generation but also the ability to diagnose intermediate errors and refine the guiding instructions without human intervention.
Recent studies have extended segmentation beyond single-pass prediction by incorporating sequential reasoning and feedback. SegAgent [33] learns segmentation actions from human annotation trajectories, while RSAgent [9] integrates multi-turn reasoning and tool execution through supervised fine-tuning and reinforcement learning. Other approaches explore collaborative reflection in video segmentation [11] and guideline-consistent segmentation through a training-free Worker–Supervisor framework [23]. These developments highlight the potential of agentic segmentation, yet a key challenge remains: how should visual errors guide updates to specific segmentation instructions? For example, the missing sleeve and background leakage in Fig. 1(a) require distinct corrections to garment coverage and region exclusion. This motivates connecting visual error diagnosis with targeted instruction refinement.
Textual optimization provides a flexible means of refining instructions through feedback without modifying model parameters [1, 25]. ProTeGi [19] employs natural-language gradients for prompt refinement, while OPRO [27] uses language models to iteratively search for effective instructions. TextGrad [30] further enables feedback-driven optimization of textual variables in compound AI systems through language-based backpropagation. However, applying general-purpose textual optimization to garment segmentation requires accounting for the relationship between visual errors and individual instruction components. The whole-prompt revision depicted in Fig. 1(b) exemplifies how correcting localized errors may inadvertently disrupt previously valid segmentation decisions. Effective refinement therefore requires identifying error-relevant textual variables while maintaining garment-specific constraints.
To enable error-specific and constraint-aware refinement, we propose GarmentSegAgent, an autonomous garment segmentation framework integrating semantic planning, spatial execution, and visual evaluation within an iterative self-refinement process. At its core, CAST (Constrained Attribution-guided Selective TextGrad)
Jia Chen and Chao Huang contributed equally to this work.
Corresponding author: Jun Bai (jun.bai@adelaide.edu.au).
(a) Initial Segmentation Error

Prompt:
"Segment upper-garment"
(b) Naive Whole-Prompt Refinement

(c) CAST: Error-Attributed Selective Refinement

Figure 1: Motivation for error-attributed selective textual refinement. (a) Initial segmentation with missing garment regions and background leakage. (b) Naive whole-prompt refinement may disrupt otherwise correct instructions. (c) CAST maps visual errors to relevant instruction fields for selective, garment-constrained textual refinement.
connects visual segmentation errors with structured textual optimization. CAST attributes observed errors to four instruction fields—target, localization, coverage, and exclusion—and selectively applies TextGrad updates to the relevant variables. For instance, CAST directs missing garment regions to coverage refinement and background leakage to exclusion refinement, while preserving unrelated instructions under garment-specific constraints (Fig. 1(c)). The refined instructions subsequently guide spatial prompt generation and segmentation, enabling autonomous, image-specific refinement without human-provided spatial prompts or fine-tuning the underlying foundation models.
Our main contributions are threefold. (1) Autonomous Garment Segmentation. We introduce GarmentSegAgent, a feedback-driven framework that enables autonomous, iterative garment segmentation without human-provided spatial prompts or foundation-model fine-tuning. (2) Error-Attributed Textual Refinement. We propose CAST, a task-aware optimization mechanism that maps visual segmentation errors to relevant textual variables and performs selective TextGrad updates under garment-specific constraints. (3) Comprehensive Experimental Validation. Experiments across three fashion benchmarks demonstrate superior region and boundary accuracy, while refinement analyses and ablations establish the effectiveness of CAST in improving optimization reliability.
2 Related Work
Agentic Segmentation. Agentic segmentation extends mask prediction through sequential reasoning, tool interaction, and feedback-driven correction [24, 28]. SegAgent [33] learns multi-step segmentation policies from human annotation trajectories, whereas RSAgent [9] combines multi-turn tool use with supervised fine-tuning and reinforcement learning. Other approaches emphasize agent coordination and iterative evaluation. Refer-Agent [11] introduces collaborative reasoning and reflection for referring video segmentation, while guideline-consistent segmentation [23] employs a Worker-Supervisor framework with guideline-based feedback and adaptive termination. These approaches advance segmentation through learned action policies, collaborative reasoning, and iterative mask correction.
Textual Optimization. Language-based refinement has been explored through iterative self-feedback, verbal reflection, and tool-assisted correction [8, 17, 22]. For prompt optimization, ProTeGi [19] employs natural-language gradients and beam search, while OPRO [27] uses language models to optimize instructions based on previous evaluations. TextGrad [30] further extends textual optimization to compound AI systems through language-based backpropagation across textual variables. These methods provide general mechanisms for optimizing instructions without differentiating through underlying models. Applying such optimization to segmentation additionally requires grounding visual errors in relevant instruction variables and maintaining task-specific constraints during updates.
3 Methodology
3.1 Problem Formulation and Framework Overview
We consider autonomous garment segmentation in heterogeneous Web fashion images. Given an input image and an initial textual instruction , the objective is to extract a target garment instance as a binary segmentation mask without human-provided spatial prompts. We formulate this task as an iterative process in which segmentation predictions are evaluated and refined through visual feedback at inference time.

Figure 2: Overview of GarmentSegAgent. The Planner generates a garment-aware semantic plan, the Actor produces candidate masks, and the Evaluator selects predictions and provides visual feedback. CAST performs selective, garment-constrained textual refinement to guide subsequent segmentation iterations.
To maintain task consistency, we introduce a garment extraction contract g specifying target-selection rules and segmentation constraints. Given an instruction p, the Planner P generates a semantic segmentation plan, which the Actor S converts into spatial prompts to produce candidate masks:
The visual Evaluator selects a mask from and provides feedback on segmentation errors. We formulate textual self-refinement as a constrained test-time optimization problem:
where denotes evaluator-estimated segmentation quality and is the set of instructions satisfying the garment contract. This objective guides feedback-driven refinement under a finite inference budget.
To realize this formulation, we develop GarmentSegAgent, which integrates semantic planning, spatial execution, visual evaluation, and CAST-based textual optimization into a closed-loop framework, as shown in Fig. 2. CAST attributes visual errors to relevant instruction components and selectively refines them through TextGrad under garment-specific constraints. The validated instructions guide subsequent segmentation iterations, while all foundation models remain frozen.
3.2 Garment-Aware Planning and Spatial Execution
We represent the segmentation instruction at iteration t as four structured textual variables: , corresponding to target selection, spatial localization, garment coverage, and region exclusion, respectively. These variables allow individual instruction components to be selectively refined while maintaining consistency with the garment extraction contract g.
Given the image I, current instruction , and contract g, the Planner employs Qwen2.5-VL [3] to generate a garment-aware semantic plan:
where describes the target garment, denotes its estimated bounding box, and and specify candidate foreground and exclusion regions, respectively.
The Actor translates this semantic plan into spatial prompts for SAM 2.1. Using the estimated bounding box and positive and negative point configurations derived from the corresponding regions, it generates a set of candidate masks:
where and denote the positive and negative point sets for the k-th prompt configuration, and is the number of candidate configurations. The resulting masks are passed to the Evaluator for candidate selection and visual error diagnosis.
3.3 Visual Error Attribution
Despite garment-aware planning, the generated masks may contain target mismatches, incomplete garment regions, or inaccurate boundaries. A coarse quality assessment alone provides limited guidance for targeted correction. We therefore introduce Visual Error Attribution (VEA) to characterize segmentation errors as structured visual feedback for subsequent textual optimization.
Given the image I, candidate masks , current instruction , and garment contract g, the visual Evaluator selects a candidate mask and generates error-specific feedback:
where is the selected mask and denotes its structured visual feedback. VEA considers four error categories: target mismatch, missing regions, region leakage, and boundary errors. Each identified error is represented by
where is the number of identified errors, denotes the error category, specifies the affected visual region, and represent error severity and evaluator confidence, respectively, and describes a suggested correction.
VEA infers these errors from the input image and predicted masks without accessing ground-truth annotations. For instance, a missing sleeve indicates insufficient garment coverage, whereas retained skin regions suggest inadequate exclusion. These structured diagnostics provide error-specific signals that CAST maps to relevant instruction variables for selective textual refinement.
3.4 CAST: Constrained Attribution-Guided Selective TextGrad
Constrained Textual Optimization. TextGrad [30] enables feedback-driven optimization of textual variables, but unrestricted instruction updates may disrupt previously valid components when correcting localized segmentation errors. To address this issue, we introduce CAST, which couples visual error attribution with selective textual optimization under garment-specific constraints.
Let index the four instruction fields defined in Section 3.2, and let denote the error-relevant fields selected at iteration . We formulate the desired refinement as
This formulation restricts updates to selected instruction fields while requiring the resulting instruction to satisfy the garment contract. CAST operationalizes this objective through error-to-instruction routing, selective TextGrad updates, and garment-constrained validation.
Error-to-Instruction Routing. CAST identifies the instruction fields requiring refinement based on the error categories detected by VEA. Given the structured feedback , the active instruction set is determined by
where R maps each error category to a subset of instruction fields in J. Specifically, target mismatches activate target and localization; missing garment regions activate coverage and localization; region leakage activates exclusion and localization; and boundary inaccuracies activate coverage and localization. When multiple errors are detected, their associated fields are combined, while unrelated instruction components remain unchanged during refinement.
Selective Textual Gradient Descent. Given the selected instruction fields , CAST applies TextGrad to refine only the variables associated with detected visual errors. For each , the corresponding error feedback is collected as . We construct a component-specific textual loss:
where produces an error-conditioned assessment of the selected field in the context of the full instruction and garment contract. The textual loss is propagated through the language-based backward operator:
where denotes the textual backward operator and denotes the natural-language gradient identifying potential corrections to the selected instruction field. Unlike numerical gradients, this feedback provides semantic guidance for instruction revision.
The resulting gradients drive selective textual updates:
where denotes the TextGrad optimizer step. This operation updates only error-relevant fields while leaving the remaining components unchanged. The resulting candidate instruction is subsequently validated against the garment contract
Garment-Constrained Update. Although selective TextGrad restricts instruction updates to error-relevant fields, the resulting candidates may still violate garment-specific requirements. We therefore introduce a contract-aware validation operator:
where checks the candidate instruction against the garment contract and update scope. Compliant updates are accepted, while violations are repaired when feasible or rolled back to . This process aims to maintain target identity, coverage, and exclusion requirements without altering unselected instruction fields.
Together, visual error attribution, selective TextGrad, and garment-constrained validation enable CAST to refine instructions based on localized segmentation errors. The validated instruction is returned to the Planner for the next segmentation iteration, while all foundation models remain frozen. Theoretical analysis of update locality and conditional constraint preservation is provided in Appendix E.
Algorithm 1 GarmentSegAgent with CAST Optimization
Require: Image I, initial instruction , garment contract g, iteration budget T
Ensure: Segmentation mask
1: for do
2:
3:
4:
5:
6: if then
7: return
8: end if
9:
10:
11: for do
12:
13:
14:
15:
16: end for
17:
18: end for
3.5 Iterative Decision and Termination
At each iteration, the Evaluator determines whether the selected mask requires further refinement based on its visual error feedback and the garment contract :
where denotes the evaluator-based decision function. A mask is accepted when the Evaluator judges it consistent with the garment extraction requirements. Otherwise, CAST generates a validated instruction , which guides the Planner and Actor in producing new segmentation candidates. The complete inference procedure is summarized in Algorithm 1.
To bound inference cost, we allow at most T segmentation iterations. The process terminates upon acceptance or when the iteration budget is exhausted. The stopping iteration and final segmentation mask are defined as
where . If no mask is accepted, the final candidate is returned. Each image is processed independently, with all foundation models remaining frozen.
4 Experiments
4.1 Experimental Setup
4.1.1 Datasets and Evaluation Protocol. We evaluate GarmentSegAgent on three fashion segmentation benchmarks: DeepFashion2 [7], ModaNet [32], and Fashionpedia [10]. DeepFashion2 includes consumer and commercial images with diverse garment appearances, viewpoints, and occlusions. ModaNet features street-fashion imagery with cluttered backgrounds and varied clothing configurations, while Fashionpedia provides fine-grained annotations across garment categories and attributes. Together, these datasets cover diverse visual conditions and garment characteristics.
We adopt a unified upper-garment segmentation setting, evaluating 500 images from each benchmark. The objective is to extract a target upper-garment instance as a binary mask. For images containing multiple garments, a consistent target-selection and annotation-matching protocol determines the evaluation target, as detailed in Appendix A. GarmentSegAgent processes each image independently without human-provided spatial prompts or access to ground-truth annotations. Its refinement relies solely on the input image and intermediate visual feedback, with ground-truth masks and evaluation metrics reserved for offline assessment.
4.1.2 Baselines. We compare GarmentSegAgent with representative baselines across spatial prompting, vision-language segmentation, and reasoning-based or agentic segmentation. Spatial prompting methods include SAM 2 [21] with box prompts and Grounding DINO+SAM 2 [15], which generates spatial prompts through object detection. Vision-language segmentation methods include READ [20], SEEM [34], and LISA [13]. We further include SegZero+SAM 2 [16] and SegAgent [33] as reasoning-based and agentic segmentation baselines, respectively. All methods are evaluated on identical image subsets and target garment definitions. We distinguish externally supplied spatial prompts from automatically generated prompts to account for differences in prompting requirements.
4.1.3 Implementation Details. GarmentSegAgent employs Qwen2.5-VL as the Planner, SAM 2.1 as the segmentation Actor, and Qwen3-VL [2] as the visual Evaluator. The Planner generates a garment-aware semantic plan, which the Actor translates into bounding-box and positive/negative point prompts for candidate mask generation. The Evaluator selects a mask and provides structured visual feedback to CAST, which selectively refines the target, localization, coverage, and exclusion instruction fields under garment-specific constraints. All foundation models remain frozen, and each image is processed independently without cross-image state sharing. We allow at most five segmentation iterations, including the initial prediction, with early termination upon evaluator acceptance.
4.1.4 Evaluation Metrics. We assess segmentation quality using mean Intersection over Union (mIoU), Dice coefficient [18], Boundary IoU (BIoU) [5], precision, and recall. mIoU and Dice quantify region-level agreement between predicted and ground-truth garment masks, while BIoU measures boundary alignment, particularly for fine garment structures and irregular contours. Precision and recall further characterize foreground leakage and missing garment regions, respectively. To evaluate textual self-refinement, we additionally report IoU improvement from the initial prediction, improvement and degradation rates, and inference costs in terms of refinement steps, language-model calls, and execution time.
4.2 Main Results
Table 1 compares GarmentSegAgent with representative baselines on DeepFashion2, ModaNet, and Fashionpedia in terms of region overlap, boundary accuracy, and foreground prediction quality. Additional experiments evaluate GarmentSegAgent on COCO [14] person segmentation and examine CAST performance across shop
Table 1: Quantitative comparison of upper-garment segmentation on DeepFashion2, ModaNet, and Fashionpedia. The best score for each metric within each dataset is highlighted in bold.
| Dataset | Method | Source | mIoU↑ | Dice↑ | Boundary IoU↑ | Precision↑ | Recall↑ |
|---|---|---|---|---|---|---|---|
| DeepFashion2 | SEEM | NeurIPS'23 | 0.4587 | 0.5619 | 0.2372 | 0.4777 | 0.7862 |
| LISA | CVPR'24 | 0.6913 | 0.7761 | 0.4688 | 0.7340 | 0.8828 | |
| SAM 2 (box-only) | ICLR'25 | 0.6328 | 0.7047 | 0.4124 | 0.7130 | 0.7391 | |
| Grounding DINO + SAM 2 | ECCV'24 / ICLR'25 | 0.2689 | 0.2889 | 0.2122 | 0.3129 | 0.2759 | |
| READ | CVPR'25 | 0.6067 | 0.6866 | 0.4008 | 0.7728 | 0.6761 | |
| SegAgent | CVPR'25 | 0.4638 | 0.5675 | 0.2477 | 0.5871 | 0.7178 | |
| SegZero + SAM 2 | arXiv'25 / ICLR'25 | 0.7959 | 0.8629 | 0.6047 | 0.8877 | 0.8765 | |
| GarmentSegAgent (Ours) | - | 0.8124 | 0.8736 | 0.6318 | 0.9156 | 0.8741 | |
| ModaNet | SEEM | NeurIPS'23 | 0.2624 | 0.4009 | 0.1391 | 0.2645 | 0.9699 |
| LISA | CVPR'24 | 0.4538 | 0.5910 | 0.3380 | 0.4634 | 0.9340 | |
| SAM 2 (box-only) | ICLR'25 | 0.5940 | 0.6765 | 0.5020 | 0.6410 | 0.7590 | |
| Grounding DINO + SAM 2 | ECCV'24 / ICLR'25 | 0.1304 | 0.1397 | 0.1146 | 0.1433 | 0.1388 | |
| READ | CVPR'25 | 0.5143 | 0.6292 | 0.3906 | 0.5400 | 0.8138 | |
| SegAgent | CVPR'25 | 0.2996 | 0.4428 | 0.1812 | 0.3122 | 0.9549 | |
| SegZero + SAM 2 | arXiv'25 / ICLR'25 | 0.6683 | 0.7337 | 0.5814 | 0.7105 | 0.8021 | |
| GarmentSegAgent (Ours) | - | 0.6733 | 0.7476 | 0.6027 | 0.7220 | 0.8301 | |
| Fashionpedia | SEEM | NeurIPS'23 | 0.3043 | 0.4376 | 0.1685 | 0.3059 | 0.9078 |
| LISA | CVPR'24 | 0.5326 | 0.6545 | 0.4086 | 0.5456 | 0.9281 | |
| SAM 2 (box-only) | ICLR'25 | 0.6989 | 0.7627 | 0.6180 | 0.7312 | 0.8642 | |
| Grounding DINO + SAM 2 | ECCV'24 / ICLR'25 | 0.2191 | 0.2291 | 0.2012 | 0.2299 | 0.2328 | |
| READ | CVPR'25 | 0.4496 | 0.5412 | 0.3554 | 0.5089 | 0.6350 | |
| SegAgent | CVPR'25 | 0.3558 | 0.5034 | 0.2063 | 0.3613 | 0.9158 | |
| SegZero + SAM 2 | arXiv'25 / ICLR'25 | 0.7426 | 0.8158 | 0.6662 | 0.7706 | 0.9332 | |
| GarmentSegAgent (Ours) | - | 0.7685 | 0.8375 | 0.6950 | 0.7940 | 0.9410 |
Table 2: Comparison of textual refinement strategies on three fashion segmentation benchmarks. BIoU denotes Boundary IoU. All iterative methods share the same foundation models and maximum refinement budget.
| Method | DeepFashion2 | ModaNet | Fashionpedia | |||
|---|---|---|---|---|---|---|
| mIoU↑ | BIoU↑ | mIoU↑ | BIoU↑ | mIoU↑ | BIoU↑ | |
| One-pass | 0.6961 | 0.6148 | 0.6145 | 0.5369 | 0.6982 | 0.6080 |
| Rule-based Refinement | 0.7014 | 0.6179 | 0.6399 | 0.5534 | 0.7080 | 0.6079 |
| Vanilla TextGrad | 0.7568 | 0.6242 | 0.6001 | 0.5221 | 0.7235 | 0.6304 |
| All-field TextGrad | 0.7491 | 0.6218 | 0.6283 | 0.5392 | 0.7128 | 0.6153 |
| Selective TextGrad | 0.7836 | 0.6287 | 0.6454 | 0.5558 | 0.7339 | 0.6612 |
| Full CAST (Ours) | 0.8124 | 0.6318 | 0.6733 | 0.6027 | 0.7685 | 0.6950 |
and consumer images in DeepFashion2 (Appendix B Table 5, Fig. 6, and Table 6).
Performance on DeepFashion2. GarmentSegAgent achieves an mIoU of 0.8124, outperforming the strongest baseline, SegZero+SAM 2, by 1.65 percentage points. Boundary IoU also improves from 0.6047 to 0.6318, indicating better preservation of garment boundaries. Moreover, GarmentSegAgent achieves the highest precision (0.9156), reflecting reduced foreground leakage. Although LISA attains slightly higher recall, its considerably lower precision and mIoU suggest a less favorable balance between garment coverage and background exclusion.
Performance on ModaNet. On ModaNet, the performance advantage is more modest in region overlap but more evident in boundary accuracy. Compared with SegZero+SAM 2, GarmentSegAgent improves mIoU from 0.6683 to 0.6733, while Boundary IoU increases from 0.5814 to 0.6027, suggesting better delineation of garment contours in street-fashion scenes. Although SEEM and SegAgent achieve higher recall, their substantially lower precision indicates greater foreground leakage. In contrast, GarmentSegAgent achieves a precision of 0.7220 and recall of 0.8301, outperforming SegZero+SAM 2 on both metrics and maintaining a better balance between garment coverage and background exclusion.
Performance on Fashionpedia. Fashionpedia shows the most consistent performance gains, with GarmentSegAgent outperforming all baselines across five evaluation metrics. Compared with SegZero+SAM 2, mIoU and Boundary IoU improve by 2.59 and 2.88 percentage points, reaching 0.7685 and 0.6950, respectively. Notably, precision and recall increase simultaneously, indicating more complete garment coverage with reduced foreground leakage. These results demonstrate improved region and boundary accuracy in a benchmark featuring fine-grained garment annotations.
4.3 Textual Optimization Strategies
To investigate the effects of textual refinement, we compare five optimization strategies against a One-pass reference without refinement. Rule-based Refinement applies predefined corrections based on evaluator feedback, while Vanilla TextGrad optimizes the entire instruction as a single variable. All-field TextGrad independently updates all four instruction fields, whereas Selective TextGrad updates only fields associated with visual errors. Full CAST additionally

Vanilla TextGrad (mean)
Vanilla TextGrad (95% bootstrap CI)
Full CAST (mean)
Full CAST (95% bootstrap CI)
Figure 3: Evolution of mIoU during iterative refinement on (a) DeepFashion2, (b) ModaNet, and (c) Fashionpedia. Iteration 0 denotes the initial prediction. Shaded regions indicate 95% bootstrap confidence intervals. Predictions from early-terminated samples are retained for subsequent iterations.
Table 3: Refinement outcomes and inference cost on three fashion benchmarks. IR and DR denote the percentages of improved and degraded predictions, respectively.
| Dataset | Method | Refinement Outcomes | Inference Cost | ||||
|---|---|---|---|---|---|---|---|
| ΔIoU↑ | IR (%)↑ | DR (%)↓ | Avg. Steps↓ | LLM Calls↓ | Time (s/img)↓ | ||
| DeepFashion2 | Vanilla TextGrad | +0.0607 | 72.4 | 18.0 | 2.2 | 4.4 | 7.8 |
| Full CAST | +0.1163 | 88.7 | 6.4 | 2.6 | 6.1 | 10.9 | |
| ModaNet | Vanilla TextGrad | -0.0144 | 43.8 | 48.2 | 2.4 | 4.8 | 8.5 |
| Full CAST | +0.0588 | 79.6 | 12.0 | 2.7 | 6.4 | 11.8 | |
| Fashionpedia | Vanilla TextGrad | +0.0253 | 61.5 | 29.2 | 2.2 | 4.4 | 7.9 |
| Full CAST | +0.0703 | 83.5 | 9.2 | 2.5 | 5.9 | 10.6 | |
incorporates garment-contract validation. All iterative methods share the same foundation models, initial instructions, evaluation protocol, and iteration budget. Table 2 reports the results.
The results highlight the limitations of unrestricted textual refinement. Although Vanilla TextGrad improves mIoU on DeepFashion2 and Fashionpedia, it degrades performance on ModaNet from 0.6145 to 0.6001 relative to One-pass. Updating all instruction fields does not consistently improve performance either. By contrast, Selective TextGrad outperforms both variants across all three benchmarks, supporting the effectiveness of error-conditioned field selection.
Full CAST further achieves the highest mIoU and Boundary IoU on every benchmark. Relative to Selective TextGrad, its mIoU gains reach 2.88, 2.79, and 3.46 percentage points on DeepFashion2, ModaNet, and Fashionpedia, respectively. Boundary IoU improvements are especially notable on ModaNet and Fashionpedia, reaching 4.69 and 3.38 percentage points. These results underscore the complementary roles of selective instruction updates and garment-specific consistency validation in reliable textual refinement.
4.4 Self-Refinement Analysis
Iterative Refinement Dynamics. Figure 3 compares the evolution of mIoU across refinement iterations for Vanilla TextGrad and CAST under identical initial predictions. On DeepFashion2 and Fashionpedia, both methods improve through iterative refinement, with CAST achieving larger gains. A contrasting trend appears on ModaNet, where Vanilla TextGrad reduces mIoU from 0.6145 to 0.6001, whereas CAST progressively improves it to 0.6733. These divergent trajectories demonstrate that repeated refinement does not inherently improve segmentation; its effectiveness depends on how visual errors guide textual updates. For early-terminated samples, the final predictions are retained in subsequent plotted iterations to maintain a consistent evaluation set. Further examples of iterative mask evolution and instruction updates are provided in Appendix B (Fig. 5) and Appendix C (Table 7), respectively. An illustrative case study of error-attributed instruction refinement is provided in Appendix D.
Refinement Reliability. Average segmentation gains alone do not capture the risk of harmful instruction updates. We therefore report the mean IoU change ( IoU) between initial and final predictions, along with improvement rate (IR) and degradation rate (DR), measuring the proportions of samples with increased and decreased IoU, respectively. As shown in Table 3, CAST consistently achieves larger IoU gains, higher improvement rates, and lower degradation rates. The contrast is particularly evident on ModaNet, where CAST increases IR from 43.8% to 79.6% while reducing DR from 48.2% to 12.0%. Similar reductions in degradation are observed on DeepFashion2 and Fashionpedia, indicating more reliable image-specific textual refinement.
Inference Cost. These reliability improvements incur additional inference overhead. Compared with Vanilla TextGrad, CAST requires approximately 1.5–1.7 more language-model calls per image,

Figure 4: Qualitative comparison of upper-garment segmentation under target ambiguity, occlusion, ambiguous boundaries, and multiple garments (top to bottom). Columns show the input, ground truth (GT), and predictions from SAM 2, LISA, SegZero + SAM 2, and GarmentSegAgent (Ours). GT is used only for evaluation.
with average inference time increasing by 2.7–3.3 seconds across the three benchmarks. For instance, on ModaNet, inference time increases from 8.5 to 11.8 seconds per image, accompanied by a substantial reduction in degradation rate. This trade-off reflects the additional computation associated with error-attributed refinement and garment-constrained validation, rather than improved inference efficiency.
4.5 Ablation Studies
We investigate the contributions of three core CAST mechanisms: visual error attribution (VEA), selective routing, and garment-contract validation. As shown in Table 4, removing VEA reduces mIoU from 0.8124 to 0.7128 and Boundary IoU from 0.6318 to 0.4924, highlighting the importance of structured visual feedback. Disabling selective routing similarly degrades mIoU to 0.7287 and Boundary IoU to 0.5121, supporting the benefit of error-guided instruction updates. Without garment-contract validation, mIoU drops to 0.7128, while the degradation rate increases from to , indicating its role in mitigating harmful updates. These findings demonstrate the complementary contributions of error attribution, selective optimization, and constraint validation. Additional validation statistics are provided in Appendix C (Table 8).
4.6 Qualitative Comparison
Qualitative results demonstrate the effectiveness of GarmentSegAgent under target ambiguity, occlusion, ambiguous boundaries, and multiple garments. As shown in Fig. 4, GarmentSegAgent better preserves target garment regions while reducing leakage into adjacent clothing and backgrounds. In contrast, competing methods often omit garment parts or include unrelated regions, highlighting the importance of accurate target localization and region exclusion.
Table 4: Ablation of CAST on DeepFashion2. DR: percentage of samples with decreased final IoU.
| Variant | mIoU↑ | BIoU↑ | DR (%)↓ |
|---|---|---|---|
| Full CAST | 0.8124 | 0.6318 | 6.4 |
| w/o VEA | 0.7128 | 0.4924 | 14.0 |
| w/o Selective Routing | 0.7287 | 0.5121 | 14.0 |
| w/o Garment Validation | 0.7128 | 0.4917 | 18.0 |
5 Limitations
Our evaluation focuses on single-target upper-garment segmentation in Web fashion images. Extending GarmentSegAgent to broader garment categories and multi-instance scenarios remains unexplored. Moreover, CAST relies on visual feedback and candidate masks from frozen foundation models, while garment-constrained validation cannot guarantee pixel-level accuracy. Iterative refinement also introduces additional inference overhead. Future work will investigate broader garment understanding and more efficient refinement strategies.
6 Conclusion
We presented GarmentSegAgent, an autonomous framework for garment segmentation in heterogeneous Web fashion images. Its core mechanism, CAST, combines visual error attribution, selective textual optimization, and garment-constrained validation to iteratively improve segmentation without human-provided spatial prompts or fine-tuning. Experiments on DeepFashion2, ModaNet, and Fashionpedia demonstrate consistent improvements in region overlap and boundary accuracy over competitive baselines. These findings highlight the potential of error-guided textual optimization for coordinating frozen foundation models in visual tasks.
References
[1] Jun Bai, Ruilin Wang, and Yue Li. 2026. FedEHR-Agents: Federated Agentic Optimization for Automated EHR Modeling. arXiv preprint arXiv:2608.27856 (2026).
[2] Shuai Bai, Yuxuan Cai, Ruizhe Chen, Keqin Chen, et al. 2025. Qwen3-VL Technical Report. arXiv preprint arXiv:2511.21631 (2025).
[3] Shuai Bai, Keqin Chen, Xuejing Liu, Jialin Wang, et al. 2025. Qwen2.5-VL Technical Report. arXiv preprint arXiv:2502.13923 (2025).
[4] Rishi Bommasani, Drew A. Hudson, Ehsan Adeli, et al. 2021. On the Opportunities and Risks of Foundation Models. arXiv preprint arXiv:2108.07258 (2021).
[5] Bowen Cheng, Ross Girshick, Piotr Dollár, Alexander C. Berg, and Alexander Kirillov. 2021. Boundary IoU: Improving Object-Centric Image Segmentation Evaluation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 15334–15342. doi:10.1109/CVPR46437.2021.01508
[6] Dehong Gao, Linbo Jin, Ben Chen, Minghui Qiu, Peng Li, Yi Wei, Yi Hu, and Hao Wang. 2020. Fashionbert: Text and image matching with adaptive loss for cross-modal retrieval. In Proceedings of the 43rd International ACM SIGIR conference on research and development in information retrieval. 2251–2260.
[7] Yuying Ge, Ruimao Zhang, Xiaogang Wang, Xiaoou Tang, and Ping Luo. 2019. Deepfashion2: A versatile benchmark for detection, pose estimation, segmentation and re-identification of clothing images. In 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 5332–5340.
[8] Zhibin Gou, Zhihong Shao, Yeyun Gong, Yelong Shen, Yujiu Yang, Nan Duan, and Weizhu Chen. 2024. CRITIC: Large Language Models Can Self-Correct with Tool-Interactive Critiquing. In International Conference on Learning Representations.
[9] Xingqi He, Yujie Zhang, Shuyong Gao, Wenjie Li, Lingyi Hong, Mingxi Chen, Kaixun Jiang, Jiyuan Fu, and Wenqiang Zhang. [n.d.]. RSAgent: Learning to Reason and Act via Multi-Turn Tool Invocations for Text-Guided Segmentation. In Forty-third International Conference on Machine Learning.
[10] Menglin Jia, Mengyun Shi, Mikhail Sirotenko, Yin Cui, Claire Cardie, Bharath Hariharan, Hartwig Adam, and Serge Belongie. 2020. Fashionpedia: Ontology, segmentation, and an attribute localization dataset. In European conference on computer vision. Springer, 316–332.
[11] Haichao Jiang, Tianming Liang, Wei-Shi Zheng, and Jian-Fang Hu. 2026. Refer-Agent: A Collaborative Multi-Agent System with Reasoning and Reflection for Referring Video Object Segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). 39508–39517.
[12] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al. 2023. Segment anything. In 2023 IEEE/CVF international conference on computer vision (ICCV). IEEE, 3992–4003.
[13] Xin Lai, Zhuotao Tian, Yukang Chen, Yanwei Li, Yuhui Yuan, Shu Liu, and Jiaya Jia. 2024. Lisa: Reasoning segmentation via large language model. In 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 9579–9589.
[14] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C. Lawrence Zitnick. 2014. Microsoft COCO: Common Objects in Context. In Computer Vision – ECCV 2014. Lecture Notes in Computer Science, Vol. 8693. Springer, 740–755. doi:10.1007/978-3-319-10602-1_48
[15] Shilong Liu, Zhaoyang Zeng, Tianhe Ren, Feng Li, Hao Zhang, Jie Yang, Qing Jiang, Chunyuan Li, Jianwei Yang, Hang Su, et al. 2024. Grounding dino: Marrying dino with grounded pre-training for open-set object detection. In European conference on computer vision. Springer, 38–55.
[16] Yuqi Liu, Bohao Peng, Zhisheng Zhong, Zihao Yue, Fanbin Lu, Bei Yu, and Jiaya Jia. 2025. Seg-zero: Reasoning-chain guided segmentation via cognitive reinforcement. arXiv preprint arXiv:2503.06520 (2025).
[17] Aman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, Shashank Gupta, Bodhisattwa Prasad Majumder, Katherine Hermann, Sean Welleck, Amir Yazdanbakhsh, and Peter Clark. 2023. Self-Refine: Iterative Refinement with Self-Feedback. In Advances in Neural Information Processing Systems, Vol. 36.
[18] Fausto Milletari, Nassir Navab, and Seyed-Ahmad Ahmadi. 2016. V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation. In 2016 Fourth International Conference on 3D Vision (3DV). 565–571. doi:10.1109/3DV.2016.79
[19] Reid Pryzant, Dan Iter, Jerry Li, Yin Lee, Chenguang Zhu, and Michael Zeng. 2023. Automatic prompt optimization with “gradient descent” and beam search. In Proceedings of the 2023 conference on empirical methods in natural language processing. 7957–7968.
[20] Rui Qian, Xin Yin, and Dejing Dou. 2025. Reasoning to attend: Try to understand how< seg> token works. In 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 24722–24731.
[21] Nikhila Ravi, Valentin Gabeur, Yuan-Ting Hu, Ronghang Hu, Chaitanya Ryali, Tengyu Ma, Haitham Khedr, Roman Rädle, Chloe Rolland, Laura Gustafson, et al. 2025. Sam 2: Segment anything in images and videos. In International Conference on Learning Representations, Vol. 2025. 28085–28128.
[22] Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. 2023. Reflexion: Language Agents with Verbal Reinforcement Learning. In Advances in Neural Information Processing Systems, Vol. 36.
[23] Vanshika Vats, Ashwani Rathee, and James Davis. 2026. Guideline-consistent segmentation via multi-agent refinement. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 40. 9612–9620.
[24] Lei Wang, Chen Ma, Xueyang Feng, Zeyu Zhang, Hao Yang, Jingsen Zhang, Zhiyuan Chen, Jiakai Tang, Xu Chen, Yankai Lin, Wayne Xin Zhao, Zhewei Wei, and Ji-Rong Wen. 2024. A Survey on Large Language Model Based Autonomous Agents. Frontiers of Computer Science 18 (2024). Article 186345. doi:10.1007/s11704-024-40231-1
[25] Ruilin Wang, Bo-Hong Wang, Elizabeth Kourbatski, Jun Bai, Hegang Chen, Ziyang Song, Gilles Boire, Marie Hudson, and Yue Li. 2026. DoctorAgents: an agentic framework to iteratively refine AutoML pipeline for small clinical temporal data. arXiv preprint arXiv:2608.05375 (2026).
[26] Shilin Xu, Xiangtai Li, Jingbo Wang, Guangliang Cheng, Yunhai Tong, and Dacheng Tao. 2022. Fashionformer: A simple, effective and unified baseline for human fashion segmentation and recognition. In European Conference on Computer Vision. Springer, 545–563.
[27] Chengrun Yang, Xuezhi Wang, Yifeng Lu, Hanxiao Liu, Quoc V Le, Denny Zhou, and Xinyun Chen. 2024. Large language models as optimizers. In International Conference on Learning Representations, Vol. 2024. 12028–12068.
[28] Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R. Narasimhan, and Yuan Cao. 2023. ReAct: Synergizing Reasoning and Acting in Language Models. In International Conference on Learning Representations.
[29] Chongkai Yu, Ting Liu, Anqi Li, Xiaochao Qu, Chengjing Wu, Luoqi Liu, and Xiaolin Hu. 2025. SAM-REF: Introducing image-prompt synergy during interaction for detail enhancement in the Segment Anything Model. In 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 19356–19365.
[30] Mert Yuksekgonul, Federico Bianchi, Joseph Boen, Sheng Liu, Pan Lu, Zhi Huang, Carlos Guestrin, and James Zou. 2025. Optimizing generative AI by backpropagating language model feedback. Nature 639, 8055 (2025), 609–616.
[31] Shuili Zhang, Hongzhang Mu, Wenyuan Zhang, Duohe Ma, and Tingwen Liu. 2026. Beyond Patches: Superpixel Token-based Transformers for Attribute-Specific Fashion Retrieval. In Proceedings of the ACM Web Conference 2026. 6956–6964.
[32] Shuai Zheng, Fan Yang, M Hadi Kiapour, and Robinson Piramuthu. 2018. Modanet: A large-scale street fashion dataset with polygon annotations. In Proceedings of the 26th ACM international conference on Multimedia. 1670–1678.
[33] Muzhi Zhu, Yuzhuo Tian, Hao Chen, Chunluan Zhou, Qingpei Guo, Yang Liu, Ming Yang, and Chunhua Shen. 2025. Segagent: Exploring pixel understanding capabilities in mllms by imitating human annotator trajectories. In 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 3686–3696.
[34] Xueyan Zou, Jianwei Yang, Hao Zhang, Feng Li, Linjie Li, Jianfeng Wang, Lijuan Wang, Jianfeng Gao, and Yong Jae Lee. 2023. Segment everything everywhere all at once. Advances in neural information processing systems 36 (2023), 19769–19782.
A Target Selection and Evaluation Protocol
For images containing multiple eligible upper-body garments, we designate the visible instance with the largest garment area as the segmentation target. This selection criterion establishes a consistent target definition across evaluated methods, particularly in scenes containing overlapping or adjacent garments. Predicted masks are evaluated against the corresponding target-instance annotation rather than other visible garment instances. Importantly, ground-truth masks and instance annotations are not accessible to GarmentSegAgent during planning, segmentation, evaluation, or textual refinement. They are used exclusively for offline annotation.
matching and metric computation, ensuring that visual feedback remains independent of reference segmentation masks.
B Additional Experimental Results
Visualization of Iterative Refinement. To further illustrate the refinement process, Fig. 5 presents the evolution of garment segmentation across successive iterations. Starting from the initial prediction, GarmentSegAgent progressively improves garment coverage and boundary alignment, particularly around the sleeves and lower edges. This example provides a visual illustration of how feedback-driven textual refinement can correct localized segmentation errors without modifying foundation-model parameters.
Cross-domain Person Segmentation on COCO. We further evaluate the generalization of the agentic segmentation framework on COCO [14] person segmentation, which differs from garment extraction in both target semantics and image distribution. As shown in Table 5, the TextGrad-based GarmentSegAgent achieves an mIoU of 0.7138, outperforming SegZero by 1.68 percentage points. Improvements are also observed in Dice, Boundary IoU, and precision, while the highest recall of 0.9045 indicates stronger foreground coverage. Grounding DINO + SAM 2 achieves higher region and boundary accuracy, potentially benefiting from detector-guided localization of the predefined person category. In contrast, GarmentSegAgent relies on language-guided planning and general textual refinement, without task-specific adaptation for person segmentation.
Table 5: Cross-domain person segmentation on COCO. BIoU denotes Boundary IoU.
| Method | mIoU | Dice | BIoU | Prec. | Rec. |
|---|---|---|---|---|---|
| READ | 0.5820 | 0.6720 | 0.4660 | 0.6460 | 0.6800 |
| SEEM | 0.6110 | 0.6560 | 0.4990 | 0.6610 | 0.7860 |
| LISA | 0.6420 | 0.7140 | 0.5250 | 0.7060 | 0.8830 |
| SegZero | 0.6970 | 0.7520 | 0.5770 | 0.7610 | 0.8770 |
| Grounding DINO+SAM 2 | 0.7650 | 0.8210 | 0.6450 | 0.8320 | 0.8500 |
| GarmentSegAgent | 0.7138 | 0.7826 | 0.6049 | 0.8017 | 0.9045 |
Qualitative results in Fig. 6 further illustrate the cross-domain behavior of GarmentSegAgent under target ambiguity, occlusion, and ambiguous boundaries. Despite being developed for garment segmentation, GarmentSegAgent can identify and segment the target person across diverse scenes, preserving visible foreground regions while limiting interference from surrounding objects and individuals. These observations suggest that its language-guided planning and textual refinement can transfer beyond garment-specific segmentation tasks.
Performance across Fashion Image Sources. We further compare segmentation performance between shop and consumer images in DeepFashion2. As reported in Table 6, GarmentSegAgent with CAST consistently outperforms its conventional TextGrad counterpart and SegZero + SAM 2 across both domains. CAST improves mIoU over conventional TextGrad by 0.9 and 0.7 percentage points on shop and consumer images, respectively. All methods achieve lower accuracy on consumer images, indicating greater segmentation difficulty in this domain.
Table 6: Segmentation performance across shop and consumer images in DeepFashion2 (500 images per domain). GSA denotes GarmentSegAgent, and BIoU denotes Boundary IoU.
| Domain | Method | mIoU↑ | BIoU↑ |
|---|---|---|---|
| Shop | SegZero + SAM 2 | 0.808 | 0.625 |
| GSA (TextGrad) | 0.817 | 0.638 | |
| GSA (CAST) | 0.826 | 0.650 | |
| Consumer | SegZero + SAM 2 | 0.784 | 0.584 |
| GSA (TextGrad) | 0.792 | 0.599 | |
| GSA (CAST) | 0.799 | 0.614 |
C CAST Mechanism Analysis
Prompt Evolution Case Study. We examine the textual refinement process by tracing how CAST transforms visual segmentation feedback into targeted instruction updates. As illustrated in Table 7, the trace records the attributed visual error, selected instruction fields, textual gradient feedback, and instructions before and after optimization. We also examine whether unselected fields remain unchanged and how the proposed updates are handled by garment-contract validation. The corresponding IoU change is measured offline to assess the effect of refinement on segmentation quality.
Table 7: Condensed CAST refinement trace for Fashionpedia image 10324. Textual entries summarize the recorded feedback and updates; IoU is measured offline.
| Component | Refinement Trace |
|---|---|
| Visual Errors | Missing jacket regions (torso, sleeves, collar, and hem), with erroneous inclusion of hands, skin, and a fur collar. |
| Selected Fields | Coverage and exclusion. |
| Initial Instruction | Preserve visible garment fabric and exclude body parts, other garments, and background. |
| Textual Feedback | Re-examine incomplete jacket coverage and the inclusion of non-garment regions. |
| Updated Fields | Coverage: retain the visible torso, sleeves, cuffs, collar, and hem. Exclusion: remove body parts, accessories, unrelated garments, and background. |
| Preserved Rule | Select the eligible upper-body garment with the largest visible fabric area. |
| IoU (Before → After) | . |
Garment-Contract Validation. We further examine the outcomes of garment-contract validation across the three benchmarks. As reported in Table 8, 26.0–31.8% of proposed updates require repair, while no rollbacks are recorded. Independent assessment identifies residual constraint-violation rates of 0.2–0.8%, suggesting that validation substantially supports instruction consistency without ensuring perfect constraint compliance.
Input
Input, Ground Truth, and Mask
Ground Truth (GT)
Final Mask



Iteration 0
Agent Iterative Refinement
Iteration 1
Iteration 2
Iteration 3
Iteration 4





Arrows indicate the chronological sequence of agent iterations.
Figure 5: Visualization of iterative garment segmentation refinement. The top row presents the input image, ground truth (GT), and final prediction, while the bottom row shows the predicted masks across Iterations 0–4. GT is used only for offline comparison.
Case
Input
GT
SegZero
SAM2
Grounding
DINO
LISA
Ours
Target Ambiguity

Occlusion

Ambiguous Boundaries
Figure 6: Qualitative comparison of person segmentation on COCO under target ambiguity, occlusion, and ambiguous boundaries.
D Case Study of Iterative Prompt Evolution
We illustrate iterative instruction refinement using Fashionpedia image 18374, featuring a red-and-black plaid overshirt. The case covers five segmentation iterations, from initial garment localization to boundary refinement. As the original textual logs were not retained, the following prompts are illustrative reconstructions based on the available segmentation masks and CAST protocol, rather than verbatim execution records.
Prompt 0: Initial Garment Specification
Instruction: Identify and segment the complete red-and-black plaid overshirt, including its collar, sleeves, cuffs, and lower hem. Exclude exposed skin, trousers, surrounding objects, and background regions. Preserve the garment's identity and visible structure.
Table 8: Garment-contract validation outcomes. Direct, Repair, and Rollback denote the final handling of proposed updates; Viol. denotes independently assessed constraint violations.
| Dataset | Updates | Direct (%) | Repair (%) | Rollback (%) | Viol. (%) |
|---|---|---|---|---|---|
| DeepFashion2 | 650 | 74.0 | 26.0 | 0.0 | 0.2 |
| ModaNet | 640 | 71.9 | 28.1 | 0.0 | 0.3 |
| Fashionpedia | 530 | 68.2 | 31.8 | 0.0 | 0.8 |
Prompt 1: Background Exclusion
Feedback: Background leakage and fragmented garment regions in the initial prediction.
Selected fields: Localization, Coverage, Exclusion.
Update: Focus on the connected plaid fabric regions forming the overshirt. Recover missing garment areas while excluding unrelated background pixels. Preserve the collar, sleeves, and lower hem without changing the target garment.
Prompt 2: Contour Refinement
Feedback: Residual background leakage and overly broad spatial localization near garment edges.
Selected fields: Localization, Exclusion.
Update: Tighten the upper and right garment boundaries to follow the visible fabric contours. Exclude adjacent skin and tree background regions while preserving the natural sleeve–torso gap and previously identified garment structures.
Prompt 3: Local Region Recovery
Feedback: Missing regions near the cuff and lower-right hem, with residual leakage along the left sleeve.
Selected fields: Localization, Coverage, Exclusion.
Update: Recover omitted plaid fabric near the cuff and lower hem. Refine the left sleeve contour to suppress surrounding background while preserving thin garment regions and natural boundaries. Avoid unnecessary expansion into adjacent areas.
Prompt 4: Final Boundary Refinement
Feedback: Minor residual background near garment boundaries, with most visible regions recovered.
Selected fields: Localization, Exclusion.
Update: Apply localized corrections to remove remaining background leakage. Maintain alignment with the visible plaid fabric while preserving the collar, sleeve contours, cuffs, and lower hem. Avoid altering correctly segmented garment regions.
Analysis. This illustrative sequence demonstrates how different visual errors can activate distinct instruction fields during iterative refinement. Early updates address background leakage and incomplete garment coverage, while later refinements focus on localized boundaries and residual errors. Throughout the sequence, the target instruction remains unchanged, whereas localization, coverage, and exclusion are selectively revised according to the attributed errors. Garment-contract validation checks candidate instructions for task consistency before subsequent execution. Although the reconstructed prompts are not verified execution logs, they illustrate the intended interaction between visual error attribution, selective TextGrad, and constrained instruction updates.
E Theoretical Analysis of CAST
We analyze two structural properties of CAST: the locality of selective textual updates and the preservation of garment-specific constraints.
Selective Update Locality. Let denote the structured instruction at iteration , where corresponds to the target, localization, coverage, and exclusion fields. Given the error-attributed active set , CAST generates a candidate update as
The final instruction is obtained through .
PROPOSITION 1 (UPDATE LOCALITY). Suppose the garment-constrained update operator preserves all inactive fields, including during validation and repair. Then
and the number of modified instruction fields satisfies
PROOF. By construction, selective TextGrad leaves every inactive field unchanged. The assumed field-preserving validation operator does not modify these fields. Consequently, only fields belonging to can change, establishing the bound.
Garment-Contract Feasibility. Let denote the set of instructions satisfying the garment contract . CAST validates each candidate instruction and accepts a direct or repaired update only when it passes the contract check; otherwise, it restores the previous instruction.
PROPOSITION 2 (CONSTRAINT PRESERVATION). Assume (i) , (ii) the contract validator is sound, such that every accepted instruction belongs to , and (iii) unsuccessful updates are rolled back to . Then
PROOF. The claim holds at by assumption. Suppose . If the candidate or its repaired version passes sound validation, the accepted instruction belongs to . Otherwise, rollback gives . The result follows by induction.
Scope of the Guarantees. These propositions characterize instruction-level properties rather than segmentation accuracy. Selective updates restrict which textual variables may change, but do not bound the resulting mask variation. Similarly, contract preservation does not guarantee that a revised instruction improves IoU. In practice, language-model-based validation may also be imperfect, making the feasibility guarantee conditional on validator soundness. We therefore complement these properties with empirical analyses of refinement gains, degradation rates, and validation outcomes.