Chinese traditional dwelling type identification method, system, equipment and medium
Through a deep neural network-based method, combined with the YOLOv8x pre-trained weight model and the "Complete Collection of Traditional Chinese House Types", the rapid and accurate identification of traditional Chinese house types is achieved, and the problem of lack of rapid identification methods in the existing technology is solved, and the research on the distribution of traditional house types across the country is supported.
Patent Information
- Application Number
- CN202510056935.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-14
AI Technical Summary
The existing technology lacks a rapid identification method for the types of traditional houses in China, and does not use image data to detect traditional houses, making it difficult to realize the detection of traditional house types nationwide.
Using a deep neural network-based method, the YOLOv8x pre-training weight model training was trained, combined with the "Complete Collection of Traditional Chinese House Types" and expert opinions, the classification standards for traditional Chinese house types were formulated, and ground photos were used for training and identification.
It has achieved rapid and accurate identification of traditional Chinese house types, and can identify various traditional house building types nationwide, support research on the distribution of traditional house building types, and reduce human and material costs.
Smart Images

Figure CN119810567A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image-based building detection, and specifically relates to a method, system, electronic device and storable medium for identifying types of traditional Chinese dwellings based on a deep neural network. Background Art
[0002] There are a large number of traditional dwelling samples from different historical periods in my country. These samples are huge and widely distributed in rural areas across the country, resulting in a lack of overall quantitative statistics for professional surveys. It requires a lot of manpower, financial resources, time and energy, and it is difficult to quickly obtain the distribution characteristics of traditional dwelling types through field surveys. Existing studies often focus on the types and forms of traditional dwellings in a certain area. There are few systematic studies on traditional dwellings across the country, and there is a lack of comprehensive understanding of the existing types of traditional Chinese dwellings. In addition, there are rich and diverse types of traditional dwellings, and different types of residential buildings have commonalities and their own obvious characteristics, which leads to unclear standards for the classification of traditional dwelling types. The identification of traditional Chinese dwelling types across the country further increases the difficulty of identification. Therefore, it is necessary to establish a detection model that can easily and quickly identify the types of traditional Chinese dwellings.
[0003] The main problems with the current testing of traditional Chinese residential types: (1) No detection method for traditional residential building types has been proposed. Existing technologies focus on the identification of buildings, bridges, roads, green areas, etc. in remote sensing images, as well as the detection of urban construction and municipal pipeline safety. There is a lack of identification and detection of traditional residential building types in rural areas.
[0004] (2) No requirements were put forward for the traditional dwelling image dataset. Existing dwelling classification methods are mainly based on expert knowledge and personal experience, and lack the technology to detect the type of traditional dwellings using images.
[0005] (3) No detection method for traditional dwelling types across China has been proposed. Existing research methods for the distribution of dwelling types are mainly based on small-scale, case-specific areas, and lack detection technology for traditional dwelling type data across the country.
[0006] (4) No residential detection method based on ground photos has been proposed. Existing detection methods are mainly based on remote sensing images as basic data sets, which are difficult and time-consuming to obtain data. Summary of the invention
[0007] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and provide a method, system, electronic device and storable medium for identifying the types of traditional Chinese dwellings based on a deep neural network. The identification method first classifies traditional Chinese residential buildings based on the "Complete Collection of Traditional Chinese Dwelling Types" and combines expert opinions to formulate a classification standard for traditional Chinese dwelling types. Secondly, by controlling the parameters of the traditional dwelling types in the training set and the verification set, an optimized Chinese traditional dwelling type identification model is obtained based on the YOLOv8x pre-trained weight model training, and the traditional dwelling image to be detected is input into the Chinese traditional dwelling type identification model to obtain the identification result. This method can be used for the rapid and accurate detection of various types of traditional residential buildings throughout China, and the identification results can be used as a demonstration support for the study of the distribution of traditional residential building types.
[0008] In order to achieve the above object, the present invention adopts the following technical solutions: In the first aspect, the present invention provides a method for identifying the types of traditional Chinese dwellings based on a deep neural network. The method is based on the ground image features of the traditional dwelling types and takes the traditional dwelling types as the target, so as to realize the identification and recognition of the types of traditional dwellings in the whole area of China. The method for identifying the types of traditional Chinese dwellings comprises the following steps: S1. Constructing the standard of Chinese traditional dwelling types: Based on the Complete Collection of Chinese Traditional Dwelling Types published by China Architecture & Building Press in 2014 and public literature data, we sorted out the types of Chinese traditional dwellings and defined 23 types of Chinese traditional dwellings according to the standard of Chinese traditional dwelling types; S2. Obtaining images of various types of traditional Chinese dwellings: Obtaining images of various types of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; S3, preparing a training set and a validation set: in the residential type image set A, annotate the traditional residential images containing 23 target residential types, and divide them into a training set T and a validation set Y in a ratio of 9:1, wherein both the training set T and the validation set Y contain 23 residential types; S4. Training recognition model: Use the training set T produced in the previous step to train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain the Chinese traditional dwelling type recognition model build_reco_best.pt; S5. Obtain images of traditional Chinese dwellings: obtain images of traditional Chinese dwellings throughout China from a public image data website or collect images of traditional Chinese dwellings throughout China in real time to form an image set B to be identified; S6. Identify the types of traditional Chinese dwellings: input the dwelling pictures in the to-be-identified image set B into the traditional Chinese dwelling type identification model for identification, and obtain the type identification results of the images in the to-be-identified image set B by calculation.
[0009] Furthermore, in step S1, this method finds through combing existing historical data and documents that the classification of building types is closely related to factors such as the building's roof, structure, material, and decoration, while existing studies are mostly based on the classification of building types based on a specific factor, lacking a type recognition method for the overall appearance of the building. Therefore, this method combines the image features of the building facade and the results of previous classification studies to form 9 major categories of 23 types of traditional Chinese dwellings, that is, 9 major types of dwellings formed according to previous studies and 23 subcategories formed based on the subdivision of building appearance, and finally 23 target types are formed, which can achieve coverage of the main types of dwellings across China and enrich the research objects.
[0010] Specifically, the characteristics of the 9 major categories and 23 minor categories of residential types are as follows: (1) Single-family residential buildings The first type of residential type is single-family residential type. Its characteristics are: a type of building with relatively simple architectural form but different building materials, usually existing in the form of a single unit, recorded as DDL. Single-family residential type is further divided into three subcategories according to the architectural form image characteristics, namely thatched roof residential type, stone structure residential type and wooden structure residential type. The characteristics of thatched roof residential type are: the building roof material is seaweed, thatch and other grass materials, the image roof color is mainly brown, brown, showing straw and other grass texture, the roof outline is clear and occupies a large proportion of the building image area; the characteristics of stone structure residential type are: the building facade is the free stacking or flat alignment of stones, the building shape is mostly rectangular, the color is mainly the color of various stones themselves, and the roof form is mostly a sloping roof; the characteristics of wooden structure residential type are: round logs or square logs are stacked horizontally to form load-bearing walls, biting each other at the corners, the roof is a pure wooden structure house with a gable roof, double slope or herringbone shape, the image is mainly the color of logs, the building facade is mostly a texture made of stacked wood, the roof form is a sloping roof and the material is also wood. They are denoted as DDL_CDMJ, DDL_SGMJ, and DDL_MGMJ respectively; (2) Courtyard-style residence The second largest type of dwellings is courtyard-style dwellings. Its characteristics are: it is composed of rooms arranged in a linear layout to form various forms of courtyards, denoted as HYS. According to the characteristics of the architectural form image, the courtyard-style dwellings are divided into two subcategories, namely courtyard-style dwellings and hall-style dwellings. Among them, the characteristics of courtyard-style dwellings are: the buildings are mostly single houses forming square or rectangular courtyards, usually with gray or brick-red exterior walls, a more flexible layout, a larger courtyard, and the roof form is mostly sloping roofs. The characteristics of hall-style dwellings are: the buildings usually have a simple, geometric appearance, with central axis symmetry, and most of the architectural images have gray or khaki facades. The building shape is mostly rectangular, and the roof form is a sloping roof. They are denoted as TYS_HYSMJ and TYS_THSMJ respectively; (3) Fort-style dwellings The third type of residential type is the fortress-style residential type. Its characteristics are: the building usually consists of an outer enclosure and an inner core part, has a strong defensive function, and has a tall outer wall, which is recorded as WBS. According to the architectural image characteristics, the fortress-style residential type is divided into two subcategories, namely earthen buildings and walled buildings. Among them, the characteristics of earthen buildings are: large residential buildings with raw earth as the main building material, raw earth combined with wooden structures, and stone materials used to varying degrees. The image is mostly earthy yellow, the image is relatively integrated, the facade has array windows, the external shape of the building is simple, and there are often arcs and squares. The roof form is a sloping roof; the characteristics of the fortress-style residential type are: there are tall walls and houses around the building, and it is often surrounded by deep trenches and high walls. Towers and watchtowers are built at the four corners and the center. It is an important folk defensive building complex. The image is mostly grayish white and grayish brown. The facade is mostly regular brick and stone textures, without obvious internal space divisions. The overall building is tall and rectangular in shape. Some corner towers are high, and the roof form is mostly sloping roofs. They are denoted as WB_TL and WB_WL respectively; (4) Diaofang-style dwellings The fourth type of residential buildings is Diaofang-style residential buildings. Its characteristics are: the external structure of the building is built with stone walls or earth walls, mostly with flat roofs, narrow windows, and excellent defense capabilities, recorded as DFS. According to the architectural image characteristics, Diaofang-style residential buildings are divided into two subcategories, namely Diaofang and Diaolou. Among them, the characteristics of Diaolou residential buildings are: the images are mostly grayish white and grayish brown, the facades of the buildings are mostly brick and stone textures, there are many small holes, the height and width of the main building are relatively large, the buildings usually present simple and geometric appearance characteristics, clear lines, and the roof form is flat. The main difference from Diaofang residential buildings is that the floor height is higher; the characteristics of Diaofang residential buildings are: they are built with rubble or earth, the image colors are relatively rich, and the original colors of the materials are basically adopted: the khaki of the soil, the beige, cyan, and dark red of the stones, and the wood parts are painted dark red. The facades of the buildings are mostly brick and stone textures, the main building is relatively flat, the building shape is simple, the lines are clear, and the roof form is flat. Recorded as DF_DL and DF_DF respectively; (5) Cave dwellings The fifth type of dwellings is cave dwellings. Its characteristics are: the main building is built by digging horizontally or underground into the loess cliff, supported by an arched structure, and the main building materials used are soil, bricks and stones, recorded as YDS. According to the architectural form image characteristics, cave dwellings are divided into three subcategories, namely cliff caves, pit courtyards and cave caves. Among them, the characteristics of the cliff kiln are: it is built by digging a horizontal hole in the natural earth wall, the image color is mainly khaki, a few have brick and stone door frames, the door openings are mostly arc-shaped and arranged in an array, and the back is against the mountain; the characteristics of the pit courtyard dwellings are: it is built by digging a rectangular or square earth pit on the flat land, the image is usually khaki, the shape of the building courtyard is mostly rectangular, the door opening is arc-shaped, arranged in an array, with clear contour lines, the main body of the building is below the ground, and the roof of the building is on the ground; the characteristics of the imprisoned kiln are: it is built on the ground, the image is usually gray and khaki, the facade is a brick and stone texture, the main body of the building is mostly strip-shaped, the door openings are arc-shaped and arranged in an array, and the roof is flat. They are denoted as YDS_KYY, YDS_DKY, and YDS_GY respectively; (6) Felt tent-style dwellings The sixth type of dwellings is the felt-tent dwellings. Its characteristics are: it is a kind of detachable and movable residential building commonly used by Chinese nomadic peoples, including felt-house dwellings and account-house dwellings, which are distinguished by roof coverings and forms, and are denoted as ZZS. The felt-tent dwellings are further divided into four subcategories according to the architectural form image characteristics, namely account-house dwellings, yak tents, oblique pillar dwellings and felt-bag dwellings. Among them, the characteristics of the account-house-style dwellings are: they are mostly made of white cotton cloth, with colorful embroidery patterns on the surface of the tent, the architectural image is mainly white, with auxiliary blue and red decorations, the architectural outline is clear, the roof is a pointed roof, and it is integrated with the building facade; the characteristics of the yak tent are: it is a form of housing for plateau herdsmen who migrate with cattle and sheep and live with grass, the image is mainly black, the architectural outline is clear, the roof is a pointed roof, and it is integrated with the building facade; the characteristics of the oblique pillar dwellings are: wooden strips are used as the skeleton, covered with bark or animal skin, the images are mainly white and brown, the buildings are mostly independent, and the overall shape is conical; the characteristics of the felt house dwellings are: the lower part of the dwelling is cylindrical, the upper part is dome-shaped, the image is mainly white, mostly independent, with clear outlines, and the roof is a slope roof, which is integrated with the building facade. They are recorded as ZZS_ZFSMJ, ZZS_MNZP, ZZS_XRZ, and ZZS_ZBSMJ respectively; (7) Stilt houses The seventh type of dwellings is stilt dwellings. Its characteristics are: the ground floor is elevated for moisture prevention and ventilation, the building materials are mostly wood, bamboo, and soil, and most of them are sloping roofs, denoted as GLS. Since the image features of stilt dwellings of various ethnic groups and regions are similar, the stilt dwellings of various ethnic groups are collectively referred to as stilt dwellings. Its characteristics are: the dwellings are made of vertical wooden or bamboo piles to form a base frame above the ground, on which bamboo, wood, thatch, etc. are built. The image is usually wood color or brown, the facade is usually wood texture, the main body of the building is relatively flexible, and the roof form is a sloping roof. It is denoted as GLSMJ; (8) Terraced Houses The eighth type of residential type is the outer shell residential type. Its characteristics are: the building material is mainly loess, most of them are flat roofs, and there are few and small doors and windows, which are recorded as KS. According to the characteristics of the architectural form image, the outer shell residential type is divided into three sub-categories, namely, Ayiwang-style residential type, Tuzhangfang and Zhuangkuo. Among them, the characteristics of Ayiwang-style residential type are: it is both a completely enclosed indoor space and a large courtyard with a skylight. The image is mainly yellow and reddish brown. The facade is mainly rammed earth or brick texture. The building shape is mostly rectangular, and there are many terraces. The roof form is flat. The characteristics of Tuzhangfang residential type are: the building shape is mostly rectangular, the outline is straight and clear, the facade is mostly a combination of multiple monomers up and down, the roof form is flat, and the image is mainly khaki. The characteristics of Zhuangkuo residential type are: there are tall and thick loess walls, the building shape is mostly rectangular, the outline is clear, there is a courtyard space inside, the roof form is mostly flat, and the image is mainly khaki or brown. They are denoted as KSMJ_AYWSMJ, KSMJ_TZF, and KSMJ_ZK respectively; (9) Special residential buildings The ninth type of residential buildings is special residential buildings. Its characteristics are as follows: special buildings usually appear due to specific factors, such as the need to protect land, abundant local forest resources, or easy disaster prevention. The appearance and structure do not have uniform characteristics, which are recorded as TSL. Special residential buildings are further divided into three subcategories according to the architectural form image characteristics, namely waterside residential buildings, Western-style buildings, and modern townhouses. The characteristics of waterside dwellings are: buildings are usually distributed around water bodies, buildings float on the water or are close to water bodies, the building shapes are relatively flexible, the roof forms are mostly sloping roofs, and the image colors are mostly white, blue, and cyan; the characteristics of Western-style buildings are: generally refers to Chinese residential buildings with Western characteristics, the residential images are rich and diverse in color, there are many Western elements in the buildings, the door and window forms and decorations are Western-style, there are many plants around, the roof forms are rich, and flat roofs and sloping roofs exist; the characteristics of modern townhouses are: the facade shape is generally a localized variant of the Nanyang style, the image mainly presents gray and brick red colors, the buildings mostly appear continuously along the street, the bays are arranged in arrays, and there are many mixed Chinese and Western patterns and geometric patterns, and the roof forms are mostly flat roofs. They are recorded as TSL_LSMJ, TSL_XSFGJZ, and TSL_XDLPMJ respectively.
[0011] Furthermore, the requirements for the images of traditional Chinese dwellings in the dwelling type image set A and the image set B to be identified in step S2 are as follows: (1) Since YOLOv8 is a target detection algorithm, it identifies the target object and its location information in the image by analyzing and processing the input image. In the model algorithm, the default image size is set to 640 pixels. If the image pixels used for training recognition are lower than this precision, the accuracy of model recognition will be affected. In addition, to ensure that traditional building types can be accurately identified, architectural photos should clearly show the roof form, color, material and other information of each type of residential building. Therefore, when constructing data set A, the image size is selected to be no less than 640*640, and the image format is jpg.
[0012] (2) Since the recognition method of the present invention is a recognition method for building types, the recognition subject is traditional Chinese residential buildings. However, since each ground-shot picture is taken at a different distance from the building and the equipment used is different, the position and scaling of the traditional residential buildings on the image will be different. In order to avoid the difficulty in identifying the characteristics of the building facade due to the small area of the feature pixels of the image during the training process, it is necessary to ensure that the collected image content should contain relatively complete one or more building facades.
[0013] Furthermore, in step S3, since there is currently no public Chinese traditional dwelling type data set for use in the present invention, the present invention collects and produces relevant Chinese traditional dwelling type training set T and verification set Y. The image collection process is as follows: analyze the color features, style features, material features, and roof features of different dwellings to determine dwelling type image examples (Figure 2), input dwelling type keywords on the public image data platform, compare the dwelling type image examples, obtain various Chinese traditional dwelling type images, and then collect Chinese traditional dwelling image data through the network search platform based on the type images as the basis for subsequent model training.
[0014] Furthermore, in step S3, the traditional dwelling images corresponding to various types of dwellings are annotated by the Labelimg image annotation tool. LabelImg is an open source graphical user interface (GUI) tool, mainly used for image annotation, especially for preparing training data for machine learning and computer vision projects. It allows users to mark objects in images by drawing bounding boxes and assigning a category label to each bounding box. These annotation information can be exported as XML files (following the Pascal VOC format), TXT files (applicable to YOLO format) or other supported formats, containing the coordinates, category information, etc. of each annotated object for training deep learning models.
[0015] Specifically, all the main parts of the buildings that appear in each picture are annotated. Since the final detection is based on the target detection function of the YOLO series, the complete range of residential buildings should be included in the annotation box when annotating the 23 target types. There should be no gap between the annotation box and the annotated object to avoid interference from parts other than the main building to the recognition; every object in the image should be annotated and no omissions should be made. Omitted marks will cause the main building to be identified as the background during model training, resulting in reduced recognition accuracy; the frame coordinates should be ensured not to be on the image boundary to prevent out-of-bounds errors during data loading or data expansion.
[0016] Furthermore, the YOLOv8x pre-trained weight model selected in step S4 is a publicly published target detection model, which was publicly released by the Ulitralytics web platform in November 2023; among the many pre-trained weight models of YOLOv8, the YOLOv8x pre-trained weight model performs best in accuracy, detection accuracy and performance, and is suitable for scenarios requiring high-precision target detection. The use scenario of the present invention is the recognition of traditional Chinese dwelling types, and the image scene is complex. The use of the YOLOv8x pre-trained weight model can improve the accuracy and precision of dwelling type recognition. How to obtain the YOLOv8x pre-trained weight model: Download the YOLOv8 network data configuration file from the official website of the code and software development platform GitHub.
[0017] Specifically, the network structure of the YOLOv8 model includes an input end, a Backbone network, a Neck network, and a Head output end connected in sequence. The process of inputting the training set T and the verification set Y into the YOLOv8 network model for model training is as follows: (1) Image preprocessing: The labeled training set and validation set are sent to the input of the model, and the input preprocesses the images of the training set. The preprocessing includes mosaic data enhancement and adaptive anchor box calculation. (2) Feature extraction: The preprocessed image enters the Backbone network, including the BottleneckCSP module and the Focus module, and three feature maps of different sizes are obtained after one convolution; (3) Feature fusion: The three feature maps of different sizes obtained in the previous step are input into the Neck network for feature fusion. The features extracted by the feature extraction module are used by FPN+PAN to enable the model to obtain feature maps of three scales. (4) Prediction output: The feature map obtained in the previous step is input into the Head output terminal to obtain the position, category and confidence of the prediction box. In the training phase, the prediction box is matched with the real box to obtain positive and negative samples, and then the weight parameters are adjusted by calculating the loss function. In the verification phase, the prediction box is screened by weighted non-maximum suppression, and the model parameters are continuously optimized by calculating the accuracy and average precision.
[0018] Furthermore, the transfer learning training process of training and acquiring the Chinese traditional dwelling type recognition model build_reco_best.pt in step S4 is as follows: (1) Custom configuration file: Customize the YOLOv8 network model data configuration file coco128.yaml, modify the dataset root directory path, training set image path train, validation set image path val, test set image path test, number of categories nc, and recognition category name names, and rename the file to build_reco.yaml.
[0019] (2) Tune the parameters and train the model: Import the set build_reco.yaml file into the computer with the configured environment; load the yolov8x.pt pre-trained weight model to obtain better network model initialization parameters; load the training set T and the validation set Y, set the YOLOv8x pre-trained weight model hyperparameters, set the number of training iterations to 300 generations, the initial learning rate to 0.01, the weight decay rate to 0.005, the batch size to 16 and start training; repeat the training process to allow YOLOv8 to gradually converge, and continuously adjust the data set through the validation set test to enable it to have generalization ability and improved accuracy.
[0020] (3) Model acquisition: During the training process, the validation set Y verification result data is observed in real time. After the training is completed, the optimal model build_reco_best.pt is saved and recorded as the Chinese traditional dwelling type recognition model.
[0021] Specifically, in step S4, the YOLOv8x pre-trained weight model hyperparameters are set, and the number of training iterations is the number of times the YOLOv8x pre-trained weight model completely traverses the training set T; the initial learning rate is used to control the step size of the model weight update at each iteration, and determines the initial convergence speed of the model in training; the batch size determines the number of samples used each time the model weight is updated, which affects the memory usage, training speed and training stability of the model; the weight decay rate is to apply a regularization term to the model parameters each time the model weight is updated to prevent the model from overfitting, and the expression formula of the total loss function is:
[0022] in,L total is the total loss function; L It is the original loss function, which is used to measure the gap between the detection results of the YOLOv8x pre-trained weight model and the actual results; is the weight decay rate; i is an index variable used to traverse all weight parameters in the model. w i represents the i-th weight parameter in the model, is the sum of the squares of all model weights, Represents the regularization term, which is used to control the complexity of the YOLOv8x pre-trained weight model. The weight decay rate is increased to 0.005, which increases the proportion of the regularization term in the loss function, reduces the model weight, reduces the model complexity, and increases the model generalization performance.
[0023] Specifically, the traditional dwelling type training set used in the present invention covers different traditional dwelling types across the country, with extensive data and large scale. When processing images of dwelling types of different styles and structures across the country, increasing the weight decay rate allows the model to maintain a smaller weight value during the training process, thereby reducing dependence on specific training samples, which can improve the generalization ability of the model and ensure that the model still has efficient recognition performance when facing residential building images in different regions.
[0024] Furthermore, the image set B to be identified in step S5 is the image of traditional dwellings of various county-level administrative units in China. The image is collected from a public image data website, and the keywords "name of county-level unit in China" + "traditional dwelling" are input for searching, and the image of traditional dwellings of the county-level administrative unit is checked and obtained, and named with the name of the county-level unit to produce the image set B to be identified with geographic semantic information. The use of county-level administrative units mainly has the following considerations: First, the purpose of the present invention is to identify the types of various types of traditional dwellings in China, and the image must have the semantics of national geographic spatial information. Divided by county-level administrative units, the name of each geographical unit will not be repeated, which can reduce the error of image confusion caused by the same name and improve the recognition accuracy; on the other hand, the appearance characteristics of traditional dwellings at the county level have a small change range and are representative; at a larger level of administrative units such as cities and provinces, there are more types of traditional dwellings, which may be omitted in the image collection stage; and at a smaller level of administrative units such as towns and villages, the appearance characteristics of traditional dwellings change less, which will increase the repeatability of the data set and reduce work efficiency.
[0025] Furthermore, in step S6, the images in the image set B to be identified are input into the model build_reco_best.pt for calculation, the confidence threshold conf-thres is set to 0.80, the intersection-and-union ratio iou-thres is set to 0.6, and the txt document result is set to be saved, and the image recognition result and txt document result of each traditional residential building are obtained; the image recognition result includes the category, detection frame, and confidence score, and one detection frame corresponds to one category and confidence score; the txt document result includes the category and the location information of the detection frame. Among them, the detection frame defines the regional rectangular boundary of the residential type, and the confidence indicates the probability of the existence of the material in the detection frame and the degree of certainty that the existing residential building belongs to a certain category; the txt document result includes the category and the location information of the detection frame.
[0026] Specifically, the recognition results of each image recognition result of a traditional dwelling are written into a separate txt document, and the name of the txt document is consistent with the source image; wherein each txt document contains one or more recognition result records, and a recognition result record corresponds to the category recognition result of an object in a detection box in the image recognition result and the location information of the detection box.
[0027] Specifically, each record contains the following information: ①Category. 0, corresponding to DDL_CDMJ; 1, corresponding to DDL_SGMJ; 2, corresponding to DDL_MGMJ; 3, corresponding to TYS_HYSMJ; 4, corresponding to TYS_THSMJ; 5, corresponding to WB_TL; 6, corresponding to WB_WL; 7, corresponding to DFS_DL; 8, corresponding to DFS_DF; 9, corresponding to YDS_KYY; 10, corresponding to YDS_DKY; 11, corresponding to YDS_GY; 12, corresponding to ZZS_ZFSMJ; 13, corresponding to ZZS_MNZP; 14, corresponding to ZZS_XRZ; 15, corresponding to ZZS_ZBSMJ; 16, corresponding to GLSMJ; 17, corresponding to KSMJ_AYWSMJ; 18, corresponding to KSMJ_TZF; 19, corresponding to KSMJ_ZK; 20, corresponding to TSL_LSMJ; 21, corresponding to TSL_XSFGJZ; 22, corresponding to TSL_XDLPMJ; ② Detection frame coordinate points. The specific location of the dwellings in the image is recorded, which can be used to extract the geometric features of the dwellings, and further support the research on traditional dwelling architecture and image processing tasks. The coordinate points allow users to accurately know the results of retaining the txt document containing the coordinate points, in order to enrich the recognition results of traditional dwelling types, which is an important basis for subsequent various practical applications and research and analysis.
[0028] Specifically, each record contains the following information: The normalized value of the x-axis coordinate of the center point of the detection frame of the recognition result corresponds to the first floating point number, recorded as x_center; The normalized value of the y-axis coordinate of the center point of the detection box of the recognition result corresponds to the second floating point number, recorded as y_center; The normalized value of the width of the detection box of the recognition result corresponds to the third floating point number, recorded as w_center; The normalized value of the height of the detection box of the recognition result corresponds to the fourth floating-point number, denoted as h_center.
[0029] The position of the detection box can be recorded as (x_center, y_center, w_center, h_center).
[0030] In a second aspect, the present invention provides a lightweight traditional residential building type identification system, which is used to perform the above-mentioned traditional residential building type identification method, and the traditional residential building type identification system includes: The building type standard construction module is used to summarize and obtain the building types of traditional Chinese residential buildings based on public literature and residential image features, and divide traditional Chinese residential buildings into 9 categories with a total of 23 types; The Chinese traditional dwelling type standard construction module is used to obtain the Chinese traditional dwelling types based on the "Complete Collection of Chinese Traditional Dwelling Types" published by China Architecture & Building Press in 2014 and public literature data, and summarize them into 9 categories with a total of 23 types of Chinese traditional dwellings according to the Chinese traditional dwelling type standards; A module for acquiring images of various types of traditional Chinese dwellings, used to acquire images of various types of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; The training set and verification set preparation module is used to annotate the traditional residential images containing 23 types of residential images in the residential type image set A, and form a training set T and a verification set Y in a ratio of 9:1, wherein both the training set T and the verification set Y contain 23 types of residential images; The recognition model training module is used to use the training set T produced in the previous step, train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain the Chinese traditional dwelling type recognition model; The module for acquiring images of traditional Chinese dwellings to be detected is used to acquire images of traditional Chinese dwellings from public image data websites or to collect images of traditional Chinese dwellings in real time to form an image set B to be identified; The residential building image recognition module is used to input the image containing the traditional Chinese residential building to be tested into the traditional residential building material type recognition model for recognition, and obtain the building material type recognition result in the image by calculation.
[0031] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory for storing a program executable by the processor, wherein when the processor executes the program stored in the memory, the above-mentioned traditional dwelling type identification method is implemented.
[0032] In a fourth aspect, the present invention provides a storage medium storing a program, which, when executed by a processor, implements the above-mentioned method for identifying the type of traditional dwellings.
[0033] Compared with the prior art, the present invention has the following advantages and beneficial effects: (1) The method of the present invention realizes high-precision and high-efficiency identification of residential types. It uses the YOLOv8x pre-trained model, and on this basis, the model hyperparameters are carefully adjusted. A custom configuration file is used to adapt to the identification requirements of traditional Chinese residential types. On this basis, combined with the residential building image dataset collected independently, an innovative model specifically for the rapid identification and detection of traditional residential types is proposed. During the model optimization process, the weight decay rate is particularly adjusted to enhance the generalization ability of the model. This improvement enables the model to show higher recognition accuracy in the process of identifying different types of traditional residential buildings. Through this optimization, we can more accurately identify the types of traditional residential buildings, which not only improves the accuracy of detection, but also expands the scope of application of the model. This method fills the current gap in the field of traditional residential type image recognition, provides technical support for the efficient and accurate identification of various traditional residential types, avoids the errors caused by relying on manual experience in traditional methods, and will greatly promote the digital protection and restoration of traditional residential buildings.
[0034] (2) The technology of the present invention can be used for rapid identification and detection of traditional dwelling types across the country. The method of the present invention comprehensively applies classification theories from multiple disciplines such as architecture, typology, botany, and materials science to carry out a refined subdivision of traditional Chinese dwelling types. Based on the authoritative document "Complete Collection of Traditional Chinese Dwelling Types" and combined with expert opinions, a comprehensive classification of traditional dwelling types was established, 23 main types of traditional dwellings were identified, and a corresponding image database was established. The dwelling image data in this database covers traditional dwelling types in different regions, different architectural styles, and usage scenarios. It has strong representativeness and wide adaptability, ensuring that the trained model can adapt to the diversity of dwelling types in different regions, significantly enhancing the generalization performance of the model, so that it can maintain high accuracy and stability even when facing unseen dwelling images. Through the training of these data, the present invention realizes the accurate identification of traditional dwelling types across the country, ensuring that various types of traditional dwellings can be effectively identified and classified, and achieving the full coverage effect of the identification of traditional dwelling types across the country.
[0035] (3) The technology of the present invention can be used for rapid identification and detection of traditional dwelling types across the country. By using the detection model formed by this technology and the image data with geographic information semantics that can be obtained from public image data websites, the spatial distribution of different traditional dwelling types across the country can be effectively studied. This greatly reduces the manpower and material costs required for related research. Ultimately, the research results will help to apply traditional dwelling types with regional characteristics in the protection and restoration of traditional dwellings across the country. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0037] Figure 1 It is a flowchart of the steps of a method for identifying the types of traditional Chinese dwellings based on a deep neural network disclosed in the present invention; Figure 2a This is an example diagram of some of the 23 types of residential buildings disclosed in the present invention. Figure 2b is an example diagram of another part of the 23 types of residential buildings disclosed in the present invention. Figure 2c It is an example diagram of another part of the 23 types of residential houses disclosed in the present invention; Figure 3 This is a schematic diagram of the optimal model obtained after multiple tests in Example 1 of the present invention; Figure 4 is a confusion matrix diagram of the optimal model obtained after multiple experiments in Example 1 of the present invention; Figure 5 This is a schematic diagram of partial image recognition results of the image set B to be recognized input into the recognition model in Example 1 of the present invention; Figure 6a is a schematic diagram comparing a portion of the recognition results of the models in Examples 1 and 2 of the present invention, Figure 6b is a schematic diagram comparing another part of the recognition results of the models in Examples 1 and 2 of the present invention; Figure 7a is a schematic diagram comparing a portion of the recognition results of the models in Examples 1 and 3 of the present invention, Figure 7b is a schematic diagram comparing another part of the recognition results of the models in Examples 1 and 3 of the present invention; Figure 8 It is a structural block diagram of a system for identifying the type of Chinese traditional residential buildings in Embodiment 4 of the present invention; Fig. 9 This is a structural diagram of an electronic device in Example 5 of the present invention. DETAILED DESCRIPTION
[0038] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0039] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
[0040] Example 1 This embodiment specifically discloses a method for identifying the types of traditional Chinese dwellings based on a deep neural network. Figure 1 As shown, the method for identifying the type of traditional Chinese dwellings includes the following steps: S1. Constructing the type standard of traditional Chinese dwellings: Based on the Complete Collection of Traditional Chinese Dwelling Types published by China Architecture & Building Press in 2014 and public literature data, the types of traditional Chinese dwellings were obtained and summarized into 9 categories with a total of 23 types according to the type standard of traditional Chinese dwellings; In step S1 of this embodiment, since the types of traditional Chinese dwellings have evolved from mutual influence and have certain common characteristics, this method is based on the combination of authoritative literature combing and expert opinions to form 9 major types of traditional dwellings distributed in various regions of China. Since different types of traditional dwellings have large differences in shape, material, appearance, color and other factors, and are reflected in the morphological characteristics of the image, the accuracy of traditional dwelling type identification is affected. Therefore, the present invention comprehensively considers the morphological characteristics of the building and subdivides the 9 major types of dwellings. Finally, the 23 types of dwellings are obtained, as shown in Table 1.
[0041] Table 1. Information on types of traditional Chinese dwellings
[0042] S2. Obtaining various types of images of traditional Chinese dwellings: Obtaining various types of traditional dwelling images from public image data websites to form a dwelling type image set A; In step S2 of this embodiment, the residential type image set A is to download the Chinese traditional residential images from public websites such as Bing, Google, and Baidu. According to the Chinese traditional residential type names obtained in the previous step, the relevant residential type names are input as keywords, and the images of various types of traditional residential images are checked and obtained, and named with the type name to produce the residential type image set A for model training and verification. In order to avoid the difficulty in distinguishing the types of traditional residential buildings due to too few characteristic pixels of small-scale Chinese traditional residential buildings after convolution, the residential type image set in step S2 needs to ensure that the residential building images can distinguish the types of traditional residential buildings, and the image format is jpg. In this embodiment, a total of 7689 Chinese traditional residential type images are obtained.
[0043] S3. Create a training set and a validation set: In the residential type image set A, use the Labelimg image annotation tool to annotate traditional residential images containing 23 residential types, and divide them into a training set T and a validation set Y in a 9:1 ratio, wherein both the training set T and the validation set Y contain 23 residential types. In this embodiment, the number of sample images of 23 traditional residential types in the training set T is 6921, and the number of sample images of 23 traditional residential types in the training set Y is 768.
[0044] S4. Training recognition model: Use the training set T produced in the previous step to train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain a Chinese traditional dwelling type recognition model; In step S4 of this embodiment, the transfer learning training process of training and obtaining the Chinese traditional dwelling type recognition model is as follows: S401, custom configuration file: customize the YOLOv8 network model data configuration file coco128.yaml, rename the file to build_reco.yaml, modify the dataset root directory path, training set image path train, validation set image path val, test set image path test, the number of categories nc is 23, and the recognition category name names is the corresponding annotation label name.
[0045] S402, tuning parameters for training model: import the set build_reco.yaml file into the computer with configured environment; load yolov8x.pt pre-trained weight model to obtain network model initialization parameters; load training set T and validation set Y, set YOLOv8x pre-trained weight model hyperparameters, set the number of training iterations to 300 generations, the initial learning rate to 0.01, the weight decay rate to 0.005, the batch size to 16 and start training; repeat the training process to make YOLOv8 gradually converge, and continuously adjust the data set through the validation set test to make it have generalization ability and improved accuracy.
[0046] S403, model acquisition: observe the validation result data of the validation set Y in real time during the training process, and save the optimal model build_reco_best.pt after the training is completed, which is recorded as the Chinese traditional dwelling type recognition model. The training result data of the Chinese traditional dwelling type recognition model in the validation set has a Precision of 0.74, a Recall of 0.71, and a mAP@50 of 0.77. After the training is completed, save the optimal model build_reco_best.pt; the Precision value represents the precision rate, the Recall value represents the recall rate, and the mAP@50 value represents the average precision value.
[0047] Figure 3 The training curves of the three loss indicators related to "train / " in the figure are decreasing, indicating that the training effect is gradually improving and the loss value is decreasing. Specifically, the train / box_loss curve is decreasing during the training process, especially after the first 100 rounds, it tends to be stable, indicating that the model performs well in optimizing the position of the detection box. The train / cls_loss curve tends to converge after about 150 rounds, which shows that the model has achieved a good state for the classification of traditional residential types under the current data set and optimization conditions. The train / dfl_loss tends to converge after 150 rounds, indicating that the focus of feature capture of various types of traditional residential buildings in the training is good. The above three indicators prove the scientificity and effectiveness of this method in the classification of traditional residential types in China. The training curves of the three loss indicators related to "val / " are also decreasing. Specifically, the val / box_loss curve shows that the detection box loss function on the validation set decreases significantly in the first 100 rounds and tends to be stable after 150 rounds, indicating that the model can also effectively optimize the position of the detection box on unseen data. The val / cls_loss curve shows that the classification loss function on the validation set decreases rapidly after about 50 rounds and converges after 100 rounds, which means that the classification ability of the model on the validation set has also been greatly improved. The val / dfl_loss curve shows that the feature point loss on the validation set tends to converge after about 100 rounds, indicating that the model can also effectively capture feature points on the validation set. Figure 3The accuracy indicators related to "metrics / " in the figure show that the accuracy and recall rate of the current model detection box increase rapidly in the early stage of training and stabilize after about 100 rounds. The detection accuracy rate (precision) is high and the recall rate (recall) is good. The curves of metrics / mAP50(B) and metrics / mAP50-95(B) show that the mean average precision (mAP) of the model is high when the IoU threshold is 0.5, indicating that the model has good positioning ability under the standard threshold. With the increase of the IoU threshold, mAP50-95 also shows a good upward trend, but it decreases slightly under the high threshold, indicating that the model still has room for improvement in boundary or detail prediction.
[0048] Overall, Figure 3 The indicators prove the correctness of using the target detection model for this study and the scientificity and effectiveness of this method in identifying the types of traditional Chinese dwellings. The model trained under the current data and optimized conditions has a good recognition effect and is capable of general recognition and detection tasks.
[0049] Figure 4 It is a confusion matrix diagram of the optimal model obtained after multiple tests in Example 1 of the present invention, showing the relationship between the model prediction results and the actual labels, where the horizontal axis "True" represents the true value, the vertical axis "Predicted" represents the predicted value, and the numerical value represents the proportion of correct or incorrect classification of the category, which can indicate the overall performance and confusion of the model. Specifically, the diagonal values (i.e. the proportion of correct classification) of most categories are high, which shows that the model has a good recognition effect on most traditional residential categories, especially in some categories, such as single-family residential types; however, there is slight confusion inside the courtyard type residential buildings, and there is more confusion between the subdivision types of the outline type residential buildings, especially the earth palm house residential buildings; the recognition effect of the background category is relatively poor, the diagonal value is low, and there is more confusion with other categories; this is because the characteristics of the background category are not obvious enough or the data is unbalanced. The number of samples of the background category should be increased in the future, and the model's recognition ability of this category should be improved through data enhancement technology. In general, the model performs well in the recognition task of traditional Chinese residential types, especially in some categories. A high accuracy rate has been achieved.
[0050] S5. Obtain images of traditional Chinese dwellings: obtain images of traditional Chinese dwellings throughout China from a public image data website or collect images of traditional Chinese dwellings throughout China in real time to form an image set B to be identified; In step S5 of this embodiment, the image set B to be identified is the images of traditional dwellings of various county-level administrative units in China. First, the images of traditional Chinese dwellings are downloaded from public websites such as Bing, Google, and Baidu. The keywords "name of Chinese county-level unit" + "traditional dwellings" are entered for search, and the images of traditional dwellings of the county-level administrative unit are checked and obtained, and named after the county-level unit to produce the image set B to be identified with geographic semantic information. In order to avoid missing detection due to too few characteristic pixels of small-scale traditional Chinese residential buildings after convolution, the image set to be identified in step S3 needs to ensure that the proportion of the main body of the traditional residential building in the image is greater than or equal to 50% of the image pixels, and the image format is jpg. In this embodiment, a total of 22,748 images of traditional dwellings of various county-level administrative units in China are obtained.
[0051] S6. Identify the types of traditional Chinese dwellings: Input the images in the to-be-identified image set B into the traditional dwelling type identification model for identification, and obtain the identification results of the dwelling types in each image by calculation.
[0052] In step S6 of this embodiment, the images in the image set B to be identified are input into the Chinese traditional dwelling type identification model for calculation, and the txt document result is set to be saved to obtain the image recognition result and txt document result of each traditional dwelling; the image recognition result includes the category, detection frame, and confidence score, and one detection frame corresponds to one category and confidence score; the txt document result includes the category and the location information of the detection frame. Among them, the detection frame defines the regional rectangular boundary of the material type, and the confidence indicates the probability of the existence of residential buildings in the detection frame and the degree of certainty that the existing residential buildings belong to a certain category; the txt document result includes the category and the location information of the detection frame.
[0053] Specifically, the image recognition results of each traditional dwelling are written into a separate txt document, and the name of the txt document is consistent with the source image; each txt document contains one or more records, and a record corresponds to the category recognition result of an object in a detection box in the image recognition result and the location information of the detection box.
[0054] Specifically, each record contains the following information: ①Category. 0, corresponding to DDL_CDMJ; 1, corresponding to DDL_SGMJ; 2, corresponding to DDL_MGMJ; 3, corresponding to TYS_HYSMJ; 4, corresponding to TYS_THSMJ; 5, corresponding to WB_TL; 6, corresponding to WB_WL; 7, corresponding to DFS_DL; 8, corresponding to DFS_DF; 9, corresponding to YDS_KYY; 10, corresponding to YDS_DKY; 11, corresponding to YDS_GY; 12, corresponding to ZZS_ZFSMJ; 13, corresponding to ZZS_MNZP; 14, corresponding to ZZS_XRZ; 15, corresponding to ZZS_ZBSMJ; 16, corresponding to GLSMJ; 17, corresponding to KSMJ_AYWSMJ; 18, corresponding to KSMJ_TZF; 19, corresponding to KSMJ_ZK; 20, corresponding to TSL_LSMJ; 21, corresponding to TSL_XSFGJZ; 22, corresponding to TSL_XDLPMJ; ② Detection frame coordinate points. The specific location of the dwellings in the image is recorded, which can be used to extract the geometric features of the dwellings, and further support the research on traditional dwelling architecture and image processing tasks. The coordinate points allow users to accurately know the results of retaining the txt document containing the coordinate points, in order to enrich the recognition results of traditional dwelling types, which is an important basis for subsequent various practical applications and research and analysis.
[0055] Specifically, each record contains the following information: The normalized value of the x-axis coordinate of the center point of the detection frame of the recognition result corresponds to the first floating point number, recorded as x_center; The normalized value of the y-axis coordinate of the center point of the detection box of the recognition result corresponds to the second floating point number, recorded as y_center; The normalized value of the width of the detection box of the recognition result corresponds to the third floating point number, recorded as w_center; The normalized value of the height of the detection box of the recognition result corresponds to the fourth floating-point number, denoted as h_center.
[0056] The position of the detection box can be recorded as (x_center, y_center, w_center, h_center).
[0057] Example 2 The method of this embodiment is roughly the same as that of the above-mentioned embodiment 1, with the main difference being that in step S4, in the hyperparameter setting of the YOLOv8x pre-trained weight model, the weight decay rate is adjusted to 0.001. The weight decay rate is a regularization term applied to the model parameters each time the model weight is updated to prevent the model from overfitting. The total loss function is expressed as:
[0058] in,L total is the total loss function; L It is the original loss function, which is used to measure the gap between the detection results of the YOLOv8x pre-trained weight model and the actual results; is the weight decay rate; i is an index variable used to traverse all weight parameters in the model. w i Indicates the model i weight parameters, is the sum of the squares of all model weights, Represents the regularization term, which is used to control the complexity of the YOLOv8x pre-trained weight model and reduce the weight decay rate to 0.001.
[0059] The total number of samples and the total number of samples in the original training set T in this embodiment are the same as those in Embodiment 1. The training set T is input into the YOLOv8 network model for model training and verified by the verification set Y. The obtained optimal model is saved as build_reco_best2.pt. The comparison with the model evaluation data of Embodiment 1 is shown in Table 2: Table 2. Comparison of model evaluation data between Example 1 and Example 2
[0060] Among them, the Precision value represents the precision rate, the Recall value represents the recall rate, the mAP@0.5 value represents the average precision value, and the mAP@.5:0.95 value represents the average precision value at different intersection-over-union ratio thresholds.
[0061] In Example 2, the weight decay rate in the model parameters is reduced, so that the model maintains a large weight value during the training process. This practice increases the dependence on specific training samples and reduces the generalization ability of the model. Therefore, the trained model has poor recognition performance when facing residential building images in different regions. When verifying the verification set Y, both the precision and recall rates are reduced; in terms of the performance of image recognition results, the model has too much memory of training data, resulting in unstable confidence in the detection frame. It is very sensitive to unseen data or subtle changes (such as shooting angles, lighting conditions), and is prone to misclassification or uncertain prediction results, resulting in a decrease in the confidence of the detection frame (as shown in Table 2).
[0062] like Figure 6a As shown, Figure 6aThe recognition test results of Build_reco_best.pt (weight-decay=0.005) and Build_reco_best2.pt (weight-decay=0.001) are shown in the figure on the left. The image recognition result of a certain image in the image set B to be recognized in Example 1 is shown. Three traditional residential buildings are recognized with confidence levels of 0.92, 0.86 and 0.56 respectively. The image on the right is shown in Example 2 for the same image. Two traditional residential buildings are recognized. The recognition confidence levels of the residential buildings are 0.90 and 0.84, which are the same as those in Example 1. On the one hand, it shows that reducing the weight decay rate reduces the generalization ability of the model and fails to recognize the traditional residential buildings recognized by the model of Example 1. On the other hand, it also shows that reducing the weight decay rate will reduce the confidence score of the originally recognized residential type. In general, the recognition ability is reduced. Similarly, Figure 6b It also shows that the recognition ability of Example 2 is reduced, and the two types of traditional dwellings identified by Example 1 cannot be correctly identified. Figure 6b , Build_reco_best.pt recognition test results (weight-decay=0.005), Build_reco_best2.pt recognition test results (weight-decay=0.001), the left picture shows the image recognition result of a certain image in the image set B to be recognized in Example 1, and 2 types of residential buildings with 2 building bodies are recognized. The right picture shows the image recognition result of the same image in Example 2, and the two types of residential buildings are recognized as the same category.
[0063] Input some images in the image set B to be identified, count the results of the model prediction in Examples 1 and 2, calculate the false negative rate and false positive rate of each category respectively, and use the average value of the false negative rate and false positive rate of each category as the comprehensive missed detection rate and false alarm rate of the Chinese traditional residential building type recognition model, which can be used as an indicator for evaluating the performance of the model. The relevant calculation formula is: False Negative Rate (FNR) =
[0064] False Positive Rate (FPR) =
[0065] Mean FNR of residential type recognition model =
[0066] False positive rate of residential type recognition model (Mean FPR) =
[0067] Among them, FN (true positive) means that the model correctly identifies a certain type of residential building, FP (false positive) means that the model mistakenly identifies another type of residential building as a certain type of residential building, TN (true negative) means that the model correctly identifies that a certain type of residential building does not exist, FN (false negative) means that the model mistakenly identifies that a certain type of residential building does not exist, i represents the i-th type of residential building, represents the false negative rate of the i-th type of residential building, and represents the false positive rate of the i-th type of residential building.
[0068] The comparison of the model prediction results of Example 1 and Example 2 is shown in Table 3: Table 3. Comparison of model prediction results between Example 1 and Example 2
[0069] In Example 2, the weight decay rate in the model parameters is reduced, and the model has more memory of the training data, which can capture more details, thereby reducing the missed detection rate. Due to the easy overfitting, the model learns some unnecessary noise, resulting in an increase in the false alarm rate, affecting the overall reliability of the model (as shown in Table 3).
[0070] Example 3 The method of this embodiment is roughly the same as that of the above-mentioned embodiment 1, with the main difference being that in step S4, in the hyperparameter setting of the YOLOv8x pre-trained weight model, the weight decay rate is adjusted to 0.01. The weight decay rate is a regularization term applied to the model parameters each time the model weight is updated to prevent the model from overfitting. The total loss function is expressed as:
[0071] in, L total is the total loss function; L It is the original loss function, which is used to measure the gap between the detection results of the YOLOv8x pre-trained weight model and the actual results; is the weight decay rate; i is an index variable used to traverse all weight parameters in the model. w i Indicates the model i weight parameters, is the sum of the squares of all model weights, Represents the regularization term, which is used to control the complexity of the YOLOv8x pre-trained weight model and increase the weight decay rate to 0.01.
[0072] The total number of samples and the total number of samples in the original training set T in this embodiment are the same as those in Embodiment 1. The training set T is input into the YOLOv8 network model for model training and verified by the verification set Y. The obtained optimal model is saved as build_reco_best3.pt. The comparison with the model evaluation data of Embodiment 1 is shown in Table 4: Table 4. Comparison of model evaluation data between Example 1 and Example 2
[0073] Among them, the Precision value represents the precision rate, the Recall value represents the recall rate, the mAP@0.5 value represents the average precision value, and the mAP@.5:0.95 value represents the average precision value at different intersection-over-union ratio thresholds.
[0074] In Example 3, the weight decay rate in the model parameters is increased, so that the model imposes a stronger penalty on the weight value during the training process. This approach reduces the model's dependence on large weight values, improves the model's generalization ability, and reduces the risk of overfitting, but causes the model to tend to learn simpler feature representations, ignores the complex patterns and details in the residential image data, and cannot fully capture the useful information in the training data. Therefore, the trained model has poor recognition performance when facing residential building images in different regions. When verifying the verification set Y, both the precision and recall rates are reduced; in terms of the performance of image recognition results, the model can better handle unseen data and is not easily affected by irrelevant changes (such as lighting and shooting angles), but at the same time the model becomes more conservative and tends to make fewer but more reliable predictions to avoid recognition errors. For some traditional residential buildings with unique decorations or structural details, the model will fail to correctly recognize these nuances due to oversimplification of its learned feature representations, thereby missing some real samples (as shown in Table 4).
[0075] like Figure 7a As shown, Figure 7aThe recognition test results of Build_reco_best.pt (weight-decay=0.005) and Build_reco_best3.pt (weight-decay=0.01) are shown in the figure. The left picture shows the image recognition result of an image in the image set B to be recognized in Example 1, and 3 traditional residential entities were recognized with confidence levels of 0.91, 0.81 and 0.85 respectively; the right picture shows the image recognition result of the same image in Example 3, and 4 traditional residential entities were recognized. The material recognition confidence levels of the same parts as those in Example 1 are 0.94, 0.92 and 0.75, and 2 more traditional residential entities were recognized with a confidence level of 0.56. On the one hand, it shows that increasing the weight decay rate enhances the generalization ability of the model, and can recognize the traditional residential building entities recognized by the model in Example 1. On the other hand, it also shows that increasing the weight decay rate will make the confidence score of the originally recognized residential type low and unstable. At the same time, if Figure 7b As shown, Figure 7b Build_reco_best.pt recognition test results (weight-decay=0.005), Build_reco_best3.pt recognition test results (weight-decay=0.01). The left picture shows the image recognition result of a cave dwelling image in the image set B to be recognized in Example 1, and 2 traditional dwellings leaning against cliffs are recognized, with confidences of 0.86 and 0.80 respectively; the right picture shows the image recognition result of Example 3 for the same image, and 2 traditional dwellings are recognized, 1 cliff kiln and 1 imprisoned kiln are detected, with confidences of 0.48 and 0.69 respectively; it shows that the recognition ability of Example 3 is reduced, and for situations that need to rely on complex features for classification, these subtle differences cannot be correctly captured, resulting in misjudgment or missed detection.
[0076] Input some images in the image set B to be identified, and count the results of model prediction in Examples 1 and 3, respectively calculate the false negative rate and false positive rate of each category, and use the average of the false negative rate and false positive rate of each category as the comprehensive missed detection rate and false alarm rate of the Chinese traditional residential building type recognition model, and compare it with the prediction results of the model in Example 1 as shown in Table 5: Table 5. Comparison of model prediction results between Example 1 and Example 3
[0077] Example 3 increases the weight decay rate in the model parameters. Although it improves the generalization ability of the model and reduces the false alarm rate, it increases the missed detection rate, especially when dealing with complex features. The model becomes more conservative and tends to avoid false positive errors, but this may cause some real positive samples to be ignored (as shown in Table 5).
[0078] Example 4 Reference Figure 8 The present invention provides a lightweight Chinese traditional dwelling type recognition system for executing the above-mentioned traditional dwelling type recognition method. The traditional dwelling type recognition system comprises: a Chinese traditional dwelling type standard construction module 801, a Chinese traditional dwelling image acquisition module 802, a training set and verification set preparation module 803, a recognition model training module 804, a Chinese global dwelling image acquisition module 805 to be detected, and a residential building image recognition module 806, which are connected in sequence. Chinese traditional dwelling type standard construction module 801 is used to obtain Chinese traditional dwelling types based on the "Complete Collection of Chinese Traditional Dwelling Types" published by China Architecture & Building Press in 2014 and public literature data, and summarize them into 9 categories with a total of 23 Chinese traditional dwelling types according to the Chinese traditional dwelling type standards; Various types of traditional Chinese dwelling images acquisition module 802, used to acquire various types of images of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; The training set and verification set preparation module 803 is used to annotate the traditional residential images containing 23 types of residential images in the residential type image set A, and form a training set T and a verification set Y in a ratio of 9:1, wherein both the training set T and the verification set Y contain 23 types of residential images; The recognition model training module 804 is used to use the training set T prepared in the previous step to perform training on the basis of the YOLOv8x pre-trained weight model, and to perform verification on the verification set Y to obtain a Chinese traditional dwelling type recognition model; The module 805 for acquiring images of traditional Chinese dwellings to be detected is used to acquire images of traditional Chinese dwellings from a public image data website or to collect images of traditional Chinese dwellings in real time to form an image set B to be identified. The residential building image recognition module 806 inputs the residential building images in the to-be-recognized image set B into the Chinese traditional residential building type recognition model for recognition, and obtains the type recognition results of the images in the to-be-recognized image set B through calculation.
[0079] Example 5 This embodiment provides an electronic device, which may be a computer. Fig. 9As shown, a processor 902, a memory, an input device 903, a display 904 and a network interface 905 connected via a system bus 901 are provided. The processor is used to provide computing and control capabilities. The memory includes a non-volatile storage medium 906 and an internal memory 907. The non-volatile storage medium 906 stores an operating system, a computer program and a database. The internal memory 907 provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the processor 902 executes the computer program stored in the memory, a lightweight Chinese traditional dwelling type identification method proposed in the above embodiment 1 is implemented. The traditional dwelling type identification method includes the following steps: S1. Constructing the type standard of traditional Chinese dwellings: Based on the Complete Collection of Traditional Chinese Dwelling Types published by China Architecture & Building Press in 2014 and public literature data, the types of traditional Chinese dwellings were obtained and summarized into 9 categories with a total of 23 types according to the type standard of traditional Chinese dwellings; S2. Obtaining images of various types of traditional Chinese dwellings: Obtaining images of various types of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; S3, preparing a training set and a validation set: in the residential type image set A, annotate the traditional residential images containing 23 target residential types, and divide them into a training set T and a validation set Y in a ratio of 9:1, wherein both the training set T and the validation set Y contain 23 residential types; S4. Training recognition model: Use the training set T produced in the previous step to train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain a Chinese traditional dwelling type recognition model; S5. Obtain images of traditional Chinese dwellings: obtain images of traditional Chinese dwellings throughout China from a public image data website or collect images of traditional Chinese dwellings throughout China in real time to form an image set B to be identified; S6. Identify the types of traditional Chinese dwellings: input the dwelling pictures in the to-be-identified image set B into the traditional Chinese dwelling type identification model for identification, and obtain the type identification results of the images in the to-be-identified image set B by calculation.
[0080] Example 6 This embodiment provides a storage medium, which is a computer-readable storage medium, storing a computer program. When the computer program is executed by a processor, a lightweight Chinese traditional dwelling type identification method proposed in the above embodiment 1 is implemented. The traditional dwelling type identification method includes the following steps: S1. Constructing the type standard of traditional Chinese dwellings: Based on the Complete Collection of Traditional Chinese Dwelling Types published by China Architecture & Building Press in 2014 and public literature data, the types of traditional Chinese dwellings were obtained and summarized into 9 categories with a total of 23 types according to the type standard of traditional Chinese dwellings; S2. Obtaining images of various types of traditional Chinese dwellings: Obtaining images of various types of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; S3, preparing a training set and a validation set: in the residential type image set A, annotate the traditional residential images containing 23 target residential types, and divide them into a training set T and a validation set Y in a ratio of 9:1, wherein both the training set T and the validation set Y contain 23 residential types; S4. Training recognition model: Use the training set T produced in the previous step to train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain a Chinese traditional dwelling type recognition model; S5. Obtain images of traditional Chinese dwellings: obtain images of traditional Chinese dwellings throughout China from a public image data website or collect images of traditional Chinese dwellings throughout China in real time to form an image set B to be identified; S6. Identify the types of traditional Chinese dwellings: input the dwelling pictures in the to-be-identified image set B into the traditional Chinese dwelling type identification model for identification, and obtain the type identification results of the images in the to-be-identified image set B by calculation.
[0081] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0082] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A method for identifying the types of traditional Chinese dwellings based on deep neural networks, characterized in that: The method for identifying the type of traditional Chinese residential buildings is aimed at identifying traditional Chinese residential buildings, and includes the following steps: S1. Constructing the standard of Chinese traditional dwelling types: Based on the Complete Collection of Chinese Traditional Dwelling Types and public literature data, the types of Chinese traditional dwellings were sorted out, and according to the standard of Chinese traditional dwelling types, 9 categories and 23 types of Chinese traditional dwellings were defined; S2. Obtaining images of various types of traditional Chinese dwellings: Obtaining images of various types of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; S3, preparing a training set and a validation set: in the residential type image set A, annotate the traditional residential images containing 23 target residential types, and divide them into a training set T and a validation set Y in a ratio of 9:1, wherein both the training set T and the validation set Y contain 23 residential types; S4. Training recognition model: Use the training set T produced in the previous step to train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain a Chinese traditional dwelling type recognition model; S5. Obtain images of traditional Chinese dwellings: obtain images of traditional Chinese dwellings throughout China from a public image data website or collect images of traditional Chinese dwellings throughout China in real time to form an image set B to be identified; S6. Identify the types of traditional Chinese dwellings: input the dwelling pictures in the to-be-identified image set B into the traditional Chinese dwelling type identification model for identification, and obtain the type identification results of the images in the to-be-identified image set B by calculation.
2. The method for identifying the types of traditional Chinese dwellings according to claim 1, characterized in that: The traditional Chinese residential type standard selects images of traditional Chinese residential buildings from the ground angle as the target object, and defines 9 categories and 23 types of traditional Chinese residential buildings, which are: The first type of dwellings is single-family dwellings, denoted by DDL, which can be subdivided into thatched-roof dwellings, stone-structured dwellings and wooden-structured dwellings, denoted by DDL_CDMJ, DDL_SGMJ and DDL_MGMJ respectively; the second type of dwellings is courtyard-style dwellings, denoted by TYS, which can be subdivided into courtyard-style dwellings and hall-style dwellings, denoted by TYS_HYSMJ and TYS_THSMJ respectively; the third type of dwellings is fort-style dwellings, denoted by WB, which can be subdivided into earthen buildings and enclosed buildings, denoted by WB_TL and WB_WL respectively; the fourth type of dwellings is watchtower-style dwellings, denoted by DF, which can be subdivided into watchtowers and watchtowers, denoted by DF_DL and DF_DF respectively; the fifth type of dwellings is cave-dwelling dwellings, denoted by YDS, which can be subdivided into cliff-side caves, pit courtyards and cave-dwelling caves, denoted by YDS_KYY and YDS_KYY respectively. _DKY, YDS_GY; the sixth type of dwellings is felt-tent dwellings, denoted by ZZS, which can be subdivided into account-room dwellings, yak tents, slanting pillar dwellings and felt-bag dwellings, denoted by ZZS_ZFSMJ, ZZS_MNZP, ZZS_XRZ, ZZS_ZBSMJ respectively; the seventh type of dwellings is stilt-style dwellings, denoted by GLSMJ; the eighth type of dwellings is gallery-style dwellings, denoted by KSMJ, which can be subdivided into Ayiwangshi dwellings, earthen houses and village gallery, denoted by KSMJ_AYWSMJ, KSMJ_TZF, KSMJ_ZK respectively; the ninth type of dwellings is special type of dwellings, denoted by TSL, which can be subdivided into waterside dwellings, Western-style buildings and modern townhouses, denoted by TSL_LSMJ, TSL_XSFGJZ, TSL_XDLPMJ respectively.
3. The method for identifying the types of traditional Chinese dwellings according to claim 1, characterized in that: The dwelling type image set A is images of traditional dwellings of various types of traditional dwellings in China. The image data is collected from a public image data website based on the constructed Chinese traditional dwelling type standard. The dwelling type name is input, and images of various types of traditional dwellings are verified and obtained. The images are named after the type name to produce the dwelling type image set A for training and verification of the traditional dwelling type recognition model. The dwelling type is judged according to the main body of the traditional dwelling image building in the dwelling type image set A. The image format is jpg.
4. The method for identifying the types of traditional Chinese dwellings according to claim 1, characterized in that: The process of training and obtaining the Chinese traditional dwelling type recognition model build_reco_best.pt in step S4 includes: loading the YOLOv8x pre-trained model, setting the number of training iterations to 300 generations, the initial learning rate to 0.01, the weight decay rate to 0.005, and the batch size to 16, testing the trained model on the verification set Y, and verifying the model to finally obtain the Chinese traditional dwelling type recognition model build_reco_best.pt.
5. The method for identifying the types of traditional Chinese dwellings according to claim 4, characterized in that: In step S4, the YOLOv8x pre-trained weight model hyperparameters are set, and the formula of the total loss function is: ; in, L total is the total loss function; L It is the original loss function, which is used to measure the gap between the detection results of the YOLOv8x pre-trained weight model and the actual results; is the weight decay rate; i is the index variable used to traverse all weight parameters in the model. w i represents the i-th weight parameter in the model, is the sum of the squares of all model weights, Represents a regularization term, which is used to control the complexity of the YOLOv8x pre-trained weight model.
6. The method for identifying the types of traditional Chinese dwellings according to claim 1, characterized in that: In the step S3, the labeling method of the dwelling types of the traditional dwelling images is realized by the Labelimg image labeling tool; in the step S5, the image set B to be identified is the images of traditional dwellings of various county-level administrative units in China, and the images are collected from a public image data website, and the keywords "name of China's county-level unit" + "traditional dwellings" are entered for search, and the images of traditional dwellings of the county-level administrative unit are verified and obtained, and named after the county-level unit to produce the image set B to be identified with geographic semantic information.
7. The method for identifying the types of traditional Chinese dwellings according to claim 1, characterized in that: In the step S6, the pictures in the image set B to be identified are input into the model build_reco_best.pt for calculation, the confidence threshold conf-thres is set to 0.80, the interaction ratio threshold iou-thres is set to 0.60, and the txt document result is set to be saved to obtain the image recognition result and txt document result of each traditional dwelling; the image recognition result includes the category, the detection frame, and the confidence score, and one detection frame corresponds to one category and the confidence score; the txt document result includes the category and the location information of the detection frame, wherein the confidence score indicates the probability that the Chinese traditional dwelling type recognition model believes that there is a type of dwelling in the detection frame and the degree of certainty that the existing residential building belongs to a certain category, and the confidence score is a floating point number between 0 and 1, and a confidence score close to 1 indicates that the model is very sure that there is a residential target of a certain category in the detection frame, and a confidence score close to 0 indicates that the model is doubtful about the residential target in the detection frame, or believes that there is no residential target in the detection frame; The recognition results of each image of traditional dwellings are written into a separate txt document, and the name of the txt document is consistent with the source image; each txt document contains one or more recognition result records, and a recognition result record corresponds to the category recognition result and location information of the detection frame of an object in a detection frame in the image recognition result.
8. A lightweight Chinese traditional dwelling type identification system, used to execute the traditional dwelling type identification method according to any one of claims 1 to 7, characterized in that: The Chinese traditional dwelling type identification system includes: The Chinese traditional dwelling type standard construction module is used to obtain the Chinese traditional dwelling types based on the "Complete Collection of Chinese Traditional Dwelling Types" published by China Architecture & Building Press in 2014 and public literature data, and summarize them into 9 categories with a total of 23 types of Chinese traditional dwellings according to the Chinese traditional dwelling type standards; A module for acquiring images of various types of traditional Chinese dwellings, used to acquire images of various types of traditional Chinese dwellings from a public image data website to form a dwelling type image set A; The training set and verification set preparation module is used to annotate the traditional residential images containing 23 types of residential images in the residential type image set A, and form a training set T and a verification set Y in a ratio of 9:1, wherein both the training set T and the verification set Y contain 23 types of residential images; The recognition model training module is used to use the training set T produced in the previous step, train on the basis of the YOLOv8x pre-trained weight model, and verify on the verification set Y to obtain the Chinese traditional dwelling type recognition model; The module for acquiring images of traditional Chinese dwellings to be detected is used to acquire images of traditional Chinese dwellings from public image data websites or to collect images of traditional Chinese dwellings in real time to form an image set B to be identified; The residential building image recognition module is used to input the image containing the traditional Chinese residential building to be tested into the traditional residential building material type recognition model for recognition, and obtain the building material type recognition result in the image by calculation.
9. An electronic device comprising a processor and a memory for storing a program executable by the processor, characterized in that: When the processor executes the program stored in the memory, the method for identifying the type of traditional Chinese dwellings described in any one of claims 1 to 7 is implemented.
10. A storage medium storing a program, characterized in that: When the program is executed by a processor, the method for identifying the type of traditional Chinese dwellings described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Building traditional feature recognition and evaluation method and system
CN114331031A