A clothes detection method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202411654363.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2044-11-19
AI Technical Summary
[0003]通过人工检测衣物的属性信息,效率和准确度较低,成本大
[0044] The embodiments of this application include at least the following beneficial effects: The clothing detection method, apparatus, electronic device, and storage medium provided in this application acquire an image of the clothing to be detected, acquire a clothing detection model, and output clothing detection results based on the clothing image using the clothing detection model. This application can achieve automatic clothing detection using the clothing detection model, improving the efficiency and accuracy of clothing detection.
Smart Images

Figure CN119723102B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a clothes detection method and device, electronic equipment and storage medium. BACKGROUND
[0002] In daily life, since clothes are flexible items, they are prone to wrinkles or uneven folding when folded. Therefore, people have a demand for using clothes folding machines. Existing clothes folding machines fold clothes according to clothes attribute information, so it is necessary to manually detect and identify clothes to obtain clothes attribute information and input the clothes attribute information into the clothes folding machine.
[0003] The efficiency and accuracy of manually detecting clothes attribute information are low, and the cost is high. SUMMARY
[0004] The main purpose of the embodiments of the present application is to provide a clothes detection method, device, electronic equipment and storage medium, which can realize automatic clothes detection and improve the efficiency and accuracy of clothes detection.
[0005] In one aspect, the present application provides a clothes detection method, which comprises the following steps:
[0006] Obtaining a clothes image to be detected;
[0007] Obtaining a clothes detection model;
[0008] Using the clothes detection model to output a clothes detection result according to the clothes image to be detected.
[0009] In some embodiments, the clothes detection model is obtained, specifically comprising:
[0010] Constructing a capsule network model;
[0011] Obtaining a sample data set; the sample data set comprises a plurality of clothes detection images with clothes attribute labels;
[0012] Using the sample data set to train and optimize the capsule network model to obtain the corresponding clothes detection model.
[0013] In some embodiments, the clothes detection model is obtained by using the sample data set to train and optimize the capsule network model, specifically comprising:
[0014] Dividing the sample data set to determine a validation set and a plurality of batch training sets;
[0015] inputting each batch training set into the capsule network model in sequence, performing image feature learning by using the capsule network model, determining a plurality of active capsules in the capsule network model, and calculating relative entropy corresponding to each active capsule;
[0016] performing parameter optimization on the capsule network model according to the relative entropy corresponding to each active capsule in the capsule network model, and obtaining a corresponding clothes detection model;
[0017] performing model evaluation on the clothes detection model by using the verification set, determining a model evaluation result, and determining whether to stop training the clothes detection model according to the model evaluation result.
[0018] In some embodiments, the clothes detection model comprises a first feature extraction module, a second feature extraction module, and a third feature extraction module, and the clothes detection model is used to output a clothes detection result according to the to-be-detected clothes image, specifically including:
[0019] inputting the to-be-detected clothes image into the clothes detection model, performing image feature extraction on the to-be-detected clothes image by using the first feature extraction module, and outputting a corresponding first clothes detection feature image;
[0020] passing the first clothes detection feature image to the second feature extraction module, performing image feature extraction on the first clothes detection feature image by using the second feature extraction module, and outputting a corresponding image feature vector and a second clothes detection feature image corresponding to the image feature vector;
[0021] inputting the image feature vector and the second clothes detection feature image into the third feature extraction module, performing image local feature extraction and image local feature integration by using the third feature extraction module, and outputting a clothes detection image feature vector and a clothes detection result image corresponding to the clothes detection image feature vector.
[0022] In some embodiments, the inputting each batch training set into the capsule network model in sequence, performing image feature learning by using the capsule network model, determining a plurality of active capsules in the capsule network model, and calculating relative entropy corresponding to each active capsule, specifically includes:
[0023] sorting each batch training set to determine a sorting list, and obtaining a batch training set ranked first in the sorting list as a current training set;
[0024] constructing an active capsule array set;
[0025] determine a plurality of the active capsules from a plurality of feature extraction capsules contained in the capsule network model, wherein the active capsules output a current feature vector corresponding to the current training set, and a norm of the feature vector after normalization is greater than a given activation threshold;
[0026] calculate a feature vector probability distribution center value of each of the active capsules corresponding to the current training set according to the current feature vector of each of the active capsules;
[0027] obtain a capsule identifier of each of the active capsules, bind the current training set, the capsule identifier of each of the active capsules, and the feature vector probability distribution center value corresponding to each of the active capsules, and store to the active capsule array set;
[0028] when it is determined that the current training set is not the last batch training set in the ranking list, obtain a next batch training set as the current training set, and then return to the step of training the capsule network model using the current training set to determine a plurality of the active capsules from a plurality of feature extraction capsules contained in the capsule network model, until it is determined that the current training set is the last batch training set in the ranking list;
[0029] when it is determined that the current training set is the last batch training set in the ranking list, for each of the batch training sets, determine a plurality of the active capsules corresponding to the batch training set and the feature vector probability distribution center value corresponding to the batch training set from the active capsule array set, obtain a historical feature vector probability distribution mean value corresponding to the active capsule, and calculate the relative entropy of each of the active capsules corresponding to the batch training set according to the historical feature vector probability distribution mean value of each of the active capsules and the feature vector probability distribution center value corresponding to the batch training set.
[0030] In some embodiments, the parameter optimization of the capsule network model according to the relative entropy of each of the active capsules corresponding to the capsule network model obtains a corresponding clothes detection model, and specifically includes:
[0031] for each of the batch training sets, determine a plurality of the active capsules corresponding to the batch training set, and obtain the relative entropy of each of the active capsules corresponding to the batch training set;
[0032] obtain a loss function;
[0033] perform parameter optimization of the capsule network model using the loss function according to the relative entropy of the active capsules corresponding to the batch training set.
[0034] In some embodiments, the step of evaluating the clothing detection model using the validation set, determining the model evaluation result, and determining whether to stop training the clothing detection model based on the model evaluation result specifically includes:
[0035] Obtain multiple model evaluation metrics;
[0036] The clothing detection model is evaluated using the validation set to determine the model evaluation value corresponding to each of the model evaluation indicators.
[0037] When the model evaluation values corresponding to each of the model evaluation metrics all exceed the given evaluation pass threshold, training of the clothing detection model is stopped; otherwise, training of the clothing detection model continues.
[0038] On the other hand, embodiments of this application propose a clothing detection device, the device comprising:
[0039] The first module is used to acquire images of the clothing to be detected;
[0040] The second module is used to obtain the clothing detection model;
[0041] The third module is used to output clothing detection results based on the clothing detection model and the clothing image to be detected.
[0042] On the other hand, embodiments of this application propose an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the clothing detection method described above.
[0043] On the other hand, embodiments of this application propose a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned clothing detection method.
[0044] The embodiments of this application include at least the following beneficial effects: The clothing detection method, apparatus, electronic device, and storage medium provided in this application acquire an image of the clothing to be detected, acquire a clothing detection model, and output clothing detection results based on the clothing image using the clothing detection model. This application can achieve automatic clothing detection using the clothing detection model, improving the efficiency and accuracy of clothing detection. Attached Figure Description
[0045] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 This is a flowchart of a clothing detection method provided in an embodiment of this application;
[0048] Figure 2 This is a schematic diagram of the capsule network model in the embodiments of this application;
[0049] Figure 3 This is a schematic diagram of the structure of a clothing detection device provided in an embodiment of this application;
[0050] Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.
[0052] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”
[0053] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0055] Before providing a detailed description of the embodiments of this application, some of the nouns and terms involved in the embodiments of this application will be explained first. The nouns and terms involved in the embodiments of this application are subject to the following interpretations.
[0056] 1) Capsule Model: The Capsule model, also known as the Capsule Network, aims to address the problems existing in traditional Convolutional Neural Networks (CNNs), especially the limitations of information loss and feature extraction.
[0057] 2) CNN Model: The CNN (Convolutional Neural Network) model is a feedforward artificial neural network particularly suitable for processing data with a grid structure. It is widely used in computer vision problems such as image classification. The core of CNN is to extract and learn the features of the data through convolutional layers, pooling layers, and fully connected layers. The convolutional layer extracts local features by performing convolution operations on the input data by sliding a small window (convolutional kernel).
[0058] 3) CapsNet Architecture: CapsNet is a deep learning model proposed by Geoffrey Hinton and his team, designed to address some limitations of traditional convolutional neural networks (CNNs) in image recognition, such as neglecting relative positional information and losing details. CapsNet improves feature representation by using a capsule structure and handles the relationships between features through a dynamic routing algorithm.
[0059] Reference Figure 1 , Figure 1 This is an optional flowchart of a clothing detection method provided in an embodiment of this application. The method may include, but is not limited to, steps S101 to S103:
[0060] Step S101: Obtain an image of the clothing to be detected;
[0061] Step S102: Obtain the clothing detection model;
[0062] Step S103: Using the clothing detection model, output the clothing detection result based on the image of the clothing to be detected.
[0063] In some embodiments, step S102 may include, but is not limited to, steps S201 to S203:
[0064] Step S201: Construct the capsule network model;
[0065] Step S202: Obtain the sample dataset; the sample dataset includes multiple clothing detection images with clothing attribute labels;
[0066] Step S203: Use the sample dataset to train and optimize the capsule network model to obtain the corresponding clothing detection model.
[0067] In some embodiments, the Capsule Network model is built upon the CapsNet architecture, including CNN models and Capsule models. The basic unit of the Capsule model is a "capsule" instead of a traditional neuron. Each capsule contains multiple neurons and represents features as vectors, where the magnitude of the vector represents the importance of the feature. Unlike traditional neural networks, the Capsule model transmits information through vector transformations and dynamic routing mechanisms, rather than simple weighted summation. This design allows the Capsule model to better handle image transformations such as rotation and scaling, and to better capture the relationships between substructures.
[0068] Optionally, refer to Figure 2 , Figure 2 This is an optional structural diagram of the capsule network model in this application embodiment, which includes a lightweight neural network EfficientNetV2, a Primary Caps Layer, and a Capsule model. The Capsule model includes two Capsule Layers. The first Capsule Layer 1 is used to extract local image features, and the second Capsule Layer 2 is used to integrate and learn the local image features extracted by the first Capsule Layer 1. The image of the clothing to be detected is input into the capsule network model, and forward propagation calculation is performed on the image of the clothing to be detected. The calculation is passed in the order of lightweight neural network - Primary Caps Layer - Capsule model, and finally the corresponding clothing detection result is output.
[0069] Lightweight neural networks, including but not limited to CNN models such as EfficientNetV2, output a vector instead of a traditional scalar value. This vector contains information about the location and pose of the detected object. The Capsule Layer is a crucial component of the capsule model. It contains multiple capsules, each receiving input from the previous layer and processing it through an affine transformation and a non-linear activation function (such as the squashing function), ultimately outputting a vector. This vector contains not only a representation of the features but also their spatial location information, enabling the capsule model to better handle image rotation and deformation, thus improving the network's robustness.
[0070] The Primary Caps Layer is an important component of the CapsNet architecture. It typically consists of multiple neurons, each responsible for detecting a specific region in the image. These neurons output a vector, rather than a traditional scalar value, which contains information about the location, pose, and other information of the detected object.
[0071] In some embodiments, specifically, the Primary Caps Layer in the capsule network model described above, compared with the traditional Primary Caps Layer, removes the original convolution calculation and directly transforms the feature image output by the lightweight neural network. For example, if the number of channels (dim) of the feature vector output by each capsule in the Capsule Layer is set to 8, then the channel dimension (channel dim) of the feature image output by the previous lightweight neural network is divided into groups of 8, and each group is combined to form the dim of the capsule.
[0072] In some embodiments, step S203 may include, but is not limited to, steps S301 to S304:
[0073] Step S301: Divide the sample dataset to determine the validation set and multiple batch training sets;
[0074] Step S302: Input each batch of training sets into the capsule network model in sequence, use the capsule network model to learn image features, determine multiple active capsules in the capsule network model and calculate the relative entropy corresponding to each active capsule;
[0075] Step S303: Optimize the parameters of the capsule network model based on the relative entropy of each activated capsule in the capsule network model to obtain the corresponding clothing detection model.
[0076] Step S304: Use the validation set to evaluate the clothing detection model, determine the model evaluation results, and determine whether to stop training the clothing detection model based on the model evaluation results.
[0077] In some embodiments, the sample dataset includes multiple clothing detection images labeled with clothing attribute information. The clothing attribute information may include, but is not limited to, the color, type, and material of the clothing. Colors include black, white, red, green, etc., types include shirts, casual pants, jeans, etc., and materials include plush, synthetic fibers, silk, etc.
[0078] In some embodiments, step S302 may include, but is not limited to, steps S401 to S407:
[0079] Step S401: Sort the training sets of each batch, determine the sorting list, and obtain the training set of the batch with the highest ranking in the sorting list as the current training set;
[0080] Step S402: Construct a set of activated capsule arrays;
[0081] Step S403: Train the capsule network model using the current training set, and determine several activation capsules from the multiple feature extraction capsules contained in the capsule network model. The output of the activation capsule corresponds to the current feature vector of the current training set, and the normalized modulus of the feature vector is greater than a given activation threshold.
[0082] Step S404: Calculate the center value of the probability distribution of the feature vector of each activated capsule corresponding to the current training set based on the current feature vector of each activated capsule.
[0083] Step S405: Obtain the capsule identifier of each activation capsule, bind the current training set, the capsule identifier of each activation capsule and the center value of the probability distribution of the feature vector corresponding to each activation capsule, and store them in the activation capsule array set;
[0084] Step S406: When it is determined that the current training set is not the last batch training set in the sorting list, the next batch training set is obtained as the current training set, and then the process returns to step S403 until it is determined that the current training set is the last batch training set in the sorting list.
[0085] Step S407: When it is determined that the current training set is the last batch training set in the sorting list, for each batch training set, determine multiple activation capsules corresponding to the batch training set and the center value of the probability distribution of the feature vector corresponding to the batch training set from the set of activation capsule arrays, obtain the mean of the historical feature vector probability distribution corresponding to the activation capsule, and calculate the relative entropy of each activation capsule corresponding to the batch training set based on the mean of the historical feature vector probability distribution of each activation capsule and the center value of the probability distribution of the feature vector corresponding to the batch training set.
[0086] In some embodiments, the capsule network model is trained using the current training set. The feature extraction capsule extracts local features from the feature image and outputs the corresponding current feature vector. The current feature vector is normalized, and the modulus of the normalized current feature vector is calculated. When the modulus is greater than a given activation threshold, such as 0.5, the feature extraction capsule is determined as the activation capsule under the current training set.
[0087] In some embodiments, the capsule network model is trained using each batch of training sets, and the center value of the probability distribution of the feature vectors corresponding to each batch of training sets for each feature extraction capsule (such as the capsule mentioned above) is stored. After the capsule network model is trained using each batch of training sets, the mean value of the historical feature vector probability distribution corresponding to each feature extraction capsule (such as the capsule mentioned above) is calculated based on the center value of the probability distribution of the feature vectors corresponding to each batch of training sets. Optionally, the mean value of the historical feature vector probability distribution is calculated using the following formula:
[0088]
[0089] Among them, Q j (x) represents the mean of the probability distribution of the historical feature vector corresponding to the j-th feature extraction capsule, P j,k (x) represents the center value of the probability distribution of the feature vector of the j-th feature extraction capsule corresponding to the k-th batch training set, and n is the number of batch training sets.
[0090] In some embodiments, step S303 may include, but is not limited to, steps S501 to S503:
[0091] Step S501: For each batch of training sets, determine the multiple activation capsules corresponding to the batch training set, and obtain the relative entropy of each activation capsule corresponding to the batch training set.
[0092] Step S502, obtain the loss function;
[0093] Step S503: Based on the relative entropy of the activated capsules corresponding to the batch training set, optimize the parameters of the capsule network model using the loss function.
[0094] In some embodiments, the relative entropy is the KL distance, also known as the KL divergence or relative entropy, which is defined as the amount of information loss caused when approximating distribution p with distribution q. Optionally, the relative entropy of each activated capsule is calculated by the following formula:
[0095]
[0096] Among them, D i (P / Q) is the relative entropy of the i-th activated capsule in the batch training set, P i (x) is the center value of the probability distribution of the feature vector of the i-th activated capsule, Q. i (x) represents the mean of the historical feature vector probability distribution of the i-th activated capsule.
[0097] The loss function (Loss) is calculated using the following formula:
[0098]
[0099] Where S is the number of activated capsules in the batch training set. Based on the relative entropy of each activated capsule in the batch training set, the mean relative entropy of the batch training set is calculated, i.e., Loss. The Loss is then passed to the capsule network model for parameter optimization.
[0100] In some embodiments, step S304 may include, but is not limited to, steps S601 to S603:
[0101] Step S601: Obtain multiple model evaluation metrics;
[0102] Step S602: Use the validation set to evaluate the clothing detection model and determine the model evaluation value corresponding to each model evaluation index.
[0103] Step S603: When the model evaluation values corresponding to each model evaluation index all exceed the given evaluation qualification threshold, stop training the clothing detection model; otherwise, continue training the clothing detection model.
[0104] In some embodiments, model evaluation metrics may include, but are not limited to, accuracy, precision, recall, and F1 score.
[0105] In some embodiments, step S103 may include, but is not limited to, steps S701 to S703:
[0106] Step S701: Input the image of the clothing to be detected into the clothing detection model, use the first feature extraction module to extract image features from the image of the clothing to be detected, and output the corresponding first clothing detection feature image.
[0107] Step S702: The first clothing detection feature image is passed to the second feature extraction module. The second feature extraction module is used to extract image features from the first clothing detection feature image and outputs the corresponding image feature vector and the second clothing detection feature image corresponding to the image feature vector.
[0108] Step S703: Input the image feature vector and the second clothing detection feature image into the third feature extraction module, and use the third feature extraction module to perform local image feature extraction and local image feature integration, and output the clothing detection image feature vector and the clothing detection result image corresponding to the clothing detection image feature vector.
[0109] In some embodiments, the first feature extraction module is a lightweight neural network, such as EfficientNetV2 mentioned above, the second feature extraction module is the Primary Caps Layer mentioned above, and the third feature extraction module is the Capsule model mentioned above. The Capsule model includes two Capsule Layers. The first Capsule Layer is used to extract local features of the image, and the second Capsule Layer is used to integrate local features of the image.
[0110] In some embodiments, the above-described clothing detection method has the following advantages compared to the prior art:
[0111] 1) Effectively improves the recognition accuracy of high-speed networks by combining the Capsule model with a lightweight neural network, thereby improving the accuracy of clothing detection;
[0112] 2) By calculating the relative entropy of the activated capsules, the parameters of the capsule network model are optimized, making the model more effective at converging to the features that affect the final result, effectively escaping local minima, and improving the effectiveness of model training and the detection accuracy of the model.
[0113] 3) The introduction of the Capsule model can appropriately reduce the size of the CNN model, improving inference speed without affecting the network model's detection efficiency, thus increasing the model's inference speed.
[0114] Reference Figure 3 , Figure 3 This is an optional structural diagram of a clothing detection device provided in an embodiment of this application. This device can be used to implement the aforementioned clothing detection method and may include:
[0115] The first module is used to acquire images of the clothing to be detected;
[0116] The second module is used to obtain the clothing detection model;
[0117] The third module is used to output clothing detection results based on the clothing image to be detected using a clothing detection model.
[0118] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0119] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described clothing detection method. This electronic device can be any smart terminal, including a tablet computer.
[0120] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0121] Please see Figure 4 , Figure 4 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:
[0122] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0123] The memory 902 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the clothing detection method of the embodiments of this application.
[0124] The input / output interface 903 is used to implement information input and output;
[0125] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0126] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);
[0127] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.
[0128] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described clothing detection method.
[0129] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0130] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0131] This application provides a clothing detection method, apparatus, electronic device, and storage medium. It acquires an image of the clothing to be detected, obtains a clothing detection model, and uses the clothing detection model to output clothing detection results based on the image. This application enables automatic clothing detection using the clothing detection model, improving the efficiency and accuracy of clothing detection.
[0132] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0133] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0134] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0135] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0136] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0137] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0138] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0139] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0140] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0141] It should be recognized that embodiments of the present invention can be implemented or carried out by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer-readable storage medium. The method can be implemented in a computer program using standard programming techniques, including a non-transitory computer-readable storage medium configured with a computer program, wherein the storage medium is configured such that the computer operates in a specific and predefined manner—according to the methods and drawings described in the specific embodiments. Each program can be implemented in a high-level procedural or object-oriented programming language to communicate with the computer system. However, if desired, the program can be implemented in assembly or machine language. In any case, the language can be a compiled or interpreted language. Furthermore, for this purpose, the program can run on a programmed application-specific integrated circuit (ASIC).
[0142] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0143] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for detecting clothing, characterized in that, The method includes the following steps: Acquire an image of the clothing to be inspected; Construct a capsule network model; Obtain a sample dataset; the sample dataset includes multiple clothing detection images with clothing attribute labels; The sample dataset is divided to determine a validation set and multiple batch training sets; Each batch of training sets is sequentially input into the capsule network model, and the capsule network model is used to learn image features, determine multiple active capsules in the capsule network model, and calculate the relative entropy corresponding to each active capsule. Based on the relative entropy corresponding to each activated capsule in the capsule network model, the parameters of the capsule network model are optimized to obtain the corresponding clothing detection model; The clothing detection model is evaluated using the validation set, the evaluation result is determined, and it is determined whether to stop training the clothing detection model based on the evaluation result. The clothing detection model is used to output clothing detection results based on the image of the clothing to be detected; The step of sequentially inputting each batch of training sets into the capsule network model, using the capsule network model to learn image features, determining multiple active capsules in the capsule network model, and calculating the relative entropy corresponding to each active capsule specifically includes: Sort the training sets in each batch to determine a sorting list, and obtain the training set at the top of the sorting list as the current training set. Construct a collection of activated capsule arrays; The capsule network model is trained using the current training set, and several activation capsules are determined from the multiple feature extraction capsules contained in the capsule network model. The activation capsules output the current feature vector corresponding to the current training set, and the normalized modulus of the feature vector is greater than a given activation threshold. Based on the current feature vector of each activation capsule, calculate the center value of the probability distribution of the feature vector of each activation capsule corresponding to the current training set; Obtain the capsule identifier of each activation capsule, bind the current training set, the capsule identifier of each activation capsule, and the center value of the probability distribution of the feature vector corresponding to each activation capsule, and store them in the activation capsule array set; When it is determined that the current training set is not the last batch training set in the sorting list, the next batch training set is obtained as the current training set, and then the process of training the capsule network model using the current training set is repeated until the current training set is determined to be the last batch training set in the sorting list. When the current training set is determined to be the last batch training set in the sorting list, for each batch training set, multiple activation capsules corresponding to the batch training set and the center value of the probability distribution of the feature vector corresponding to the batch training set are determined from the set of activation capsule arrays. The mean value of the historical feature vector probability distribution corresponding to the activation capsule is obtained. Based on the mean value of the historical feature vector probability distribution of each activation capsule and the center value of the probability distribution of the feature vector corresponding to the batch training set, the relative entropy of each activation capsule corresponding to the batch training set is calculated.
2. The clothing detection method according to claim 1, characterized in that, The clothing detection model includes a first feature extraction module, a second feature extraction module, and a third feature extraction module. The step of using the clothing detection model to output clothing detection results based on the clothing image to be detected specifically includes: The clothing image to be detected is input into the clothing detection model, and the first feature extraction module is used to extract image features from the clothing image to be detected, and the corresponding first clothing detection feature image is output. The first clothing detection feature image is transmitted to the second feature extraction module, and the second feature extraction module is used to extract image features from the first clothing detection feature image, and outputs the corresponding image feature vector and the second clothing detection feature image corresponding to the image feature vector. The image feature vector and the second clothing detection feature image are input to the third feature extraction module. The third feature extraction module is used to extract local image features and integrate local image features, and outputs the clothing detection image feature vector and the clothing detection result image corresponding to the clothing detection image feature vector.
3. The clothing detection method according to claim 1, characterized in that, The step of optimizing the parameters of the capsule network model based on the relative entropy corresponding to each activated capsule in the capsule network model to obtain the corresponding clothing detection model specifically includes: For each batch of training sets, determine a plurality of activation capsules corresponding to the batch of training sets, and obtain the relative entropy of each activation capsule corresponding to the batch of training sets; Obtain the loss function; Based on the relative entropy of the activated capsule corresponding to the batch training set, the parameters of the capsule network model are optimized using the loss function.
4. The clothing detection method according to claim 1, characterized in that, The step of evaluating the clothing detection model using the validation set, determining the model evaluation result, and determining whether to stop training the clothing detection model based on the model evaluation result specifically includes: Obtain multiple model evaluation metrics; The clothing detection model is evaluated using the validation set to determine the model evaluation value corresponding to each of the model evaluation indicators. When the model evaluation values corresponding to each of the model evaluation metrics all exceed the given evaluation pass threshold, training of the clothing detection model is stopped; otherwise, training of the clothing detection model continues.
5. A clothing detection device, characterized in that, The device includes: The first module is used to acquire images of the clothing to be detected; The second module is used to construct a capsule network model, obtain a sample dataset, which includes multiple clothing detection images with clothing attribute labels, divide the sample dataset to determine a validation set and multiple batch training sets, input each batch training set into the capsule network model in sequence, use the capsule network model to learn image features, determine multiple active capsules in the capsule network model and calculate the relative entropy corresponding to each active capsule, optimize the parameters of the capsule network model according to the relative entropy corresponding to each active capsule in the capsule network model to obtain the corresponding clothing detection model, use the validation set to evaluate the clothing detection model, determine the model evaluation result, and determine whether to stop training the clothing detection model based on the model evaluation result. The third module is used to output clothing detection results based on the clothing detection model and the clothing image to be detected. The step of sequentially inputting each batch of training sets into the capsule network model, using the capsule network model to learn image features, determining multiple active capsules in the capsule network model, and calculating the relative entropy corresponding to each active capsule specifically includes: Sort the training sets in each batch to determine a sorting list, and obtain the training set at the top of the sorting list as the current training set. Construct a collection of activated capsule arrays; The capsule network model is trained using the current training set, and several activation capsules are determined from the multiple feature extraction capsules contained in the capsule network model. The activation capsules output the current feature vector corresponding to the current training set, and the normalized modulus of the feature vector is greater than a given activation threshold. Based on the current feature vector of each activation capsule, calculate the center value of the probability distribution of the feature vector of each activation capsule corresponding to the current training set; Obtain the capsule identifier of each activation capsule, bind the current training set, the capsule identifier of each activation capsule, and the center value of the probability distribution of the feature vector corresponding to each activation capsule, and store them in the activation capsule array set; When it is determined that the current training set is not the last batch training set in the sorting list, the next batch training set is obtained as the current training set, and then the process of training the capsule network model using the current training set is repeated until the current training set is determined to be the last batch training set in the sorting list. When the current training set is determined to be the last batch training set in the sorting list, for each batch training set, multiple activation capsules corresponding to the batch training set and the center value of the probability distribution of the feature vector corresponding to the batch training set are determined from the set of activation capsule arrays. The mean value of the historical feature vector probability distribution corresponding to the activation capsule is obtained. Based on the mean value of the historical feature vector probability distribution of each activation capsule and the center value of the probability distribution of the feature vector corresponding to the batch training set, the relative entropy of each activation capsule corresponding to the batch training set is calculated.
6. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the clothing detection method according to any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the clothing detection method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Clothing classification method and system based on capsule network
CN113205061A