Abstract
Taming diffusion models for generative segmentation has attracted increasing attention. While existing approaches primarily focus on architectural tweaks or training heuristics, there remains a limited understanding of the intrinsic mismatch between continuous flow matching objectives and discrete perception tasks. In this work, we revisit diffusion segmentation from the perspective of vector field learning. We identify two key limitations of the commonly used flow matching objective: gradient vanishing and trajectory traversing, which result in slow convergence and poor class separation. To tackle these issues, we propose a principled vector field reshaping strategy that augments the learned velocity field with a detached distance-aware correction term. This correction introduces both attractive and repulsive interactions, enhancing gradient magnitudes near centroids while preserving the original diffusion training framework. Furthermore, we design a computationally efficient, quasi-random category encoding scheme inspired by Kronecker sequences, which integrates seamlessly with an end-to-end pixel neural field framework for pixel-level semantic alignment. Extensive experiments consistently demonstrate significant improvements over vanilla flow matching approaches, substantially narrowing the performance gap between generative segmentation and strong discriminative specialists.
The Optimization Mismatch in Generative Segmentation
Diffusion and Flow Matching (FM) models have revolutionized image generation, but applying them to semantic segmentation—where every pixel must be assigned a discrete category—remains a struggle. The core issue lies in an "optimization mismatch." Standard Flow Matching uses a Mean Squared Error (MSE) objective that treats segmentation like a simple regression task. This leads to two major failures:
- Gradient Vanishing: As a prediction gets closer to its target category "centroid" in continuous space, the training signal weakens and eventually disappears. This results in blurry boundaries and imprecise classifications.
- Trajectory Traversing: Because the model only learns to be "attracted" to the correct label and isn't "repelled" by incorrect ones, predicted paths often drift through the territory of competing classes, causing high-cardinality confusion (e.g., mistaking a "truck" for a "car" because their embeddings are nearby).
The FlowSeg Framework
To address these limitations, we propose FlowSeg, a framework built on three main pillars:
Vector Field Reshaping
This is the paper's primary innovation. Instead of a vanilla velocity field, we augment the ground-truth velocity with a discriminative rectification term. This term acts like a potential field: it provides a strong "push" toward the correct class and an explicit "repulsion" away from all other classes. Crucially, we use a "stop-gradient" operation on this correction term to ensure training remains stable within the existing Flow Matching framework.
As illustrated above, FlowSeg maintains a strong gradient magnitude even near the semantic centroid, unlike vanilla FM where the gradient vanishes. This ensures faster convergence and sharper class separation.
Quasi-Random Category Encoding
To map discrete labels (like "tree" or "sky") into a continuous 3D color space, we use Kronecker sequences. This is a deterministic, computationally cheap way to ensure that category centroids are spread as evenly as possible across the available space, maximizing the distance between different classes from the start.
End-to-End Pixel Neural Field
Rather than using a pre-trained VAE, which can lose fine-grained spatial details, FlowSeg uses a "pixel neural field" decoder. It treats each image patch as a continuous field where weights are dynamically generated by a Transformer backbone, allowing for high-precision, pixel-level alignment.
Experimental Results
We evaluated FlowSeg on two challenging, high-cardinality benchmarks: ADE20K (150 categories) and COCO-Stuff (171 labels). These datasets are particularly difficult for generative models because the high number of classes makes "trajectory traversing" much more likely.
Key Findings
- Closing the Gap: On ADE20K, FlowSeg achieved 47.1 mIoU, outperforming previous generative methods like PixWizard (32.8) and InstructDiffusion (33.6) by a massive margin. It even surpassed strong discriminative models like SegFormer (46.5).
- Efficiency: The model achieves peak performance with only 10 sampling steps, making it viable for practical use compared to older diffusion methods that required hundreds of iterations.
Qualitative results demonstrate FlowSeg's ability to produce clean, detailed segmentation masks that closely match the ground truth (GT), even in complex scenes with many small objects.
Conclusion
FlowSeg rethinks generative segmentation by addressing the fundamental mismatch between continuous diffusion flows and discrete semantic labels. By adding repulsive forces and preventing gradient vanishing, we bring the benefits of contrastive learning to flow-based generation. While generative segmentation still faces challenges in extremely high-resolution settings, FlowSeg significantly narrows the gap with discriminative specialists, paving the way for more robust generative perception models.
Summary updated