Abstract
We present a deep neural network to predict structural similarity between 2D layouts by leveraging Graph Matching Networks (GMN). Our network, coined LayoutGMN, learns the layout metric via neural graph matching, using an attention-based GMN designed under a triplet network setting. To train our network, we utilize weak labels obtained by pixel-wise Intersection-over-Union (IoUs) to define the triplet loss. Importantly, LayoutGMN is built with a structural bias which can effectively compensate for the lack of structure awareness in IoUs. We demonstrate this on two prominent forms of layouts, viz., floorplans and UI designs, via retrieval experiments on large-scale datasets. In particular, retrieval results by our network better match human judgement of structural layout similarity compared to both IoUs and other baselines including a state-of-the-art method based on graph neural networks and image convolution. In addition, LayoutGMN is the first deep model to offer both metric learning of structural layout similarity and structural matching between layout elements.
Introduction: Beyond Pixel-Level Matching
Determining the similarity between 2D layouts, such as architectural floorplans or mobile user interface (UI) designs, is a fundamental challenge in design automation and retrieval. Traditionally, computer vision has relied on Intersection-over-Union (IoU), a metric that measures the pixel-level overlap between two stacked images. However, IoU is fundamentally "structure-blind." A minor spatial shift of a room can drastically lower its IoU score even if the functional layout remains identical. Conversely, two layouts might overlap significantly in pixel space while having entirely different structural "flows" or functional arrangements.
Layout similarity is a matter of inference and reasoning about spatial relationships and semantic arrangements, not just visual matching. There is a critical need for a metric that understands structural features—such as "a kitchen adjacent to a living room"—regardless of exact pixel coordinates.
Methods: Layouts as Graphs
The core innovation of LayoutGMN is shifting the representation of layouts from pixel grids to topological graphs. This allows the model to focus on the relationships between elements rather than their absolute positions.
1. Layout Representation
Each layout is converted into a directed, fully connected graph $G$.
- Nodes: Represent semantic elements (e.g., a "bedroom" in a floorplan or a "button" in a UI). Node features include the element's semantic class and geometric properties like coordinates and area.
- Edges: Capture the spatial relationships between every pair of elements, including relative distance, angle, and individual IoU.
2. Neural Graph Matching
Unlike standard Graph Convolutional Networks (GCNs) that process graphs in isolation, LayoutGMN employs a Graph Matching Network (GMN). This architecture incorporates a cross-graph attention mechanism, allowing nodes in one graph to "attend" to nodes in another during the embedding process. This interaction enables the network to learn correspondences between elements across different layouts, facilitating a more nuanced comparison of their global structures.
3. Weakly Supervised Training
To overcome the lack of large-scale human-labeled similarity datasets, the authors utilize a weakly supervised approach. The model is trained using a triplet loss (Anchor, Positive, Negative) where initial labels are generated by IoU. Despite being trained on these "noisy" pixel-based labels, the architectural design of LayoutGMN allows it to transcend them.
Key Insights: The Structural Bias
A significant finding of this research is the "structural bias" inherent in the graph-based architecture. Because the network is forced to process layouts as graphs of semantic elements and their relationships, it naturally learns to prioritize structural consistency over pixel-perfect alignment. This allows LayoutGMN to ignore the pixel-level misalignments that often mislead traditional IoU metrics.
Furthermore, the attention weights used for graph comparison can be extracted to perform element-level matching. This provides interpretability, allowing users to see exactly which components the model deems similar between two layouts.
Experimental Results
The model was evaluated on two large-scale datasets: RICO (mobile UI designs, ~66k layouts) and RPLAN (residential floorplans, ~77k layouts).
Alignment with Human Judgment
To validate the metric, the authors conducted human subject studies via Amazon Mechanical Turk (AMT). In retrieval tasks, LayoutGMN’s results were judged as "structurally relevant" by humans significantly more often than results from IoU or state-of-the-art GCN-CNN hybrid models.
Retrieval Performance
On UI layouts, LayoutGMN achieved a Precision@1 of 47.91%, outperforming the IoU metric (43.75%) and GCN-CNN baselines (39.6%). The model also demonstrated superior consistency in finding similar layouts across different query variations, as measured by a new "Overlap@k" score.
Limitations and Future Directions
While LayoutGMN represents a significant step forward, several areas for improvement remain:
- Supervision: The model still relies on IoU for initial training. Future work could explore active learning or few-shot learning with direct human feedback to further refine the metric.
- Hierarchy: Currently, layouts are treated as "flat" graphs. Incorporating hierarchical graph representations could better capture nested relationships, such as buttons within a form container.
- Scalability: Fully connected graphs can become computationally expensive for extremely complex layouts. Optimizing the graph structure for scalability is a key area for future research.
Summary updated