Weather period classification method, system, device and storage medium

By combining the cross entropy loss function and the focal loss loss function in the weather period classification model for training, the accuracy of image classification in mixed scenarios is solved, and efficient image annotation and screening is achieved.

CN112183673BActive Publication Date: 2025-04-08CTRIP COMP TECH SHANGHAI
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202011228586.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-06
Publication Date
2025-04-08
Estimated Expiration
2040-11-06

AI Technical Summary

Technical Problem

The prior art is difficult to accurately classify images in mixed scenarios, especially those in weather-period scenes, and requires manual intervention.

Method used

Using a weather period classification model based on deep learning, combined with cross entropy loss function and focal loss function for training, can classify images more accurately in mixed scenarios.

Benefits of technology

It realizes more accurate image classification in mixed scenarios, reduces the cost of manual annotation, improves the efficiency of image annotation, and can better screen and display high-quality images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112183673B_ABST
    Figure CN112183673B_ABST
Patent Text Reader

Abstract

The present invention provides a weather period classification method, system, device and storage medium, the method comprising: constructing a weather period classification model based on deep learning, the input of the weather period classification model is an image to be classified, and the output is a weather period classification result; inputting sample images in a training set into the weather period classification model, and obtaining the weather period classification results of each sample image output; training the weather period classification model based on a cross entropy loss function and a focal loss loss function according to the label category of the sample image and the weather period classification result output by the weather period classification model; inputting the image to be classified into the trained weather period classification model, and obtaining the output weather period classification result. The present invention combines different loss functions to train the classification model, and can obtain more accurate classification results in mixed scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] With the development of science and technology, various forms of information, including images, have experienced explosive growth. Taking the travel guide scene of a travel platform as an example, a large number of images uploaded by users or merchants are added every day, and a large number of images are accumulated in the gallery. These images are uneven and disorganized. It is impossible to process such a large amount of data manually, which makes these images difficult to use. Although some automatic image processing methods have appeared in the prior art, one or several labels are added to the image based on the image content information, and then filtered and screened according to the labels, which greatly improves the utilization efficiency of these images. However, the existing methods are generally aimed at specific scenes and cannot be well applied to mixed scenes. For example, when images of weather period scenes are mixed with images of other categories, it is difficult to distinguish them, and it is still necessary to manually classify and mark the scenes. Summary of the invention

[0003] In response to the problems in the prior art, the purpose of the present invention is to provide a weather period classification method, system, device and storage medium, which can obtain more accurate classification results in mixed scenarios by combining different loss functions to train classification models.

[0004] The embodiment of the present invention provides a weather period classification method, comprising the following steps:

[0005] Constructing a weather period classification model based on deep learning, wherein the input of the weather period classification model is an image to be classified, and the output is a weather period classification result;

[0006] Inputting the sample images in the training set into the weather period classification model to obtain the weather period classification results of each output sample image;

[0007] According to the label category of the sample image and the weather period classification result output by the weather period classification model, the weather period classification model is trained based on a cross entropy loss function and a focal loss function;

[0008] The image to be classified is input into the trained weather period classification model to obtain the output weather period classification result.

[0009] In some embodiments, the weather period classification model is constructed based on a Wide Resnet50 network, and the output of the classifier includes multiple weather period categories and one non-weather period category.

[0010] In some embodiments, the training of the weather period classification model based on the cross entropy loss function and the focal loss function comprises the following steps:

[0011] For sample images whose label category belongs to the non-weather period category, a focal loss function is used to train the weather period classification model;

[0012] For sample images whose label category belongs to the weather period category, the weather period classification model is trained by combining the cross entropy loss function and the focal loss function.

[0013] In some embodiments, when training the weather period classification model, the weights of the weather period classification model are updated using an iterative strategy of stochastic gradient descent based on momentum.

[0014] In some embodiments, the weather period classification model is constructed based on a convolutional neural network, and different learning rates are used for the convolutional layer and the fully connected layer when training the weather period classification model.

[0015] In some embodiments, before training the weather period classification model, the following steps are also included:

[0016] A pre-trained model based on the public scene classification dataset place365 is used to perform transfer learning on the weather period classification model, and parameter weights except the last fully connected layer in the pre-trained model are loaded into the weather period classification model;

[0017] When training the weather period classification model, the parameters of each layer in the weather period classification model except the fully connected layer are fixed, and the parameters of the fully connected layer in the weather period classification model are trained based on the training set and the constructed loss function.

[0018] In some embodiments, after training the weather period classification model, the following steps are further included:

[0019] Inputting the test images in the test set into the weather period classification model to obtain an output weather period classification result;

[0020] Manually extract the classification results of the weather period to be verified and compare them with the label categories of the test images;

[0021] For the test samples with classification errors, the corresponding positive and negative samples are supplemented, the weight of the cross entropy and the balance factor of the focal loss are updated, and the weather period classification model is retrained.

[0022] In some embodiments, after manually extracting the classification result of the weather period to be verified and comparing it with the label category of the test image, the following steps are also included:

[0023] Determine whether the classification accuracy of the test image is greater than a preset threshold;

[0024] If yes, it is determined that the training of the weather period classification model is completed.

[0025] In some embodiments, after training the weather period classification model, the following steps are further included:

[0026] Package the trained weather period classification model based on the TorchServe model framework;

[0027] The weather period classification model is deployed based on the Flask framework.

[0028] The embodiment of the present invention further provides a weather period classification system, which is used to implement the weather period classification method, and the system includes:

[0029] A model building module, used to build a weather period classification model, the input of the weather period classification model is the image to be classified, and the output is the weather period classification result;

[0030] A model training module, for inputting sample images in a training set into the weather period classification model to obtain the weather period classification results of each sample image output; and training the weather period classification model based on a cross entropy loss function and a focal loss loss function according to the label categories of the sample images and the weather period classification results output by the weather period classification model;

[0031] The image classification module is used to input the image to be classified into the trained weather period classification model to obtain the output weather period classification result.

[0032] The embodiment of the present invention further provides a weather period classification device, including:

[0033] processor;

[0034] a memory storing executable instructions of the processor;

[0035] Wherein, the processor is configured to perform the steps of the weather period classification method by executing the executable instructions.

[0036] An embodiment of the present invention also provides a computer-readable storage medium for storing a program, and when the program is executed, the steps of the weather period classification method are implemented.

[0037] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.

[0038] The weather period classification method, system, device and storage medium of the present invention have the following beneficial effects:

[0039] The present invention is based on a deep learning network model in the field of computer vision and is trained with two different loss functions to obtain more accurate classification results in mixed scenarios. It can not only identify images containing weather time period scenes from images of various scenes, but also further divide the images into specific weather and time period categories. Compared with the traditional manual labeling method, it greatly reduces labor costs and greatly improves the image labeling efficiency, making it easier to screen out more and better quality images for display in subsequent production applications, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Other features, objectives and advantages of the present invention will become more apparent from a reading of the detailed description of non-limiting embodiments made with reference to the following accompanying drawings.

[0041] Figure 1 is a flow chart of a weather period classification method according to an embodiment of the present invention;

[0042] Figure 2 This is a schematic diagram of a weather period classification model service processing flow according to an embodiment of the present invention;

[0043] Figure 3 It is a schematic diagram of the flow of weather period classification model training in a specific example of the present invention;

[0044] Figure 4 is a structural schematic diagram of a weather period classification system according to an embodiment of the present invention;

[0045] Figure 5 is a schematic structural diagram of a weather period classification device according to an embodiment of the present invention;

[0046] Figure 6 It is a schematic diagram of the structure of a computer-readable storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION

[0047] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0048] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0049] like Figure 1 As shown, an embodiment of the present invention provides a weather period classification method, comprising the following steps:

[0050] S100: constructing a weather period classification model based on deep learning, wherein the input of the weather period classification model is an image to be classified, and the output is a weather period classification result;

[0051] In this embodiment, the weather period classification model is constructed based on the Wide Resnet50 network, and the output of the classifier includes labels of N weather period categories and a label of a non-weather period category. Wide ResNet (WRN) improves ResNet (residual network) from the perspective of increasing the network width, and both performance and training speed have been improved. Resnet is the abbreviation of Residual Network. This series of networks is widely used in fields such as target classification and as part of the backbone classical neural network for computer vision tasks. In the Resnet50 network, a convolution operation is first performed on the input, followed by 4 residual blocks (ResidualBlock), and finally a full connection operation is performed to facilitate the classification task.

[0052] S200: inputting sample images in the training set into the weather period classification model to obtain the weather period classification results of each output sample image;

[0053] First, it is necessary to collect sample images for training. A variety of methods can be used to collect image data with N weather period labels and "other" labels. For example, crawler technology can be used to collect and integrate relevant image data accumulated by the tourism platform in the past on the Internet, and integrate some data in the public data sets Image2Weather and MWD that meet the current label definition. N weather period labels may include "sunny", "rainy", "night", "morning", etc. Each weather period label may include a weather category or a time period category. The weather period classification model can be used to simultaneously identify whether the image is a weather-related scene or a time period-related scene. The weather may include sunny, rainy, snowy, etc., and the time period may include morning, noon, evening, night, etc.;

[0054] S300: training the weather period classification model based on a cross entropy loss function and a focal loss function according to the label category of the sample image and the weather period classification result output by the weather period classification model;

[0055] S400: Inputting the image to be classified into the trained weather period classification model, obtaining the output weather period classification result, that is, obtaining the weather period classification label corresponding to the image to be classified.

[0056] In view of the current situation that the existing guide gallery contains a large number of unlabeled images that are difficult to use, the present invention uses a loss function to train a weather period classification model, and can screen out images of weather period scenes from the gallery and label them accordingly, replacing manual labeling. Specifically, the present invention first constructs a weather period classification model through step S100, and the weather period classification model is a deep learning network model based on the field of computer vision. The weather period classification model is trained through steps S200 and S300. In step S300, two different loss functions are combined for training to obtain a trained weather period classification model. In step S400, the image to be classified is input into the trained weather period classification model, so as to obtain a more accurate classification result in a mixed scene. Not only can the image containing the weather period scene be identified from images of various scenes, but the image can also be further divided into specific weather and time categories. Compared with the traditional manual labeling method, the labor cost is greatly reduced, and the image labeling efficiency is greatly improved.

[0057] like Figure 2 and Figure 3As shown, in this embodiment, when training the weather period classification model, after inputting the sample image into the weather period classification model, the loss function of the model is first constructed based on the cross entropy loss function and the focal loss loss function, and the weather period classification model is trained based on the loss function of the model, and the network model is optimized by mixing the two loss functions, and the weight in the cross entropy loss function and the balance factor in the focal loss loss function are set based on the proportion of training samples. Cross entropy is mainly used to measure the difference information between two probability distributions. One advantage of cross entropy as a loss function is that the problem of reduced learning rate of the mean square error loss function can be avoided when the gradient is descended by using the sigmoid function, because the learning rate can be controlled by the output error. The goal of the Focal Loss loss function is to solve problems such as imbalanced sample categories and imbalanced sample classification difficulty. Its main idea is to add suppression parameters one by one, so that when calculating the loss during training, the weights of samples that are easy to classify are suppressed, so that the model can focus on learning to distinguish samples that are not easy to distinguish. Among them, the cross entropy loss function is mainly aimed at the differences between different weather period labels to better distinguish different weather period labels, while the face loss is mainly used to distinguish weather period labels from "other" labels and filter out images with weather period labels from images of mixed scenes.

[0058] In step S300, based on the cross entropy loss function and the focal loss function, the weather period classification model is trained, including the following steps:

[0059] For sample images whose label category belongs to the non-weather period category, a focal loss function is used to train the weather period classification model;

[0060] For sample images whose label category belongs to the weather period category, the weather period classification model is trained by combining the cross entropy loss function and the focal loss function.

[0061] Specifically, the weather period classification model is trained based on the mixture of two loss functions in the following manner:

[0062] For the model output Y = {y1, y2, ..., y N+1}, label weight W = {w1,22,…,2 N}, calculate the cross entropy loss loss between N labels ce :

[0063]

[0064] Where label represents the official label number of the image, which is an integer in the range [1, N].

[0065] Calculate the focal loss of the weather time label and the "other" label, and record the balance factor as A = {α period ,α other}, the concentration parameter is γ, then:

[0066]

[0067] in

[0068] The two hybrid functions are mixed. If the image label is "other", only the focal loss is calculated. If the label is any weather or time period label, the cross entropy loss is also calculated. The final hybrid loss is loss total for:

[0069]

[0070] In this embodiment, when the mixed loss function of the two loss functions is used to train the weather period classification model, the back propagation of the loss adopts an iterative strategy of stochastic gradient descent based on momentum to update the weights of the weather period classification model to prevent jitter and accelerate convergence. The value of the momentum factor momentum can be 0.9, for example, but the present invention is not limited to this. Gradient descent is an optimization method used in machine learning to make the model approach the minimum deviation of the true distribution. The momentum-based stochastic gradient descent method uses V, the exponential moving average of the historical and current gradients, to replace the current gradient to update the weights. V is initialized to 0, and β usually takes a value of 0.9.

[0071] In this embodiment, the weather period classification model is constructed based on a convolutional neural network. When training the weather period classification model, different learning rates are used for the convolutional layer and the fully connected layer.

[0072] like Figure 3 As shown, in this embodiment, before training the weather period classification model, the following steps are also included:

[0073] A pre-trained model based on the public scene classification dataset place365 is used to perform transfer learning on the weather period classification model. The parameter weights of the pre-trained model except the last fully connected layer are loaded into the weather period classification model. Transfer learning is a machine learning method, which refers to a pre-trained model being reused in the newly constructed weather period classification model. Transfer learning can transfer the powerful skills that have been learned to related problems.

[0074] When training the weather period classification model, the parameters of each layer in the weather period classification model except the fully connected layer are fixed, and the parameters of the fully connected layer in the weather period classification model are trained based on the training set and the constructed loss function. When training the weather period classification model, the weather period classification model can be selectively fine-tuned on the input-output pairs in the target data set to adapt it to the target task.

[0075] In this embodiment, after the step S300: training the weather period classification model, the following steps are also included:

[0076] Inputting the test images in the test set into the weather period classification model to obtain an output weather period classification result;

[0077] Manually extract the classification results of the weather period to be verified and compare them with the label categories of the test images;

[0078] For the bad cases of the test samples that are misclassified, the corresponding positive and negative samples are added, the atypical samples are eliminated, the weight of the cross entropy and the balance factor of the focal loss are updated, and the weather period classification model is retrained.

[0079] In the event of a bad case, multiple rounds of data iteration are repeated until the classification accuracy meets the preset threshold requirement. That is, in this embodiment, after manually extracting the classification result of the weather period to be verified and comparing it with the label category of the test image, the following steps are also included:

[0080] Determine whether the classification accuracy of the test image is greater than a preset threshold;

[0081] If yes, it is determined that the weather period classification model training is completed and no further iterative training is performed.

[0082] like Figure 3 As shown, in this embodiment, after training the weather period classification model and determining that the weather period classification model training has been completed according to the manual sampling classification results, the following steps are also included:

[0083] Based on the TorchServe model framework officially launched by the Pytorch framework, the trained weather period classification model is packaged. TorchServe is a flexible and easy-to-use tool for deploying PyTorch models as services. PyTorch is an open source Python machine learning library based on Torch for applications such as natural language processing.

[0084] The weather time classification model is deployed based on the Flask framework. Flask is a lightweight customizable framework written in Python. It is more flexible, lightweight, secure and easy to use than other similar frameworks. It can be well combined with the MVC model for development. Developers can work together and a small team can complete the implementation of feature-rich small and medium-sized websites or Web services in a short time. In addition, Flask is also highly customizable. Users can add corresponding functions according to their needs, enriching and expanding functions while keeping the core functions simple. Its powerful plug-in library allows users to customize their websites and develop powerful websites.

[0085] like Figure 2 As shown, the final weather period classification model can be used to process the massive unlabeled images to be classified in the gallery. The weather period classification model deployed in the TorchServer model server predicts the category of the input image to be classified. The external service interface is defined in the Flask framework. If the classification result is a weather period label, the specific classification label is output. If the classification result is an "other" label, no output is performed. Therefore, the weather period classification model deployed on the TorchServe model server adopts two loss functions for mixed training during training. The cross entropy loss function can handle the classification problem between the classification labels of the weather period, and the focal loss can solve the problem of distinguishing the weather period scene from other scenes, so that the weather period classification model can filter images of irrelevant scenes, accurately identify the weather period category of the relevant scene images, and avoid the interference of non-weather period category images.

[0086] like Figure 4 As shown, an embodiment of the present invention further provides a weather period classification system for implementing the weather period classification method, the system comprising:

[0087] The model building module M100 is used to build a weather period classification model, wherein the input of the weather period classification model is the image to be classified, and the output is the weather period classification result;

[0088] The model training module M200 is used to input the sample images in the training set into the weather period classification model to obtain the weather period classification results of each sample image output; and train the weather period classification model based on the cross entropy loss function and the focal loss function according to the label category of the sample image and the weather period classification results output by the weather period classification model;

[0089] The image classification module M300 is used to input the image to be classified into the trained weather period classification model to obtain the output weather period classification result.

[0090] In view of the current situation that the existing guide gallery contains a large number of unlabeled images that are difficult to use, the present invention uses a loss function to train a weather period classification model, and can screen out images of weather period scenes from the gallery and label them accordingly, replacing manual labeling. Specifically, in the present invention, firstly, a weather period classification model is constructed by a model construction module M100, and the weather period classification model is a deep learning network model based on the field of computer vision. The weather period classification model is trained by a model training module M200. During the training process, two different loss functions are combined for training to obtain a trained weather period classification model. Through an image classification module M300, the image to be classified is input into the trained weather period classification model, thereby obtaining a more accurate classification result in a mixed scene. Not only can images containing weather period scenes be identified from images of various scenes, but also images can be further divided into specific weather and period categories. Compared with the traditional manual labeling method, the labor cost is greatly reduced, and the image labeling efficiency is greatly improved.

[0091] In the weather period classification system of the present invention, the functions of each module can be implemented by the specific implementation of the weather period classification method described above. For example, the model construction module M100 can use the specific implementation of step S100 to build a weather period classification model, and the model training module M200 can use the specific implementation of the above steps S200 and S300 to collect training sample images and train the weather period classification model. The image classification module M300 can use the specific implementation of the above step S400 to process the massive unlabeled images to be classified in the gallery.

[0092] Specifically, the model training module M200 first uses a pre-trained model based on the public scene classification dataset place365 to perform transfer learning on the weather period classification model. When the model training module M200 trains the weather period classification model, the parameters of each layer in the weather period classification model except the fully connected layer are fixed, and the parameters of the fully connected layer in the weather period classification model are trained based on the training set and the constructed loss function.

[0093] The model training module M200 trains the weather period classification model based on the cross entropy loss function and the focal loss function using the following steps:

[0094] For sample images whose label category belongs to the non-weather period category, the model training module M200 uses a focal loss function to train the weather period classification model;

[0095] For sample images whose label category belongs to the weather period category, the model training module M200 uses a combination of a cross entropy loss function and a focal loss function to train the weather period classification model.

[0096] In this embodiment, the weather period classification system also includes a model deployment module, which is used to package the trained weather period classification model based on the TorchServe model framework and deploy the weather period classification model based on the Flask framework. The weather period classification model deployed on the TorchServe model server adopts two loss functions for mixed training during training, wherein the cross entropy loss function can handle the classification problem between the classification labels of the weather period, and the focal loss can solve the problem of distinguishing the weather period scene from other scenes, so that the weather period classification model can filter images of irrelevant scenes, accurately identify the weather period category of the relevant scene images, and avoid interference from non-weather period category images.

[0097] An embodiment of the present invention also provides a weather period classification device, comprising a processor; a memory, in which executable instructions of the processor are stored; wherein the processor is configured to execute the steps of the weather period classification method by executing the executable instructions.

[0098] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "platform".

[0099] Refer to the following Figure 5 The electronic device 600 according to this embodiment of the present invention is described. Figure 5 The electronic device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0100] like Figure 5 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.

[0101] The storage unit stores a program code, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps of various exemplary embodiments of the present invention described in the weather period classification method section of this specification. For example, the processing unit 610 can perform the following steps: Figure 1 Follow the steps shown in .

[0102] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .

[0103] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0104] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0105] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0106] The embodiment of the present invention further provides a computer-readable storage medium for storing a program, which implements the steps of the weather period classification method when executed. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is executed on a terminal device, the program code is used to cause the terminal device to execute the steps of various exemplary embodiments of the present invention described in the above weather period classification method section of this specification.

[0107] refer to Figure 6 As shown, a program product 800 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be executed on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0108] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0109] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0110] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0111] In summary, by adopting the weather period classification method, system, device and storage medium of the present invention, based on the deep learning network model in the field of computer vision, combined with two different loss functions for training, more accurate classification results are obtained in mixed scenes. Not only can images containing weather period scenes be identified from images of various scenes, but the images can be further divided into specific weather and time period categories. Compared with the traditional manual labeling method, the labor cost is greatly reduced, and the image labeling efficiency is greatly improved, which is convenient for screening more and better quality images for display in subsequent production applications, thereby improving the user experience.

[0112] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the scope of protection of the present invention.

Claims

1. A weather period classification method, characterized in that: The steps include: Constructing a weather period classification model based on deep learning, wherein the input of the weather period classification model is an image to be classified, and the output is a weather period classification result; the weather period classification model is constructed based on a Wide Resnet50 network, and the output of the classifier of the Wide Resnet50 network includes multiple weather period categories and one non-weather period category; Inputting the sample images in the training set into the weather period classification model to obtain the weather period classification results of each output sample image; According to the label category of the sample image and the weather period classification result output by the weather period classification model, the weather period classification model is trained based on the cross entropy loss function and the focal loss loss function, including the following steps: for sample images whose label category belongs to the non-weather period category, the weather period classification model is trained using the focal loss function; for sample images whose label category belongs to the weather period category, the weather period classification model is trained using a combination of the cross entropy loss function and the focal loss function; Input the image to be classified into the trained weather period classification model to obtain the output weather period classification result; Wherein, after training the weather period classification model, the following steps are also included: Inputting the test images in the test set into the weather period classification model to obtain an output weather period classification result; Manually extract the classification results of the weather period to be verified and compare them with the label categories of the test images; For the test samples with classification errors, the corresponding positive and negative samples are supplemented, the weight of the cross entropy and the balance factor of the focal loss are updated, and the weather period classification model is retrained.

2. The weather period classification method according to claim 1, characterized in that: When training the weather period classification model, the weights of the weather period classification model are updated using an iterative strategy of stochastic gradient descent based on momentum.

3. The weather period classification method according to claim 1, characterized in that: The weather period classification model is constructed based on a convolutional neural network. When training the weather period classification model, different learning rates are used for the convolutional layer and the fully connected layer.

4. The weather period classification method according to claim 1, characterized in that: Before training the weather period classification model, the following steps are also included: A pre-trained model based on the public scene classification dataset place365 is used to perform transfer learning on the weather period classification model, and parameter weights except the last fully connected layer in the pre-trained model are loaded into the weather period classification model; When training the weather period classification model, the parameters of each layer in the weather period classification model except the fully connected layer are fixed, and the parameters of the fully connected layer in the weather period classification model are trained based on the training set and the constructed loss function.

5. The weather period classification method according to claim 1, characterized in that: After manually extracting the classification result of the weather period to be verified and comparing it with the label category of the test image, the following steps are also included: Determine whether the classification accuracy of the test image is greater than a preset threshold; If yes, it is determined that the training of the weather period classification model is completed.

6. The weather period classification method according to claim 1, characterized in that: After training the weather period classification model, the following steps are also included: Package the trained weather period classification model based on the TorchServe model framework; The weather period classification model is deployed based on the Flask framework.

7. A weather period classification system, used to implement the weather period classification method according to any one of claims 1 to 6, characterized in that: The system comprises: A model building module, used to build a weather period classification model, the input of the weather period classification model is the image to be classified, and the output is the weather period classification result; A model training module, used to input the sample images in the training set into the weather period classification model, obtain the weather period classification results of each sample image output; and train the weather period classification model based on the cross entropy loss function and the focalloss loss function according to the label category of the sample image and the weather period classification results output by the weather period classification model; The image classification module is used to input the image to be classified into the trained weather period classification model to obtain the output weather period classification result.

8. A weather period classification device, characterized in that: include: processor; a memory storing executable instructions of the processor; The processor is configured to execute the steps of the weather period classification method according to any one of claims 1 to 6 by executing the executable instructions.

9. A computer-readable storage medium for storing a program, characterized in that: When the program is executed, the steps of the weather period classification method described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Image classification method and system, electronic device and storage medium

    CN110503154A

  • Non-equilibrium class leukocyte classification method based on transfer learning

    CN111476266A

  • Weather image classification method and device

    CN111507388A