An automated system for electrical power symbol placement in electrical plan drawing

An electrical plan drawing–sometimes called a wiring diagram or electrical drawing–consists of lines and symbols. Electrical plan drawings are prepared on 2D architectural floor plans using Computer-Aided Design and/or Drafting (CAD) programs. The placement/drawing of electrical power symbols–such as sockets, lights, and switches–is the first step of an electrical plan drawing. For this purpose, a smart system has been developed in this study to automatically draw/place electrical power symbols in appropriate locations. The system is based on the detection and classification/recognition of furnishing (decorative) symbols in the floor plans. We have created a furnishing symbol dataset drawing on dozens of architectural plan drawings that contain symbols of the most commonly used tools in floor plans, such as furniture, appliances, plumbing, doors, and windows. We used a Deep Convolutional Neural Network (D-CNN) with transfer learning–Inception-v3 model– to classify furnishing symbols. We tested the model on 20 real floor plans and achieved a very satisfactory accuracy of 97.05% in furnishing symbol classification. The symbol drawing step, which is the first step of drawing the electrical plan, was automated using the work developed, thus achieving the aim of saving time and labour. Experimental studies show the effectiveness of the proposed automated system.

as sockets, lights, and switches, while drawing electrical plans for residential buildings. A Deep Convolutional Neural Network (D-CNN) with transfer learning was used for the classification/recognition of furnishing symbols. We have created a suggestion system for placing electrical power symbols corresponding to the furnishing symbols after classifying furnishings, based on expert experiences. As a result, an automated system was developed to place the electrical power symbols on electrical plan drawings.
The paper is organized as follows: Section 2 provides general information about CAD, architectural floor plans, and furnishing symbols. Related work is summarized in Section 3. Section 4 presents dataset preparation, the proposed D-CNN model for the classification of furnishing symbols, and experimental results. Section 5 describes the automated placement of appropriate electrical power symbols in accordance with the classified furnishing symbols. Finally, in Section 6, we give the conclusion and future work.

CAD and floor plans
CAD and its applications are the most popular topics in design-related fields such as engineering and architecture. The foundations of CAD date back to the late 1950s and early 1960s [3]. In today's construction sector, many CAD programs, either 2D or 3D, are used for engineering and architecture services. AutoCAD, Revit, Archicad, SolidWorks, SketchUp, and StaCad are the most popular. CAD systems are used to increase the designer's productivity, improve the quality of the design, improve communications through documentation, and create a database for manufacturing [4].
Files in CAD programs are in a vector format. In this format, drawing objects consist of mathematical expressions. For example, a line segment consists of two points, while an arc consists of a central point, a starting angle, and a sweep angle. The vector file format includes basic geometric shapes such as lines, arcs, circles, ellipses, polygons, and blocks that can be used by grouping them in accordance with one's needs. Moreover, these geometric objects have various formatting properties, such as layer, colour, line-type, line-weight, etc. Layer usage is one of the most important factors of a CAD program. Architectural drawings are usually made in layers, which are similar to overlapping sketches.

Furnishing symbols
Furnishing symbols are drawn as blocks in vectorial drawing environments. A block is a collection of objects that is combined into a single object. The use of blocks is another important factor in CAD programs. In vectorial drawing environments, objects are combined so that multiple geometric objects can be reused in different places. Architectural plan designers store repeating objects in different plans in a library created in block form. Thus, they reuse these blocks in any plans without redrawing them.
Although furnishing blocks differ according to architect and architecture, they are usually prepared in the form of a top-down view of the material they represent. Figure 2 illustrates some sample furnishing symbols.
Hundreds of different symbols can be adopted for each class of furnishing used by architects. These  symbols are usually specific to an architect and culture. Figure 3 shows ten different stove-oven symbols.

Related work
Architectural drawings are made in the form of floor plans. Floor plans include walls, rooms, doors, windows, and other decorative symbols. Many studies have been conducted analyzing architectural floor plans. These studies mostly aimed to obtain 3D building models from 2D architectural floor plans based on a pattern recognition approach [5][6][7][8].
Ah-Soon and Tombre [9] presented a study to find door and window symbols in scanned architectural floor plans using computer vision and pattern recognition techniques. Dosch et al. [10] described a complete system for symbol recognition on architectural floor plans to reconstruct 3D buildings by using computer vision tools such as segmentation, vectorization, and feature detection. Guo et al. [11] used an exampledriven symbol recognition approach to analyze symbols from engineering drawings in their work. This study can be applied to many fields. The study has been tested in architectural floor plans and decorative symbols have been successfully recognized. Heras et al. [12] presented a database of scanned real floor plans (CVC-FP) and the ground-truthing tool (SGT tool) to generate its structural ground-truth (GT). They also present a benchmark on wall segmentation and room detection tasks in their paper.
There are many research on isolated symbol recognition. However, it was not observed the same for symbol recognition in context. Most symbol spotting techniques work on scanned floor plans. Rezvanifar et al. [13] offered a wide literature survey on symbol spotting (not recognition) in architectural drawing images.
Symbol spotting refers to the retrieval of graphical symbols embedded in larger images or documents. Additionally, Rezvanifar et al. [14] propose a deep learning based framework for symbol spotting on architectural floor plans.
Although there are a few other datasets for floor plans in the literature, these also consist of rasterized images. GREC'2003 [15], GREC'2011 [16], and SESYD [17] datasets contain either scanned or synthetic architectural and electrical documents for symbol spotting, recognition, and retrieval. The FPLAN-POLY [18] dataset contains 42 real floor plans vectorized from scanned images.
To the best of our knowledge, there is only one study about the automatic generating of electrical plans from architectural data. The paper proposes a procedural approach to automatically generate the residential electrical plans by using a stack-based finite state machine model [19]. This system receives 2D architectural data such as wall location as input and yields a customized electrical plan as output.
In practice, CAD applications (especially in the design-related industry) do not use rasterized floor plans, instead, they use vector plans. Therefore, none of these datasets are appropriate for our study. That's why we created our own dataset. In our study, we use vector (DXF/DWG) files as input to automatically draw the electrical power symbols. Additionally, the generated output is also in vector format.

Furnishing symbols classification
Furnishing symbol classification is the backbone of this paper, because all other processes in this study are carried out based on the recognition of furnishing symbols. Furnishing symbol classification is an image classification problem, or a computer vision problem that takes an image as input and categorizes it into a prescribed class. In the past, many classification approaches, such as artificial neural networks, expert systems, and fuzzy sets, have been widely used for this task. However, accuracy values for each are comparatively lower than for deep learning [20]. Deep learning is currently the best solution for image classification.
Unlike traditional machine learning and image processing techniques, deep learning carries out the learning process using raw data. Deep learning obtains the necessary features using representation learning carried out over different layers. Representation learning includes a group of methods allowing models to be supplied with raw data (such as the pixel values of an image) and automatically explore representations for detection or classification [21]. DNNs have been reached humanequivalent accuracy in image classification and object detection [22].
Classical machine learning techniques use manually extracted features for classification, although CNNs use features automatically extracted from raw images via convolutional and pooling layers. For learning, automatically extracted features strongly depend on the training dataset size. If the amount of training data is not large enough, this may lead to overfitting. To avoid this, deep CNNs with transfer learning are used [23].

Transfer learning
Transfer learning (TL) is an approach that aims to apply the knowledge gained from one task to another, similar task during the machine learning process.
The most common problem in CNNs is that researchers usually cannot find enough data to create a large dataset. Transfer learning is often used when collecting training data would be expensive or difficult [24]. It also helps save time and achieve better performance with less training time. Training a deep CNN model from zero requires large amounts of both labelled data and computing resources. However, a pretrained CNN model with transfer learning allows a short-cut in the training process. Experiments show that transfer learning gives better accuracy on CNNs than random weight distribution [25]. Figure 4 shows the transfer learning approach.
There are three type of transfer learning based on the availability and the amount of labelled data in the source and target domains: inductive, transductive, and unsupervised transfer learning [26]. We used inductive transfer learning in this paper. In inductive transfer learning, a model developed for the source task is used as a starting point for the target task. For example, using the information of a model to classify cats and dogs for vehicle classification.
To transfer the parameters of a CNN, first, the network is trained on the source task with a large amount of labelled data, such as that in ImageNet. Then, the convolution and pooling layers are frozen for new tasks. The last fully connected layer and the classifier are removed. To use this pre-trained model for new tasks, one or more new fully connected layers (adaptation layers) and a new classifier that matches the target dataset are added. Finally, the network is trained to update the weights of new fully connected layers.
The ImageNet is a large image database (over 14 million labelled high-resolution images belonging to approximately 22,000 categories) designed for object detection and classification research [27].
Nowadays, transfer learning is used to classify images in many areas. In particular, learning gained from the ImageNet dataset is commonly used. Many advanced pre-trained models, such as Inception-v3 [28], ResNet [29,30], MobileNet [31], and their improved versions, are available for researchers on different platforms.

Dataset preparation
To create a dataset, 1020 furnishing symbol blocks for 23 classes were collected from dozens of real-world architectural floor plan drawings. The class names are given in Table 2. These symbols were then saved in a DXF file to be used and/or expanded publicly by researchers. A DXF (drawing interchange or exchange format) file is an either binary or text-based representation of a drawing file used to interchange drawing data between CAD programs. The DXF format specifications are determined by the company Autodesk [32].
Since the symbols in the CAD files are in vector format, they were converted to image format at certain resolutions to be used in a CNN. To investigate which resolution would give better results, it was necessary to try different resolution scenarios. Enlarging or shrinking scales in vector data does not change the thickness of edge lines, but it is not possible to say the same for bitmap images. When scale changes in a bitmap image, the image thickens or refines at the edges. Indeed, if the bitmap image is overly minimized, some lines of 1-pixel thickness may then be lost in the minimized image. To prevent this, furnishing symbol blocks were brought to the desired scales in vector format and then converted into bitmap images. To do this, we created an application to convert DXF blocks into bitmap images automatically based on specified parameters such as size, rotation angle, line-weight, line-type, line-colour, and background-colour.
While geometric shapes can be similar for any furnishing symbol, architects may create their own style using line-colour, line-weight, or line-type. To facilitate the work of the neural network, only geometrical furnishing shapes were used, with a standard colour and a standard line-weight. Thus, regardless of which colour or line thickness was used for furnishing, the system automatically applied white for line-colour and only one pixel for line-weight; in this way, each furnishing symbol was converted to the bitmap image.
In deep learning, large datasets are important for success, although they increase the cost of computation and resources. Not only the size of the dataset but also the diversity of data is important for success. In some cases, if a dataset is not large enough, data should be increased through data augmentation methods. A dataset can be increased by resizing, rotating, mirroring, or applying distortions [33][34][35].
The 1020 collected symbols were increased to 24480 symbols using data augmentation. To do this, first, each block symbol was converted into three separate images with resolutions of 112 × 112, 224 × 224 and 299 × 299 pixels. Then, each image was transformed into eight other images by rotation and mirroring. In addition to the original image, 90 • , 180 • , and 270 • angles were used to perform mirroring and rotation. This was also an advantage for the prepared system, because furnishing symbols may be placed on the floor plan drawing at different angles. The dataset is renamed FDS, short for "Furnishing Dataset". Of this dataset, 25% was reserved for later use in the testing process.

Proposed method for furnishing symbols classification
Since we do not have a large dataset, we used a pretrained Inception-v3 model with transfer learning to perform classification. Inception-v3 is the third version of GoogLeNet, a CNN based on the Inception architecture [28]. In this study, transfer learning transfers the knowledge gained from the ImageNet classification to the furnishing symbol classification. The proposed model is shown in Figure 5.
We used the Microsoft ML.NET Image Classification API to create a classifier for FDS. The Image Classification API uses TensorFlow, an open-source machine learning platform. During the training process, the reserved training dataset was split 80:20 into training and validation sets, respectively. The mini-batch size was set to 10, and the learning rate was set to 0.01. Thus the training was completed at 32 epochs.   Table 1 shows the final accuracy and loss values for the training and validation sets. Figure 6 show the accuracy and loss values per epoch for the training and validation sets. The confusion matrix for the test data is given in Figure 7. The confusion matrix shows that the furnishing symbols are well separated from each other.

Experimental results on classification
The number of block symbols in each class is not equal. Since the data is imbalanced, it is more appropriate to use the F1-score than accuracy. The F1-score is a common criterion used to rate the success of a classifier. To calculate the F1-score, we first need to calculate precision and recall values. Precision is the ratio of true positives (TP) as opposed to false positives (FP) and recall is the ratio of true positives as compared to false negatives (FN). The mathematical representation of precision and recall are shown in Equations (1) and (2), respectively. The F1-score is the harmonic mean of precision and recall, as shown in Equation (3).

Recall = TP TP + FN
(2) Unlike binary classification, in multi-class classification, the F1-score is calculated separately for each class. The calculated F1-scores for each class are given in the last column of Table 2. The F1-macro-score is computed using the arithmetic mean of each class's F1-scores, as shown in Equation (4) [36]. Thus, the F1-macro-score was computed as 0.9859.
We tested the model on 20 real floor plans. A total of 2139 block symbols (furnishing blocks) were detected in these floor plans. These block symbols are originally in vector format, and so must be converted into bitmap images in order to use them in the model. We created three separate bitmaps with different resolutions (112 × 112, 224 × 224 and 299 × 299) for each block. All conversions are automatically made by our application. In this way, we forwarded separately three images for each block to the created model. If the prediction for at least two of the three images was the same, it was considered the model's prediction. This also allowed us to conduct a triple check. Table 3 shows the number of symbols detected and the accuracy rate of the classification on each floor plan. As seen in the table, the proposed model achieved 97.05% accuracy on real floor plans when classifying furnishing symbols.

Automated electrical power symbol placement system
To draw an electrical plan, we place the electrical power symbols automatically according to the algorithm given in Algorithm 1. Each step of this algorithm is explained in the following subSections.

Room polygon selection
Room zones on the floor plans are considered as polygons. A polygon can be created by selecting a few points or by specifying a rectangle (with two corner points). In the plan drawings, most rooms are rectangular. Zones in rectangular form can be actively detected within a locale with the help of the interSection of the wall lines closest to the left-right-top-bottom position of the cursor. Figure 8) shows how to automatically select a zone in rectangular form. Also, a rectangular zone can easily be selected by clicking two corner points (e.g. top-left and bottom-right) on the floor plan, as shown in Figure 8). If the region to be selected is not rectangular, for example, is an L-shaped room, then the boundary points of the zone can be selected with the help of individual clicks.

Detection of furnishing symbols inside a polygon area
In the present work, we need not only object classification but also object position. The aim of generic object detection is to locate and classify existing objects in an image and label them with bounding boxes [37]. If the floor plans in our study consist of raster images, then we would have to first detect the furnishing symbols by using object detection algorithms such as Faster R-CNN [38] or YOLO [39]. There are geometrical data in vector files consisting of coordinates, angles, and similar information. The objects in the vector files are visualized at run-time by the application program. Because the floor plans in our study are in vector format, we do not need to use classic object detection algorithms. All block symbols are already in a list in vector drawings. In addition, we can already calculate the boundaries of these block objects thanks to the geometric data in the file.
All graphical objects with known coordinates inside a closed polygon were determined according to their positions, and then the blocks were grouped into a list. All block objects in the floor plan drawing were considered as potential furnishing symbols. Thus, furnishing symbols from a selected area were determined according to their positions.

Recognition of furnishing symbols
Once a zone (room) was selected and block objects in the selected zone were listed, each block in this list was treated as a furnishing symbol. These blocks were converted into individual bitmaps by ignoring the original line weights/types/colours. Then, each bitmap image was forwarded to the trained CNN model to recognize the furnishing symbols. Figure 9 shows furnishing symbol detection and recognition in the selected zone.

The suggestion of electrical power symbols based on furnishing symbols
A Look-up table, given in Table 4, was created to place electrical power symbols when drawing an electrical plan using the experience of project designers. This table can be customized according to country and/or region.
Although the washing machine, dishwasher, and oven sockets are treated as normal socket material, the power drawn from them is in fact greater than for normal sockets: 300-500 watts for normal sockets, 1500-2500 watts for these sockets. Since the power used by these sockets will be high, each is designed as a separate circuit in the electrical plan drawing and a separate circuit breaker is planned for each. Therefore, these sockets have different symbols in electrical plan drawings.

Placing electrical power symbols
When drafting an electrical plan drawing using a CAD program, the placement of the electrical power symbols in the right place is the first step. The electrical power symbols to be placed are selected from Table 4 after the furnishing symbols are recognized. Some electrical Algorithm 1: Automatic electrical power symbols placement system Input: Architectural floor plan with furnishing symbols. Output: Architectural floor plan with electrical power symbols placed. foreach room in floor plan do Create the polygon that will enclose the room zone. (room-polygon). List all cad-block-object(s) within the polygon with their locations. Note: we know all the furnishing symbols are in block form, so each block will be considered as a furnishing symbol. foreach cad-block-object in room-polygon do Convert the block object to three bitmap images with the specified resolutions (112 × 112, 224 × 224 and 299 × 299) and properties (line-weight: 1px, line-colour: white, line-type: continuous) for the network. Recognize the furnishing symbols in the converted images by inputting them into the trained network. Determine the electrical power symbols for the recognized furnishing symbols using Table 4. Place the determined electrical power symbol(s) near the wall line where the furnishing symbol is. end end power symbols are shown in Figure 10. These symbols are used as blocks in CAD drawings.
It is necessary to detect the most suitable wall line for the electrical power symbol after recognizing the furnishing symbol. The selected electrical power symbol is placed on the wall line nearest to the geometric position where the furnishing symbol is recognized. To detect the nearest wall line and place the electrical power symbol appropriately, the following procedures are performed, in the given order [2]: • Select the nearest line segment (wall line) to the central point (cp) of the identified furnishing symbol. This line segment will be considered the reference line (refLine).
• Draw a perpendicular line (perpLine) to the refLine from the cp and find the interSection point (intPt). • The angle of perpLine is considered the rotation angle (rotAng) for the electrical power symbol. • A specified distance (delta) along the perpLine from the intPt becomes the insertion point (ToolPt) for the electrical power symbol.
The placement of the electrical power symbols on the appropriate line segments (walls) according to the steps above is shown in Figure 11.
As seen in Figure 12, the electrical power symbols matching the furnishing symbols found were selected and placed on the appropriate walls. The light symbol was selected according to the study in [40] and placed  in the appropriate place. The readers can refer to [40] for detailed information about selecting and placing appropriate luminaires according to the specified zone (room), based on lighting calculations.

Conclusions and future work
This paper carries out a study to intelligently draw electrical power symbols in appropriate places, depending on furnishing symbols, in order to automatically draw  electrical plans. To the best of our knowledge, deep CNN and transfer learning are used for the first time in electrical plan drawing to automatically place electrical power symbols. With this study, a new vision has been presented for the automatic placement of electrical power symbols based on the recognition of furnishing symbols. After recognizing furnishing symbols, algorithms were developed and successfully applied to Table 5. The steps of "the automated electrical power symbols placement for electrical plan drawing".
Step-1 • Rectangular zones can be selected automatically by clicking inside an area with the help of cursor crosshair reference lines (see Figure 8)). • Selection of a zone (room) is carried out by clicking two corner points (see Figure 8)). • Any polygonal room can be selected by individual clicks on the corner points of the zone. • A polygon is created that determines the boundaries of the zone (room-polygon).
Step-2 • All block objects inside the room-polygon are listed.
* Seven blocks are listed in the left-hand figure. • Each block will be considered a furnishing symbol. • Convert each block to three bitmap images with the specified resolutions (112 × 112, 224 × 224 and 299 × 299) and properties (line thickness: 1 pixel, line colour: white, line type: continuous) for the CNN model. • Forward each converted image to the trained CNN model to classify/recognize the "furnishing symbols". * If the prediction for at least two of three images is the same, then it will be considered as the prediction of the model.
Step-3 • Determine the electrical power symbols for the recognized furnishing symbols using Table 4.
• Place the identified electrical power symbols on the nearest wall line where the furnishing symbol is.
• Place the lighting fixture in the centre of the selected area. * The type, number, and position of the selected lighting fixture are determined according to [40]. automatically place electrical power symbols in appropriate locations. The steps of the study are summarized in Table 5.
The proposed system works on vector-based realworld residential architectural floor plans. The furnishing (decorative) symbols should be in block forms. The furnishing symbols used in this study were selected only from among the those most commonly used for residential buildings.
Furnishing symbol classification is basically an image classification problem. From past to present, much work has been done to classify images. Numerous different (new or pre-trained) CNN models (ResNet, MobileNet, VGG, etc.) with different fine-tuning can be tested to improve the success of classification for this objective.
The automated placement of the electrical power symbols successfully depends on the correct recognition of the furnishing symbols. Therefore, it can be said that the success of the proposed system is the same as the success of the classification. Since we created the dataset for the proposed system ourselves, it would not be appropriate to compare it with the previous symbol recognition studies. Yet the success rate of 97.05% is a very satisfactory result.
We used the Microsoft ML.NET Image Classification API in the .Net environment to create a classifier model for furnishing symbols. Satisfactory results were obtained according to the success of the proposed model. This study will stimulate the use of artificial intelligence in the field of electrical plan drawings.
The furnishing symbol dataset and test floor plans (in dxf, pdf and jpg formats) are publicly available at https://www.kaggle.com/bayramakgl/furnishing-data set.
A video from the implementation of this study is available for the electronic version of this paper as supplemental material.
We aim to draw a fully automatic electrical plan drawing. In the future, we would expect to parse floor plans for rooms automatically instead of selecting them manually. This will take us one step closer to fully automated electrical plan drawings. Room types can be identified according to the furnishing symbols inside. For example, if an oven symbol is recognized in a room zone, this means this zone is most likely a kitchen. In our previous work [40], we created a lighting simulation program that makes recommendations for the number of luminaires, types, and insertion points to be placed in a three-dimensional closed area to provide a predetermined minimum illumination level in accordance with the type, size, and purpose of use. By integrating this previous work into our current study, we will be able to automatically place the correct number and type of lighting fixtures in the automatically identified rooms.
Automating the drawing process in CAD applications involves obtaining engineering calculations from the drawing. Consequently, the next step of this study is to connect electrical power symbols to distribution panels automatically and to ensure that all calculations are done in the same manner.