# Developing a Robust Training Dataset for AI-Driven Architectural Spatial Layout Generation
## 3 Methodology
### YOLO-Based Spatial Relationship Diagram Extraction Method  
The convolutional neural network (CNN) and YOLO [24; 25] are pivotal object detection models. Although object detection requires the ability to identify and categorize multiple entities, CNN models encounter challenges when recognizing numerous objects. As floorplan images contain a variety of diminutive and intricate elements of varying sizes and positions, the YOLO model was adopted in this study. This decision stems from YOLO's proficiency in rapidly detecting multiple classes within raster-based floor plan images. Unlike Fast R-CNN, which requires two stages, specifically region proposal and classification, YOLO models are single-stage detectors. This means that YOLO can predict bounding boxes and class probabilities directly from full images in one evaluation, making it faster and more suitable for real-time applications. YOLOv3, in particular, predicts the objectness score for each bounding box using logistic regression. YOLOv3's architecture divides the input image into a grid and predicts bounding boxes and confidence scores for objects within each grid cell. This offers significant advantages in terms of both speed and accuracy, especially when detecting smaller objects compared to other models like Faster R-CNN. In terms of operational efficiency, YOLOv3 outperforms both Faster R-CNN and Retinanet and its ability to detect smaller objects has been enhanced using scales [25].  
Table 3 presents the extraction process of the spatial relationship diagram from YOLOv3-based floor plan images. When an image was input, the space and central classes were detected using the YOLO model. A center point is detected and each point (referring to a node) is connected based on previously defined adjacency conditions (i.e., a completely open space, a partially open space, or an indirectly connected space). This is discussed in detail in Section 3.3. Table 4 shows how the lines were connected according to the adjacency definition.  
Table 5 lists the successful encapsulation methods used in the extraction process. It is divided into a step for detecting classes using the YOLO model and a step for drawing a diagram, such as a graph, through calculation. The dimensions of the graph images were determined after data calculation. If the outer coordinates of the detected space class are represented by X and Y, their cumulative lengths are incorporated and averaged to obtain a square. As the space classes are discerned through bounding boxes, overlaps may  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Step 1. Image input** & **Step 2. Class detection** & **Step 3. Center point** \\  & **using YOLO model** & **calculated from bounding box** \\ \hline \hline
**Step 4. Connection by definition of adjacency** & **Step 5. Spatial relationship diagram extraction** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Extraction process of the spatial relationship diagram.  
The intricacies and procedures within 'Connectalgorithm.cs' are exhibited in Figure 4. Within housing plans, living rooms predominantly occupy the most extensive area. Consequently, directly adjacent spaces like hallmarks, kitchens, and foyers are the primary connections. Rooms with a solitary door are connected accordingly. In instances where a room contains multiple doors, all neighboring rooms are interconnected. As space is detected as a bounding box, the closet is mostly included in the bedroom. The porch space is connected and the hallways may overlap due to bounding boxes, so they are merged. The 'Connectorithm.cs' function yields 'Connection Information' as its output. The contents described in Chapter 3.4 are in 'Drawimages.cs'. The conclusive diagrammatic image is presented to the user after calibrating parameters like pixels, resolution, and dimensions.