Cleanness detection model training method and device and electronic equipment
By preprocessing image segmentation and training sample generation of construction site cleanliness detection models, the problem of low detection accuracy in the prior art is solved, and more efficient cleanliness detection is achieved.
Patent Information
- Application Number
- CN202410851751.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2025-05-02
AI Technical Summary
The existing construction site cleanliness detection method based on deep learning is not very accurate, and the data set production process is complicated.
The training method of the neatness detection model is adopted, and the original image is acquired, and the image segmentation model is used for preprocessing, the processing image is generated, and the training samples are generated based on the original image and the processed image, and the model is trained.
The training accuracy of the neatness detection model is improved, and more accurate feature recognition and detection results are achieved.
Smart Images

Figure CN119919699A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to image classification detection technology, and more specifically, to a training method, device and electronic device for a neatness detection model. Background Art
[0002] Currently, site cleanliness inspection is the supervision and evaluation of construction sites to ensure that the site remains clean, safe and environmentally friendly. The importance of this inspection cannot be underestimated. It plays a key role in ensuring the safety of workers, improving the quality of the project and maintaining a healthy environment.
[0003] Site cleanliness testing is critical to worker safety. A clean and orderly site can reduce accidents and injuries. Messy sites often present safety hazards such as tripping, falling objects, and material accumulation, while a clean site can ensure smooth passages and reduce the risk of worker injury. In addition, proper storage and handling of construction materials to prevent them from being scattered around the site can also improve worker safety.
[0004] Site cleanliness inspection helps improve the quality of the project. Keeping the site clean and tidy can reduce the risk of building materials being damaged or contaminated and enable better management of the construction process. The requirements for the storage and handling capabilities of building materials can prompt the construction team to pay more attention to details and ensure the quality and integrity of the materials.
[0005] Site cleanliness inspection is beneficial to environmental protection. During the construction process of the site, a large amount of waste and pollutants are generated, such as concrete slag, construction waste, wastewater, etc. If these wastes and pollutants are not properly handled, they will cause serious pollution to the surrounding soil, water sources and atmosphere. By inspecting the cleanliness of the site, the site can be forced to carry out garbage sorting, waste treatment and wastewater discharge in accordance with environmental protection requirements to ensure that the impact on the environment is minimized.
[0006] In the existing technology, the construction site cleanliness detection method based on deep learning is mainly based on target detection, but the detection accuracy of this method is not optimistic, and the data set production process is very complicated.
[0007] Therefore, it is necessary to provide a new neatness detection technology solution to improve the detection accuracy. Summary of the invention
[0008] An object of the present invention is to provide a new technical solution for a training method of a neatness detection model.
[0009] According to a first aspect of the present invention, a method for training a neatness detection model is provided, comprising:
[0010] Get the original image;
[0011] Using an image segmentation model, preprocessing the original image to obtain a processed image; wherein the processed image is an image in which images corresponding to objects of different categories are identified from the original image;
[0012] Generating training samples according to the original image and the processed image; wherein each image in the training sample is annotated with a neatness classification result;
[0013] The training samples are input into the neatness detection model to be trained to obtain a trained neatness detection model.
[0014] Optionally, the image segmentation model stores feature information corresponding to items of a preset category; wherein,
[0015] The method of preprocessing the original image using the image segmentation model to obtain a processed image includes:
[0016] According to the feature information corresponding to the preset category of objects, images corresponding to objects of different categories are identified from the original image to obtain a processed image.
[0017] Optionally, the image segmentation model also stores specific pixel values corresponding to items of a preset category; wherein,
[0018] The step of identifying images corresponding to objects of different categories from the original image according to the images corresponding to the preset categories of objects to obtain processed images includes:
[0019] Obtaining specific pixel values corresponding to each category of identified objects and the preset category of objects;
[0020] Determine the specific pixel value corresponding to each category of the identified objects according to the specific pixel values corresponding to each category of the identified objects and the preset category of objects;
[0021] The original pixel values of the identified objects of each category are replaced by the specific pixel values corresponding to the identified objects of each category to obtain a processed image.
[0022] Optionally, the image segmentation model is a FastSAM model.
[0023] Optionally, the method further includes:
[0024] The trained neatness detection model is lightweighted to obtain a lightweight neatness detection model.
[0025] Optionally, the lightweight processing includes lightweight processing of weight parameters, and the weight parameters are model parameters that have been optimized and are to be quantized in the trained neatness detection model; wherein,
[0026] The step of performing lightweight processing on the trained neatness detection model to obtain a lightweight neatness detection model includes:
[0027] Obtaining the weight parameters to be quantized and the number of bits of the scaled floating-point number of the trained neatness detection model;
[0028] Determining a scaling factor of the weight parameter to be quantized according to the maximum value of the weight parameter to be quantized, the minimum value of the weight parameter to be quantized, and the number of bits of the scaled floating-point number;
[0029] Determining a quantized weight parameter according to the weight parameter to be quantized and a scaling factor of the weight parameter to be quantized;
[0030] The quantized weight parameters are used to replace the weight parameters to be quantized, so as to obtain the lightweight neatness detection model.
[0031] Optionally, the lightweight processing includes lightweight processing of input data, where the input data is input data of each layer to be quantized in the trained neatness detection model; wherein,
[0032] The step of performing lightweight processing on the trained neatness detection model to obtain a lightweight neatness detection model includes:
[0033] Input at least one original image into the trained neatness detection model, and obtain the maximum value of the input data of the corresponding layer, the minimum value of the input data of the corresponding layer, and the number of bits of the scaled floating-point number based on each layer to be quantized;
[0034] Determine, according to the maximum pixel value of the input data, the minimum pixel value of the input data and the number of bits of the scaled floating-point number, a scaling factor of the input data of the corresponding layer when performing neatness detection based on the trained neatness detection model;
[0035] According to the scaling factor of the input data of each corresponding layer, a lightweight neatness detection model is obtained.
[0036] Optionally, the method further includes:
[0037] Acquire the image to be detected;
[0038] The lightweight neatness detection model is used to perform classification detection processing on the image to be detected to obtain a classification result.
[0039] According to a second aspect of the present invention, there is provided a training device for a neatness detection model, comprising:
[0040] An acquisition module, used for acquiring the original image;
[0041] A preprocessing module, used to preprocess the original image using an image segmentation model to obtain a processed image; wherein the processed image is an image in which images corresponding to objects of different categories are identified from the original image;
[0042] A training sample generation module, used to generate training samples according to the original image and the processed image; wherein each image in the training sample is annotated with a neatness classification result;
[0043] The training module is used to input the training samples into the neatness detection model to be trained to obtain a trained neatness detection model.
[0044] According to a third aspect of the present invention, there is provided an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is used to control the processor to operate so as to execute any one of the methods according to the first aspect of the present invention.
[0045] The training method of the neatness detection model provided by the present invention utilizes an image segmentation model to preprocess the original image to obtain a processed image, generates training samples based on the original image and the processed image, and realizes the expansion of the training samples. In addition, when the processed image is used to train the neatness detection model to be trained, since the processed image is an image in which images corresponding to objects of different categories are identified from the original image, the processed image plays a prompting role, so that the neatness detection model to be trained can more accurately identify features, thereby improving the training accuracy of the neatness detection model, and a more accurate trained neatness detection model can be obtained.
[0046] Features and advantages of the embodiments of the present specification will become apparent from the following detailed description of exemplary embodiments of the present specification with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the specification and, together with the description, serve to explain the principles of the embodiments of the specification.
[0048] Figure 1 4 is a processing flow chart of a method for training a neatness detection model according to an embodiment of the present invention.
[0049] Figure 2 The figure is a schematic diagram of a process of mapping a weight parameter stored in a 32-bit floating point number to a weight parameter stored in an 8-bit floating point number according to an embodiment of the present invention.
[0050] Figure 3It is a principle block diagram of a training device for a neatness detection model according to an embodiment of the present invention.
[0051] Figure 4 FIG. 4 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0052] Various exemplary embodiments of the present specification will now be described in detail with reference to the accompanying drawings.
[0053] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the embodiments of the present specification and its application or uses.
[0054] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0055] In one embodiment of the present invention, a method for training a neatness detection model is provided. Figure 1 As shown, the training method of the neatness detection model of this embodiment may include the following steps S110 to S140.
[0056] Step S110, obtaining an original image.
[0057] The original image is a real-time RGB image collected by cameras set up at multiple inspection sites. The inspection site can be a construction site or other types of places.
[0058] Step S120, using the image segmentation model, preprocessing the original image to obtain a processed image; wherein the processed image is an image obtained by identifying images corresponding to objects of different categories from the original image.
[0059] The principle of the image segmentation model is to classify based on pixels and classify pixels belonging to the same category into one category. In this way, objects of different categories can be segmented out in the original image, that is, the background category and objects of different categories can be distinguished.
[0060] Based on each original image, a corresponding processed image can be obtained, which includes images corresponding to different categories of objects and images corresponding to background categories.
[0061] Step S130, generating training samples according to the original image and the processed image; wherein each image in the training sample is annotated with a neatness classification result.
[0062] The neatness classification results of each image in the training sample are manually labeled. For example, the neatness classification results include excellent, good, and poor.
[0063] Step S140: input the training samples into the neatness detection model to be trained to obtain a trained neatness detection model.
[0064] The training method of the neatness detection model provided by the embodiment of the present invention uses an image segmentation model to preprocess the original image to obtain a processed image, and generates training samples based on the original image and the processed image, thereby achieving the expansion of the training samples. In addition, when using the processed image to train the neatness detection model to be trained, since the processed image is an image that identifies images corresponding to objects of different categories from the original image, the processed image serves as a prompt, so that the neatness detection model to be trained can more accurately identify features, thereby improving the training accuracy of the neatness detection model, and a more accurate trained neatness detection model can be obtained.
[0065] In one embodiment, after obtaining a trained neatness detection model, the trained neatness detection model is used to perform classification detection processing on the image to be detected to obtain a classification result.
[0066] In one embodiment, the image segmentation model stores feature information corresponding to items of a preset category. Step S120 specifically includes: according to the feature information corresponding to items of the preset category, identifying images corresponding to items of different categories from the original image to obtain a processed image. The feature information corresponding to items of the preset category may be a set of vectors.
[0067] The images corresponding to the preset category items include images corresponding to multiple categories of items. Specifically, based on each image corresponding to the preset category item, it is determined whether the original image contains the image corresponding to the preset category item.
[0068] In one embodiment, the image segmentation model also stores specific pixel values corresponding to preset category items. Based on the images corresponding to the preset category items, images corresponding to different categories of items are identified from the original image to obtain the processed image, which specifically includes: obtaining specific pixel values corresponding to each identified category of items and preset category items; determining specific pixel values corresponding to each identified category of items based on the specific pixel values corresponding to each identified category of items and preset category items; replacing the original pixel values of each identified category of items with the specific pixel values corresponding to each identified category of items to obtain the processed image.
[0069] The specific pixel values corresponding to different preset category objects are different. Based on one preset category object, the specific pixel values corresponding to each pixel point in the image corresponding to the preset category object are the same.
[0070] After replacing the original pixel values of the identified objects of each category with the specific pixel values corresponding to the identified objects of each category, the pixel values of each pixel point in the image corresponding to the objects of each category are the same, that is, a specific pixel value.
[0071] In one example, three different categories of objects are identified from the original image, namely, object A, object B, and object C. The image segmentation model stores a specific pixel value a corresponding to object A, b specific pixel value b corresponding to object B, and c specific pixel value c corresponding to object C. The specific pixel value a, the specific pixel value b, and the specific pixel value c are all single different pixel values. After identifying objects A, B, and C from the original image, the specific pixel value a corresponding to object A replaces the original pixel value of object A, the specific pixel value b corresponding to object B replaces the original pixel value of object A, and the specific pixel value c corresponding to object C replaces the original pixel value of object C. After the replacement is completed, the pixel value of each pixel point in the image corresponding to object A is the specific pixel value a, the pixel value of each pixel point in the image corresponding to object B is the specific pixel value b, and the pixel value of each pixel point in the image corresponding to object C is the specific pixel value c.
[0072] In one embodiment, the image segmentation model is a FastSAM (Fast Segment Anything Model) model.
[0073] The FastSAM model is implemented based on YOLOv8-seg, with CNN as the backbone, and then FPN (Feature Pyramid Networks) is used to achieve semantic segmentation of the image.
[0074] In one embodiment, the method further includes: performing lightweight processing on the trained neatness detection model to obtain a lightweight neatness detection model.
[0075] In one embodiment, the lightweight processing includes lightweight processing of weight parameters. The lightweight processing of the trained neatness detection model to obtain the lightweight neatness detection model specifically includes: obtaining the weight parameters to be quantized and the number of bits of the scaled floating-point number of the trained neatness detection model; determining the scaling factor of the weight parameters to be quantized according to the maximum value of the weight parameters to be quantized, the minimum value of the weight parameters to be quantized and the number of bits of the scaled floating-point number; determining the quantized weight parameters according to the weight parameters to be quantized and the scaling factor of the weight parameters to be quantized; replacing the weight parameters to be quantized with the quantized weight parameters to obtain the lightweight neatness detection model.
[0076] In this embodiment, a lightweight neatness detection model is obtained by lightweight processing of the weight parameters of the trained neatness detection model. Under the premise of ensuring accuracy, the trained neatness detection model can be simplified, so that the amount of calculation is small when the lightweight neatness detection model is used for image classification detection.
[0077] In one embodiment, the trained neatness detection model is traversed through a predefined trace function to obtain the weight parameters to be quantized.
[0078] It should be noted that the weight parameters are the model parameters that have been optimized and are to be quantized in the trained neatness detection model. In the trained neatness detection model, all optimized parameters can be lightweight processed, or only some optimized parameters can be lightweight processed.
[0079] Floating point numbers are a data type used to represent real numbers in computers. Their internal representation and operations are based on binary. The number of bits in a floating point number refers to the number of bits in the binary representation of the floating point number.
[0080] In this embodiment, the number of bits of the floating point number is the number of bits of the binary number representing the weight parameter in the computer. Based on the following calculation formula (1), the scaling factor of the weight parameter to be quantized is calculated:
[0081]
[0082] Among them, S is the scaling factor of the weight parameter to be quantized, max is the maximum value of the weight parameter to be quantized, min is the minimum value of the weight parameter to be quantized, and b is the number of bits of the scaled floating point number.
[0083] For example, the original binary number of the weight parameter is 32 bits, and the binary number of the scaled weight parameter is 8 bits. The process of mapping the weight parameter of the trained neatness detection model originally stored in 32-bit floating point numbers to the weight parameter stored in 8-bit floating point numbers can be seen in Figure 2 In order to realize this mapping relationship, it is necessary to obtain a scaling value for the distribution of the weight parameter to be quantized, that is, the scaling factor of the weight parameter to be quantized.
[0084] Based on the following calculation formula (2), the quantized weight parameter is determined according to the weight parameter to be quantized and the scaling factor of the weight parameter to be quantized.
[0085]
[0086] Among them, x q is the quantized weight parameter, x is the weight parameter to be quantized, the round function is the rounding function, and the clamp function is a function that limits a value to within known upper and lower limits.
[0087] It should be noted that the round function may be replaced by a ceiling function or a floor function.
[0088] In one embodiment, lightweight processing includes lightweight processing of input data. The input data is the input data of each layer to be quantized in the trained neatness detection model. Lightweight processing is performed on the trained neatness detection model to obtain a lightweight neatness detection model, which specifically includes: inputting at least one original image into the trained neatness detection model, and obtaining the maximum value of the input data of the corresponding layer, the minimum value of the input data of the corresponding layer, and the number of bits of the scaled floating point number based on each layer to be quantized; according to the maximum pixel value of the input data, the minimum pixel value of the input data, and the number of bits of the scaled floating point number, determining the scaling factor of the input data of the corresponding layer when performing neatness detection based on the trained neatness detection model; and obtaining a lightweight neatness detection model according to the scaling factors of the input data of each corresponding layer.
[0089] In one embodiment, the scaling factor of a layer of input data can be calculated based on the above calculation formula (1). In the calculation formula (1), S is the scaling factor of the layer of input data, max is the maximum value of the layer of input data, min is the minimum value of the layer of input data, and b is the number of bits of the scaled floating point number. In this embodiment, the number of bits of the floating point number is the number of bits of binary that represent pixel values in a computer.
[0090] Taking the first layer input data of the trained neatness detection model as the pixel value of the original image as an example, in the above calculation formula (1), S is the scaling factor of the input data of this layer, max is the maximum pixel value of the input data of this layer, min is the minimum pixel value of the input data of this layer, and b is the number of bits of the scaled floating point number. Correspondingly, the scaling factors of the input data of other layers can be calculated using the above calculation formula (1).
[0091] It should be noted that the number of original images participating in the calculation of the scaling factor of each layer of input data may be one or more. In the case where there are multiple original images participating in the calculation of the scaling factor of each layer of input data, multiple scaling factors of the input data of this layer can be obtained based on each layer, and the average of the multiple scaling factors of the input data of this layer is calculated to serve as the final scaling factor of the input data of this layer.
[0092] In one embodiment, the trained neatness detection model is traversed through a predefined trace function to obtain the corresponding layers to be quantized in the trained neatness detection model. It should be noted that in the trained neatness detection model, all layers may participate in the lightweight processing, or some layers may participate in the lightweight processing.
[0093] In one embodiment, after a lightweight neatness detection model is obtained according to the scaling factor of the input data of each corresponding layer, when the lightweight neatness detection model is used for image detection, the image to be detected is subjected to classification detection processing to obtain a classification result.
[0094] Taking the first layer input data of the trained neatness detection model as the pixel value of the image to be detected as an example, the scaling factor of the input data of this layer is first used to process the pixel value of each pixel of the image to be detected. Specifically, based on the above calculation formula (2), the pixel value of each pixel of the image to be detected after processing is calculated, and the pixel value of each pixel of the image to be detected after processing is used as the final input data of this layer. In calculation formula (2), x q is the pixel value of a pixel in the image to be detected after processing, x is the pixel value of a pixel in the image to be detected before processing, round function is a rounding function, and clamp function is a function that limits a value to a known upper and lower limit. Correspondingly, the processing of input data of other layers can be calculated using the above calculation formula (2), and the processed input data is used as the final input data of this layer.
[0095] In this embodiment, when the lightweight neatness detection model is used for detection, the input data of each layer can be simplified while ensuring accuracy, so that the amount of calculation is small when the lightweight neatness detection model is used for image classification detection.
[0096] In one embodiment, the image classification model uses ResNet50 obtained through ImageNet pre-training as the backbone network, uses stochastic gradient descent as the optimizer method, and uses an Epoch-based trainer to train the model.
[0097] An embodiment of the present invention provides a training device for a neatness detection model, such as Figure 3 The training device 300 of the neatness detection model includes an acquisition module 310 , a preprocessing module 320 , a training sample generation module 330 and a training module 340 .
[0098] The acquisition module 310 is used to acquire the original image.
[0099] The preprocessing module 320 is used to preprocess the original image using an image segmentation model to obtain a processed image; wherein the processed image is an image obtained by identifying images corresponding to objects of different categories from the original image.
[0100] The training sample generation module 330 is used to generate training samples according to the original image and the processed image; wherein each image in the training sample is annotated with a neatness classification result.
[0101] The training module 340 is used to input the training samples into the neatness detection model to be trained to obtain a trained neatness detection model.
[0102] In one embodiment, the image segmentation model stores feature information corresponding to preset categories of items. The preprocessing module 320 is further configured to identify images corresponding to different categories of items from the original image based on the feature information corresponding to the preset categories of items to obtain a processed image.
[0103] In one embodiment, the image segmentation model also stores specific pixel values corresponding to preset category items. The preprocessing module 320 is also used to obtain the specific pixel values corresponding to the identified categories of items and the preset category items; determine the specific pixel values corresponding to the identified categories of items according to the specific pixel values corresponding to the identified categories of items and the preset category items; replace the original pixel values of the identified categories of items with the specific pixel values corresponding to the identified categories of items to obtain a processed image.
[0104] In one embodiment, the image segmentation model is a FastSAM model.
[0105] In one embodiment, the training device for the neatness detection model further includes a lightweight processing module. The lightweight processing module is used to perform lightweight processing on the trained neatness detection model to obtain a lightweight neatness detection model.
[0106] In one embodiment, the lightweight processing includes lightweight processing of weight parameters. The weight parameters are model parameters that have been optimized and are to be quantized in the trained neatness detection model.
[0107] The lightweight processing module is used to obtain the weight parameters to be quantized and the number of bits of the scaled floating-point number of the trained neatness detection model; determine the scaling factor of the weight parameters to be quantized according to the maximum value of the weight parameters to be quantized, the minimum value of the weight parameters to be quantized and the number of bits of the scaled floating-point number; determine the quantized weight parameters according to the weight parameters to be quantized and the scaling factor of the weight parameters to be quantized; replace the weight parameters to be quantized with the quantized weight parameters to obtain the lightweight neatness detection model.
[0108] In one embodiment, lightweight processing includes lightweight processing of input data, and the input data is the input data of each layer to be quantized in the trained neatness detection model. The lightweight processing module is used to input at least one original image into the trained neatness detection model, and based on each layer to be quantized, obtain the maximum value of the input data of the corresponding layer, the minimum value of the input data of the corresponding layer, and the number of bits of the scaled floating point number; according to the maximum pixel value of the input data, the minimum pixel value of the input data, and the number of bits of the scaled floating point number, determine the scaling factor of the input data of the corresponding layer when performing neatness detection based on the trained neatness detection model; according to the scaling factors of the input data of each corresponding layer, obtain a lightweight neatness detection model.
[0109] An embodiment of the present invention provides an electronic device, such as Figure 4 The electronic device 400 includes a memory 420 and a processor 410. The memory 420 stores a computer program, and the computer program is used to control the processor 410 to operate to execute the training method of the neatness detection model in any of the above embodiments.
[0110] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For the device embodiment, its related parts can be referred to the partial description of the method embodiment.
[0111] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0112] The embodiments of the present specification may be systems, methods and / or computer program products. The computer program product may include a computer-readable storage medium carrying computer instructions for causing a processor to implement various aspects of the embodiments of the present specification.
[0113] A computer-readable storage medium may be a tangible device that can hold and store computer instructions used by a computer instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which computer instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0114] The computer instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device through a network layer, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network layer may include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network layer adapter card or network layer interface in each computing / processing device receives the computer instructions from the network layer and forwards the computer instructions for storage in a computer-readable storage medium in each computing / processing device.
[0115] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to the multiple embodiments of this specification. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a computer instruction, and a part of a module, a program segment or a computer instruction contains one or more executable computer instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0116] The embodiments of the present specification have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations are obvious to those of ordinary skill in the art without departing from the scope of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A training method for a neatness detection model, characterized in that: include: Get the original image; Using an image segmentation model, preprocessing the original image to obtain a processed image; wherein the processed image is an image in which images corresponding to objects of different categories are identified from the original image; Generating training samples according to the original image and the processed image; wherein each image in the training sample is annotated with a neatness classification result; The training samples are input into the neatness detection model to be trained to obtain a trained neatness detection model.
2. The method according to claim 1, characterized in that The image segmentation model stores feature information corresponding to items of a preset category; wherein The method of preprocessing the original image using the image segmentation model to obtain a processed image includes: According to the feature information corresponding to the preset category of objects, images corresponding to objects of different categories are identified from the original image to obtain a processed image.
3. The method according to claim 2, characterized in that The image segmentation model also stores specific pixel values corresponding to preset category items; wherein, The step of identifying images corresponding to objects of different categories from the original image according to the images corresponding to the preset categories of objects to obtain processed images includes: Obtaining specific pixel values corresponding to each category of identified objects and the preset category of objects; Determine the specific pixel value corresponding to each category of the identified objects according to the specific pixel values corresponding to each category of the identified objects and the preset category of objects; The original pixel values of the identified objects of each category are replaced by the specific pixel values corresponding to the identified objects of each category to obtain a processed image.
4. The method according to any one of claims 1 to 3, characterized in that: The image segmentation model is a FastSAM model.
5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The trained neatness detection model is lightweighted to obtain a lightweight neatness detection model.
6. The method according to claim 5, characterized in that The lightweight processing includes lightweight processing of weight parameters, and the weight parameters are model parameters that have been optimized and to be quantized in the trained neatness detection model; wherein, The step of performing lightweight processing on the trained neatness detection model to obtain a lightweight neatness detection model includes: Obtaining the weight parameters to be quantized and the number of bits of the scaled floating-point number of the trained neatness detection model; Determining a scaling factor of the weight parameter to be quantized according to the maximum value of the weight parameter to be quantized, the minimum value of the weight parameter to be quantized, and the number of bits of the scaled floating-point number; Determining a quantized weight parameter according to the weight parameter to be quantized and a scaling factor of the weight parameter to be quantized; The quantized weight parameters are used to replace the weight parameters to be quantized, so as to obtain the lightweight neatness detection model.
7. The method according to claim 5, characterized in that The lightweight processing includes lightweight processing of input data, and the input data is the input data of each layer to be quantized in the trained neatness detection model; wherein, The step of performing lightweight processing on the trained neatness detection model to obtain a lightweight neatness detection model includes: Input at least one original image into the trained neatness detection model, and obtain the maximum value of the input data of the corresponding layer, the minimum value of the input data of the corresponding layer, and the number of bits of the scaled floating-point number based on each layer to be quantized; Determine, according to the maximum pixel value of the input data, the minimum pixel value of the input data and the number of bits of the scaled floating-point number, a scaling factor of the input data of the corresponding layer when performing neatness detection based on the trained neatness detection model; According to the scaling factor of the input data of each corresponding layer, a lightweight neatness detection model is obtained.
8. The method according to claim 6 or 7, characterized in that: The method further comprises: Acquire the image to be detected; The lightweight neatness detection model is used to perform classification detection processing on the image to be detected to obtain a classification result.
9. A training device for a neatness detection model, characterized in that: include: An acquisition module, used for acquiring the original image; A preprocessing module, used to preprocess the original image using an image segmentation model to obtain a processed image; wherein the processed image is an image in which images corresponding to objects of different categories are identified from the original image; A training sample generation module, used to generate training samples according to the original image and the processed image; wherein each image in the training sample is annotated with a neatness classification result; The training module is used to input the training samples into the neatness detection model to be trained to obtain a trained neatness detection model.
10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the computer program is used to control the processor to operate so as to execute the training method of the neatness detection model according to any one of claims 1 to 8.