CN108717547B - Sample data generation method and device and model training method and device - Google Patents

Sample data generation method and device and model training method and device Download PDF

Info

Publication number
CN108717547B
CN108717547B CN201810289135.2A CN201810289135A CN108717547B CN 108717547 B CN108717547 B CN 108717547B CN 201810289135 A CN201810289135 A CN 201810289135A CN 108717547 B CN108717547 B CN 108717547B
Authority
CN
China
Prior art keywords
sample data
sample
slice
target
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810289135.2A
Other languages
Chinese (zh)
Other versions
CN108717547A (en
Inventor
刘萌
夏珺峥
李长升
孙源良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guoxin Youe Data Co Ltd
Original Assignee
Guoxin Youe Data Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guoxin Youe Data Co Ltd filed Critical Guoxin Youe Data Co Ltd
Priority to CN201810289135.2A priority Critical patent/CN108717547B/en
Publication of CN108717547A publication Critical patent/CN108717547A/en
Application granted granted Critical
Publication of CN108717547B publication Critical patent/CN108717547B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • G06F18/2155Generating training patterns; Bootstrap methods, e.g. bagging or boosting characterised by the incorporation of unlabelled data, e.g. multiple instance learning [MIL], semi-supervised techniques using expectation-maximisation [EM] or naïve labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning

Abstract

The application provides a sample data generation method and device and a method and device for training a model, wherein the sample data generation method comprises the following steps: obtaining a sample picture, wherein the sample picture comprises a plurality of target categories; determining a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture; traversing the sample picture according to the size of a preset window to generate a slice to be analyzed; determining sample data from the slice to be analyzed according to a preset screening condition, so that the obtained sample data meets the following conditions: aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; and aiming at the condition that the second target type is taken as a screening basis, the proportion of the sample data containing the second target type in the sample data is reduced. The method and the device avoid the problem of data unbalance, and improve the precision of model training through the constructed balance data.

Description

Sample data generation method and device and model training method and device
Technical Field
The application relates to the technical field of data processing, in particular to a sample data generation method and device and a model training method and device.
Background
For machine learning, especially deep learning, most algorithms need to be run on the basis of a large amount of sample data. The richness and accuracy of sample data are very important to machine learning.
For example, semantic segmentation realized based on deep learning requires training a neural network model using a large amount of sample data, so that the trained neural network model can obtain a better semantic segmentation result. Wherein, the sample data may include: the method comprises the following steps of obtaining a plurality of sample pictures and pictures obtained after objects in the sample pictures are subjected to accurate semantic segmentation according to object types.
Although the data size of the sample pictures is particularly large, the number of the sample data of a certain type is obviously smaller than that of the sample data of other types, and the unbalanced data is often difficult to avoid in research work. In the related technology, different original picture sets are obtained in different application scenes, and the size of original pictures in the original picture sets is usually very large and cannot be matched with the size of a neural network model, so that the original pictures are generally traversed according to the size of a preset window to slice sample data corresponding to the original picture sets.
However, in the related art, since the image segmentation is performed without destination to acquire data, the problem of data imbalance is serious, so that small-class information (which is likely to be useful information) is covered by large-class information at two levels of a sample structure and a feature dimension, and the small-class information is often difficult to learn in the subsequent semantic segmentation, so that the accuracy of model training is poor.
Disclosure of Invention
In view of this, an object of the embodiments of the present application is to provide a sample data generation method and apparatus, and a method and apparatus for training a model, which avoid the problem of data imbalance to a certain extent, and improve the precision of model training by constructing balanced data.
In a first aspect, an embodiment of the present application provides a sample data generating method, where the method includes:
obtaining a sample picture, wherein the sample picture comprises a plurality of target categories;
determining a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture;
traversing the sample picture according to the size of a preset window to generate a section to be analyzed;
determining sample data from the slice to be analyzed according to a preset screening condition, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; and aiming at the condition that the second target type is taken as a screening basis, the proportion of the sample data containing the second target type in the sample data is reduced.
With reference to the first aspect, an embodiment of the present application provides a first possible implementation manner of the first aspect, where, for a case where the first target category is used as a screening basis, determining sample data from a slice to be analyzed according to a preset screening condition includes:
determining the distribution proportion of a first target class contained in a slice to be analyzed in the slice to be analyzed;
and if the determined distribution ratio is larger than the first preset slice ratio, determining the slice to be analyzed as sample data.
With reference to the first aspect, an embodiment of the present application provides a second possible implementation manner of the first aspect, where, for a case where the second target category is used as a screening basis, determining sample data from a slice to be analyzed according to a preset screening condition includes:
determining the distribution proportion of a second target class contained in the section to be analyzed;
and if the determined distribution ratio is smaller than a second preset slice ratio, determining the slice to be analyzed as sample data.
With reference to the first aspect, the first possible implementation manner of the first aspect, and any one possible implementation manner of the second possible implementation manner, an embodiment of the present application provides a third possible implementation manner of the first aspect, where the third possible implementation manner further includes:
marking pixels in the sample picture to obtain a marked picture; wherein, the pixels forming the same target category have the same label value;
and determining the distribution ratio of each target category in the sample picture according to different labeling values corresponding to different target categories in the labeling graph.
With reference to the third possible implementation manner of the first aspect, an embodiment of the present application provides a fourth possible implementation manner of the first aspect, where, for a case that the number of sample pictures is greater than one, determining, according to different labeled values corresponding to different target classes in the labeled graph, a distribution ratio of each target class in the sample pictures includes:
and determining the ratio of the total number of the labeling values corresponding to the target category in the labeling graphs respectively corresponding to the sample pictures to the total number of pixels in the labeling graphs respectively corresponding to the sample pictures as the distribution ratio of the target category in the sample pictures aiming at different target categories.
With reference to the first aspect, an embodiment of the present application provides a fifth possible implementation manner of the first aspect, where determining sample data from a slice to be analyzed according to a preset screening condition includes:
and determining sample data from the slice to be analyzed according to a preset screening condition aiming at the slice to be analyzed generated by traversing the sample picture according to the size of a specified preset window.
With reference to the fifth possible implementation manner of the first aspect, this application provides a sixth possible implementation manner of the first aspect, where the larger a difference between a distribution ratio of the first target class in the sample picture and a distribution ratio of the second target class in the sample picture is, the larger the number of the specified preset window sizes is.
In a second aspect, an embodiment of the present application further provides a method for training a model based on sample data generated in any one of the first aspect and the first possible implementation manner to the sixth possible implementation manner of the first aspect, where the method includes:
determining the labeling sample data of the sample data;
inputting sample data and labeled sample data into a semantic segmentation model to train the semantic segmentation model; wherein the semantic segmentation model is used for realizing semantic segmentation.
In a third aspect, an embodiment of the present application further provides a sample data generating apparatus, where the apparatus includes:
the system comprises a sample picture acquisition module, a target classification module and a target classification module, wherein the sample picture acquisition module is used for acquiring a sample picture which comprises a plurality of target classifications;
the target category determining module is used for determining a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture;
the to-be-analyzed slice acquisition module is used for traversing the sample picture according to the size of a preset window to generate a to-be-analyzed slice;
the sample data generating module is used for determining sample data from the slice to be analyzed according to preset screening conditions, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; and aiming at the condition that the second target type is taken as a screening basis, the proportion of the sample data containing the second target type in the sample data is reduced.
In a fourth aspect, an embodiment of the present application further provides an apparatus for training a model based on sample data generated in the third aspect, where the apparatus includes:
the marking data determining module is used for determining marking sample data of the sample data;
the semantic segmentation model training module is used for inputting the sample data and the labeled sample data into a semantic segmentation model to train the semantic segmentation model; wherein the semantic segmentation model is used for realizing semantic segmentation.
In the embodiment of the present application, based on an acquired sample picture, a first target class and/or a second target class are determined, and after traversing the sample picture according to a preset window size, a slice to be analyzed is generated, so as to determine sample data from the slice to be analyzed according to a screening condition that determines that a ratio of the sample data including the first target class is increased and a ratio of the sample data including the second target class is decreased when the first target class and the second target class are respectively taken as screening bases, that is, while increasing a ratio of a small-class target object (i.e., a first target class corresponding to a first target type) in the slice to be analyzed, the embodiment of the present application reduces a ratio of a large-class target object (i.e., a second target class corresponding to a second target type), thereby avoiding a problem of data imbalance to a certain extent, the constructed sample data achieves the balance of the large-class target object and the small-class target object, and the model trained based on the constructed sample data is higher in precision.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 shows a flowchart of a sample data generation method provided in an embodiment of the present application;
fig. 2 is a flowchart illustrating another sample data generation method provided in an embodiment of the present application;
FIG. 3 is a flow chart of another sample data generation method provided by the embodiment of the present application;
FIG. 4 is a flow chart of another sample data generation method provided by the embodiment of the present application;
FIG. 5 is a flow chart of a method for training a model provided by an embodiment of the present application;
fig. 6 is a schematic structural diagram illustrating a sample data generating apparatus according to an embodiment of the present application;
FIG. 7 is a schematic structural diagram of a computer device provided in an embodiment of the present application;
FIG. 8 is a schematic diagram of an apparatus for training a model according to an embodiment of the present disclosure;
fig. 9 shows a schematic structural diagram of another computer device provided in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
In consideration of the fact that data are acquired by performing image segmentation without destination in the related technology, the problem of data imbalance is serious, so that small-class information is covered by large-class information in two levels of a sample structure and a feature dimension, and the accuracy of model training is poor due to the fact that the small-class information is difficult to learn in the subsequent semantic segmentation. Based on this, an embodiment of the present application provides a sample data generation method, which avoids the problem of data imbalance to a certain extent, and improves the accuracy of model training by constructing balanced data, for details, see the following embodiments.
Referring to fig. 1, a flowchart of a sample data generating method provided in an embodiment of the present application is applied to a computer device, where the sample data generating method includes the following steps:
s101, obtaining a sample picture, wherein the sample picture comprises a plurality of target categories.
Here, the sample picture may be a picture taken by an image capture device (such as a camera, a video camera, etc.), or may be a picture scanned by a remote sensor. In the embodiment of the application, the sample picture can be directly obtained from the image acquisition device and the remote sensor, and can also be obtained through a data interface or a network crawler and the like. For a data interface layer, the sample picture may be obtained from a data interface accurately opened by an internet website (such as a chinese resource satellite application center website), and for a web crawler, the embodiment of the present application may use a web crawler technology, such as python (an object-oriented interpreted computer programming language), to implement a function of a crawler, and crawl the sample picture in the source code to be obtained to a local computer device.
S102, determining a first target category with a distribution ratio smaller than a first preset ratio and/or a second target category with a distribution ratio larger than a second preset ratio in the sample picture.
Here, with respect to the sample picture obtained as described above, only the first target class whose distribution is relatively small may be determined, only the second target class whose distribution is relatively large may be determined, or both the first target class and the second target class may be determined, from among a plurality of target classes included in the sample picture. The first target category with a relatively small distribution may be one or more, and similarly, the second target category with a relatively large distribution may be one or more, which is not specifically limited in the embodiment of the present application.
In addition, in the embodiment of the present application, the distribution ratio of the first target class may be determined based on the labeled value corresponding to the first target class in the labeled graph, and the distribution ratio of the second target class may also be determined based on the labeled value corresponding to the second target class in the labeled graph. The label graph is obtained by labeling the pixels in the sample picture.
For example, the distribution ratios of the two target categories are determined to be 10% and 90% respectively through the labeled graph, if the first preset ratio is 15% and the second preset ratio is 85%, then the target category with the distribution ratio of 10% is determined as the first target category, and the target category with the distribution ratio of 90% is determined as the second target category.
S103, traversing the sample picture according to the size of a preset window, and generating a slice to be analyzed.
Here, the traversal in the embodiment of the present application may be performed multiple times, and the size of the preset window used in each traversal may be different, so that the slice to be analyzed corresponding to the size of the preset window can be generated in each traversal.
The specified number of the preset window sizes is related to the difference between the distribution ratio of the first target category in the sample picture and the distribution ratio of the second target category in the sample picture. The larger the difference is, the larger the number of designated preset window sizes is, and the smaller the difference is, the smaller the number of designated preset window sizes is.
S104, determining sample data from the slice to be analyzed according to a preset screening condition, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; and aiming at the condition that the second target type is taken as a screening basis, the proportion of the sample data containing the second target type in the sample data is reduced.
Here, the sample data is screened from the slices to be analyzed obtained by traversal. In order to ensure that the first target class with a small distribution ratio and the second target class with a large distribution ratio can achieve data balance, the embodiment of the present application may perform the screening of the sample data in the following two cases.
In the first case: the first target category is used as a screening basis, and is a target category with a smaller distribution ratio, namely, the first target category corresponds to a disadvantage category. In order to achieve data balance, the embodiment of the application may increase a proportion of sample data including the first target category in the sample data determined from the slice to be analyzed.
In the second case: the second target category is used as a screening basis, and is a target category with a larger distribution ratio, that is, the second target category corresponds to the dominant category. In order to achieve data balance, the embodiment of the present application may reduce a proportion of sample data in the second target category included in the sample data determined from the slice to be analyzed.
In addition, the first target type and the second target type can be used as screening bases at the same time, even if the sample data contains more sample data of the first target type, the sample data contains less sample data of the second target type.
For the first case, referring to fig. 2, the sample data generating process corresponding to S104 is specifically implemented by the following steps:
s201, determining the distribution proportion of a first target class contained in a slice to be analyzed in the slice to be analyzed;
and S202, if the determined distribution ratio is larger than a first preset slice ratio, determining the slice to be analyzed as sample data.
Here, in the embodiment of the present application, a distribution ratio of a first target category included in a slice to be analyzed is first determined, then when it is determined that the distribution ratio is greater than a first preset slice ratio, the slice to be analyzed is determined as sample data, and when it is determined that the distribution ratio is less than or equal to the first preset slice ratio, the slice to be analyzed is discarded. That is, for a slice to be analyzed, only when the distribution proportion of the disadvantage category (i.e., the first target category) in the slice to be analyzed is sufficiently large (larger than the first preset slice proportion), the corresponding slice to be analyzed is retained, so that the sample data proportion corresponding to the disadvantage category is increased.
The first preset slice proportion may be determined based on a first preset proportion, and the second preset slice proportion may be determined based on a second preset proportion.
For the second case, referring to fig. 3, the sample data generating process corresponding to S104 is specifically implemented by the following steps:
s301, determining the distribution proportion of a second target category contained in the section to be analyzed;
and S302, if the determined distribution ratio is smaller than a second preset slice ratio, determining the slice to be analyzed as sample data.
Here, in the embodiment of the present application, first, a distribution ratio of a second target category included in a slice to be analyzed is determined, then, when it is determined that the distribution ratio is smaller than a second preset slice ratio, the slice to be analyzed is determined as sample data, and when it is determined that the distribution ratio is greater than or equal to the second preset slice ratio, the slice to be analyzed is discarded. That is, for a slice to be analyzed, only when the distribution ratio of the dominant class (i.e., the second target class) in the slice to be analyzed is sufficiently small (smaller than the second preset slice ratio), the corresponding slice to be analyzed is retained, so as to reduce the sample data ratio corresponding to the dominant class.
Further, combining the methods shown in fig. 2 and fig. 3, the sample data generating process corresponding to S104 may also be implemented by the following steps:
step one, determining the distribution proportion of a first target category contained in a section to be analyzed in the section to be analyzed;
secondly, determining the distribution proportion of a second target category contained in the section to be analyzed;
the execution of the step one and the step two is not in strict sequence.
And step three, if the determined distribution ratio is larger than the first preset slice ratio and smaller than the second preset slice ratio, determining the slice to be analyzed as sample data.
As shown in fig. 4, the sample data generation method provided in the embodiment of the present application determines the distribution ratio of each target class in the sample picture by the following steps:
s401, marking pixels in a sample picture to obtain a marked picture; wherein, the pixels forming the same target category have the same label value;
s402, determining the distribution proportion of each target category in the sample picture according to different labeling values corresponding to different target categories in the labeling graph.
Here, in the embodiment of the present application, the sample picture is labeled according to the pixel level to obtain a corresponding labeled graph, and then the distribution ratio of each target class in the sample picture is determined based on different labeled values corresponding to different target classes in the labeled graph. The process of determining the distribution ratio of the first object class and the second object class in the sample picture will be explained in detail next.
For the first target category, determining the distribution proportion of the first target category in the sample picture according to the ratio of the labeling value corresponding to the first target category in the labeling graph to the number of pixels of the labeling graph. In addition, when the number of the sample pictures is greater than one, the distribution ratio of the first target class in the sample pictures can be determined according to the ratio of the total number of the labeling values corresponding to the first target class in the labeling pictures respectively corresponding to the sample pictures to the total number of pixels in the labeling pictures respectively corresponding to the sample pictures.
For the second target category, determining the distribution proportion of the second target category in the sample picture according to the ratio of the labeled value corresponding to the second target category in the labeled graph to the number of pixels of the labeled graph. In addition, when the number of the sample pictures is greater than one, the distribution ratio of the second target class in the sample pictures can be determined according to the ratio of the total number of the labeling values corresponding to the second target class in the labeling pictures respectively corresponding to the sample pictures to the total number of pixels in the labeling pictures respectively corresponding to the sample pictures.
The sample data generation method provided by the embodiment of the application can determine sample data from the to-be-analyzed slice according to a preset screening condition aiming at the to-be-analyzed slice generated by traversing the sample picture according to the size of a specified preset window.
Specifically, in the embodiment of the present application, the traversal may be performed multiple times according to the sizes of the multiple preset windows. In this way, in the first traversal, all the obtained slices to be analyzed are retained as sample data, in the embodiment of the present application, part of the slices to be analyzed may be discarded at the beginning of the second traversal, part of the slices to be analyzed may also be discarded at the beginning of the third traversal, and the discarding may also be started at the beginning of the fourth traversal, the fifth traversal, and the like. If the difference between the distribution ratio of the first target class in the sample picture and the distribution ratio of the second target class in the sample picture is larger, that is, the difference between the dominant class and the dominant class is larger, the corresponding data imbalance phenomenon is more serious, at this time, part of the slices to be analyzed may start to be discarded during the second traversal, and then the number of the size of the corresponding indicated preset window is more. If the difference between the distribution ratio of the first target category in the sample picture and the distribution ratio of the second target category in the sample picture is smaller, that is, the difference between the dominant category and the dominant category is not large, at this time, the reject of the partial to-be-analyzed slices may be started only during the fifth pass, and then the number of the preset window sizes corresponding to the indications is smaller.
Based on the sample data generated in the foregoing embodiment, an embodiment of the present application further provides a method for training a model, as shown in fig. 5, which is a flowchart of the method for training a model provided in the embodiment of the present application, and is applied to a computer device, where the method for training a model includes the following steps:
s501, determining marking sample data of the sample data;
s502, inputting sample data and labeled sample data into a semantic segmentation model to train the semantic segmentation model; the semantic segmentation model is used for realizing semantic segmentation.
In the model training stage, sample data is used as input features of the semantic segmentation model to be trained, and labeled sample data corresponding to the sample data is used as an output result, and the parameter information of the semantic segmentation model is obtained through training, namely the trained semantic segmentation model is obtained. The embodiment of the application can adopt the neural network model as a semantic segmentation model, and the model training stage is the process of training some unknown parameter information in the neural network model. Then, the semantic segmentation is provided based on the semantic segmentation model, corresponding labeled target data can be obtained only by inputting the target data into the trained semantic segmentation model, and an effect graph after semantic segmentation can be restored based on the labeled target data.
Based on the same inventive concept, the embodiment of the present application further provides a sample data generating device corresponding to the sample data generating method, and as the principle of solving the problem of the device in the embodiment of the present application is similar to that of the sample data generating method in the embodiment of the present application, the implementation of the device may refer to the implementation of the method, and repeated details are not described again. As shown in fig. 6, which is a schematic structural diagram of a sample data generating device provided in an embodiment of the present application, the sample data generating device includes:
a sample picture obtaining module 61, configured to obtain a sample picture, where the sample picture includes multiple target categories;
a target category determining module 62, configured to determine a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture;
a to-be-analyzed slice acquisition module 63, configured to traverse the sample picture according to the size of the preset window, and generate a to-be-analyzed slice;
a sample data generating module 64, configured to determine sample data from the slice to be analyzed according to a preset filtering condition, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; and aiming at the condition that the second target type is taken as a screening basis, the proportion of the sample data containing the second target type in the sample data is reduced.
In a possible implementation manner, the sample data generating module 64 is specifically configured to determine a distribution ratio of a first target class included in a slice to be analyzed in the slice to be analyzed; and if the determined distribution ratio is larger than the first preset slice ratio, determining the slice to be analyzed as sample data.
In another possible implementation manner, the sample data generating module 64 is specifically configured to determine a distribution ratio of a second target class included in a slice to be analyzed in the slice to be analyzed; and if the determined distribution ratio is smaller than a second preset slice ratio, determining the slice to be analyzed as sample data.
The sample data generating device further includes:
the pixel labeling module 65 is configured to label pixels in the sample picture to obtain a labeled graph; wherein, the pixels forming the same target category have the same label value;
and a distribution ratio determining module 66, configured to determine a distribution ratio of each target category in the sample picture according to different labeled values corresponding to different target categories in the labeled graph.
In a specific implementation, for a case that the number of the sample pictures is greater than one, the distribution ratio determining module 66 is specifically configured to, for different target categories, determine, as the distribution ratio of the target category in the sample pictures, a ratio of the total number of the labeling values corresponding to the target category in the labeling graphs respectively corresponding to the sample pictures to the total number of pixels in the labeling graphs respectively corresponding to the sample pictures.
In another possible implementation manner, the sample data generating module 64 is specifically configured to determine, according to a preset filtering condition, sample data from a slice to be analyzed, where the slice to be analyzed is generated by traversing a sample picture according to a specified preset window size.
In a specific implementation, the larger the difference between the distribution ratio of the first target class in the sample picture and the distribution ratio of the second target class in the sample picture, the larger the number of the specified preset window sizes.
As shown in fig. 7, a schematic structural diagram of a computer device provided in an embodiment of the present application is shown, where the computer device includes: a processor 71, a memory 72 and a bus 73, wherein the memory 72 stores execution instructions, and when the device is operated, the processor 71 communicates with the memory 72 via the bus 73, and the processor 71 executes the following execution instructions stored in the memory 72:
obtaining a sample picture, wherein the sample picture comprises a plurality of target categories;
determining a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture;
traversing the sample picture according to the size of a preset window to generate a slice to be analyzed;
determining sample data from the slice to be analyzed according to a preset screening condition, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; and aiming at the condition that the second target type is taken as a screening basis, the proportion of the sample data containing the second target type in the sample data is reduced.
In a possible embodiment, the processor 71 is specifically configured to determine a distribution ratio of a first target class included in a slice to be analyzed in the slice to be analyzed; and if the determined distribution ratio is larger than the first preset slice ratio, determining the slice to be analyzed as sample data.
In another possible embodiment, the processor 71 is specifically configured to determine a distribution ratio of the second target class included in the slice to be analyzed; and if the determined distribution ratio is smaller than a second preset slice ratio, determining the slice to be analyzed as sample data.
The processor 71 is further configured to label pixels in the sample picture to obtain a label graph; wherein, the pixels forming the same target category have the same label value; and determining the distribution ratio of each target category in the sample picture according to different labeling values corresponding to different target categories in the labeling graph.
In a specific implementation, for a case that the number of the sample pictures is greater than one, the processor 71 is specifically configured to determine, for different target classes, a ratio of a total number of the labeling values corresponding to the target class in the labeling graphs respectively corresponding to the sample pictures to a total number of pixels in the labeling graphs respectively corresponding to the sample pictures, as a distribution ratio of the target class in the sample pictures.
In another possible implementation, the processor 71 is specifically configured to determine, for a to-be-analyzed slice generated by traversing the sample picture according to a specified preset window size, sample data from the to-be-analyzed slice according to a preset filtering condition.
In a specific implementation, the larger the difference between the distribution ratio of the first object class in the sample picture and the distribution ratio of the second object class in the sample picture, the larger the number of the preset window sizes specified by the processor 71.
Based on the same inventive concept, the embodiment of the present application further provides a device for training a model corresponding to the method for training a model, and since the principle of solving the problem of the device in the embodiment of the present application is similar to the method for training a model in the embodiment of the present application, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated. As shown in fig. 8, a schematic diagram of an apparatus for training a model according to an embodiment of the present application is provided, where the apparatus for training a model includes:
an annotation data determination module 81, configured to determine annotation sample data of the sample data;
a semantic segmentation model training module 82, configured to input the sample data and the labeled sample data into a semantic segmentation model to train the semantic segmentation model; the semantic segmentation model is used for realizing semantic segmentation.
As shown in fig. 9, a schematic structural diagram of a computer device provided in an embodiment of the present application is shown, where the computer device includes: a processor 91, a memory 92 and a bus 93, the memory 92 storing execution instructions, the processor 91 communicating with the memory 92 via the bus 93 when the device is operating, the processor 91 executing the following execution instructions stored in the memory 92:
determining the labeling sample data of the sample data;
inputting sample data and labeled sample data into a semantic segmentation model to train the semantic segmentation model; the semantic segmentation model is used for realizing semantic segmentation.
The sample data generation method and the computer program product of the model training method provided in the embodiment of the present application include a computer-readable storage medium storing a program code, and instructions included in the program code may be used to execute the method in the foregoing method embodiment.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (6)

1. A sample data generating method, characterized in that the method comprises:
obtaining a sample picture, wherein the sample picture comprises a plurality of target categories;
determining a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture;
traversing the sample picture according to the size of a preset window to generate a section to be analyzed;
determining sample data from the slice to be analyzed according to a preset screening condition, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; for the condition that the second target category is taken as a screening basis, the proportion of sample data containing the second target category in the sample data is reduced;
the sample data generation method further comprises:
marking pixels in the sample picture to obtain a marked picture; wherein, the pixels forming the same target category have the same label value;
determining the distribution proportion of each target category in the sample picture according to different labeling values corresponding to different target categories in the labeling graph;
for the condition that the number of the sample pictures is more than one, determining the distribution proportion of each target category in the sample pictures according to different labeling values corresponding to different target categories in the labeling graph, wherein the distribution proportion comprises the following steps:
for different target classes, determining the ratio of the total number of the labeling values corresponding to the target classes in the labeling graphs respectively corresponding to the sample pictures to the total number of pixels in the labeling graphs respectively corresponding to the sample pictures as the distribution ratio of the target classes in the sample pictures;
determining sample data from the slice to be analyzed according to a preset screening condition aiming at the condition that the first target category is taken as a screening basis, wherein the method comprises the following steps:
determining the distribution proportion of a first target class contained in a slice to be analyzed in the slice to be analyzed;
if the determined distribution ratio is larger than a first preset slice ratio, determining the slice to be analyzed as sample data, and if the determined distribution ratio is smaller than or equal to the first preset slice ratio, discarding the slice to be analyzed; wherein the first preset slice fraction is determined based on the first preset fraction;
determining sample data from the slice to be analyzed according to a preset screening condition aiming at the condition that the second target category is taken as a screening basis, wherein the method comprises the following steps:
determining the distribution proportion of a second target class contained in the section to be analyzed;
and if the determined distribution ratio is smaller than a second preset slice ratio, determining the slice to be analyzed as sample data, and if the determined distribution ratio is larger than or equal to the second preset slice ratio, discarding the slice to be analyzed, wherein the second preset slice ratio is determined based on the second preset ratio.
2. The method of claim 1, wherein determining sample data from the slice to be analyzed according to a preset screening condition comprises:
and determining sample data from the slice to be analyzed according to a preset screening condition aiming at the slice to be analyzed generated by traversing the sample picture according to the size of a specified preset window.
3. The method according to claim 2, wherein the larger the difference between the distribution ratio of the first object class in the sample picture and the distribution ratio of the second object class in the sample picture, the larger the number of preset window sizes is specified.
4. A method for training a model using sample data, the method comprising:
determining annotated sample data of sample data, wherein the sample data is generated based on the sample data generation method according to any one of claims 1-3;
inputting sample data and labeled sample data into a semantic segmentation model to train the semantic segmentation model; wherein the semantic segmentation model is used for realizing semantic segmentation.
5. An apparatus for generating sample data, the apparatus comprising:
the system comprises a sample picture acquisition module, a target classification module and a target classification module, wherein the sample picture acquisition module is used for acquiring a sample picture which comprises a plurality of target classifications;
the target category determining module is used for determining a first target category of which the distribution ratio is smaller than a first preset ratio and/or a second target category of which the distribution ratio is larger than a second preset ratio in the sample picture;
the to-be-analyzed slice acquisition module is used for traversing the sample picture according to the size of a preset window to generate a to-be-analyzed slice;
the sample data generating module is used for determining sample data from the slice to be analyzed according to preset screening conditions, so that the obtained sample data meets the following conditions:
aiming at the condition that the first target category is taken as a screening basis, the sample data containing the first target category is increased in proportion; for the condition that the second target category is taken as a screening basis, the proportion of sample data containing the second target category in the sample data is reduced;
the pixel labeling module is used for labeling the pixels in the sample picture to obtain a labeled graph; wherein, the pixels forming the same target category have the same label value;
the distribution ratio determining module is used for determining the distribution ratio of each target category in the sample picture according to different labeling values corresponding to different target categories in the labeling graph;
for the case that the number of the sample pictures is greater than one, the distribution ratio determining module is specifically configured to determine, for different target classes, a ratio of a total number of the labeling values corresponding to the target class in the labeling graphs respectively corresponding to the sample pictures to a total number of pixels in the labeling graphs respectively corresponding to the sample pictures, as the distribution ratio of the target class in the sample pictures;
the sample data generation module is specifically used for determining the distribution proportion of a first target category contained in the slice to be analyzed; if the determined distribution ratio is larger than a first preset slice ratio, determining the slice to be analyzed as sample data, and if the determined distribution ratio is smaller than or equal to the first preset slice ratio, discarding the slice to be analyzed;
the sample data generating module is specifically configured to determine a distribution ratio of a second target category included in the slice to be analyzed, determine the slice to be analyzed as sample data if the determined distribution ratio is smaller than a second preset slice ratio, and discard the slice to be analyzed if the determined distribution ratio is greater than or equal to the second preset slice ratio.
6. An apparatus for training a model using sample data, the apparatus comprising:
an annotation data determination module, configured to determine annotation sample data of sample data, where the sample data is generated based on the sample data generation apparatus according to claim 5;
the semantic segmentation model training module is used for inputting the sample data and the labeled sample data into a semantic segmentation model to train the semantic segmentation model; wherein the semantic segmentation model is used for realizing semantic segmentation.
CN201810289135.2A 2018-03-30 2018-03-30 Sample data generation method and device and model training method and device Active CN108717547B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810289135.2A CN108717547B (en) 2018-03-30 2018-03-30 Sample data generation method and device and model training method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810289135.2A CN108717547B (en) 2018-03-30 2018-03-30 Sample data generation method and device and model training method and device

Publications (2)

Publication Number Publication Date
CN108717547A CN108717547A (en) 2018-10-30
CN108717547B true CN108717547B (en) 2020-12-22

Family

ID=63898986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810289135.2A Active CN108717547B (en) 2018-03-30 2018-03-30 Sample data generation method and device and model training method and device

Country Status (1)

Country Link
CN (1) CN108717547B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109409432B (en) * 2018-10-31 2019-11-26 腾讯科技(深圳)有限公司 A kind of image processing method, device and storage medium
CN109635034B (en) * 2018-11-08 2020-03-03 北京字节跳动网络技术有限公司 Training data resampling method and device, storage medium and electronic equipment
CN111382569B (en) * 2018-12-27 2024-05-03 深圳市优必选科技有限公司 Method and device for identifying entity in dialogue corpus and computer equipment
CN110162649B (en) * 2019-05-24 2021-06-18 北京百度网讯科技有限公司 Sample data acquisition method, acquisition system, server and computer readable medium
CN110889462B (en) * 2019-12-09 2023-05-02 秒针信息技术有限公司 Data processing method, device, equipment and storage medium
CN113743431B (en) * 2020-05-29 2024-04-02 阿里巴巴集团控股有限公司 Data selection method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105354595A (en) * 2015-10-30 2016-02-24 苏州大学 Robust visual image classification method and system
CN105740894A (en) * 2016-01-28 2016-07-06 北京航空航天大学 Semantic annotation method for hyperspectral remote sensing image
CN105844287A (en) * 2016-03-15 2016-08-10 民政部国家减灾中心 Domain self-adaptive method and system for remote sensing image classification
CN106530305A (en) * 2016-09-23 2017-03-22 北京市商汤科技开发有限公司 Semantic segmentation model training and image segmentation method and device, and calculating equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105354595A (en) * 2015-10-30 2016-02-24 苏州大学 Robust visual image classification method and system
CN105740894A (en) * 2016-01-28 2016-07-06 北京航空航天大学 Semantic annotation method for hyperspectral remote sensing image
CN105844287A (en) * 2016-03-15 2016-08-10 民政部国家减灾中心 Domain self-adaptive method and system for remote sensing image classification
CN106530305A (en) * 2016-09-23 2017-03-22 北京市商汤科技开发有限公司 Semantic segmentation model training and image segmentation method and device, and calculating equipment

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
"Semi-supervised rail defect detection from imbalanced image data";Hajizadeh et al.;《Proceedings of the 14th IFAC Symposium on Control in Transportation Systems》;20160520;全文 *
"一种基于级联模型的类别不平衡数据分类方法";刘胥影 等;《南京大学学报(自然科学)》;20060331;第42卷(第2期);第148-155页 *
"不平衡数据的集成分类算法综述";李勇 等;《计算机应用研究》;20140531;第31卷(第5期);第1287-1291页 *
"基于内容的图像分割方法综述";姜枫 等;《软件学报》;20170131;第28卷(第1期);第168-171页 *
"非平衡类数据分类概述";钱洪波 等;《计算机工程与科学》;20100531;第32卷(第5期);第86页 *
钱洪波 等."非平衡类数据分类概述".《计算机工程与科学》.2010,第32卷(第5期), *

Also Published As

Publication number Publication date
CN108717547A (en) 2018-10-30

Similar Documents

Publication Publication Date Title
CN108717547B (en) Sample data generation method and device and model training method and device
CN106920229B (en) Automatic detection method and system for image fuzzy area
CN109858436B (en) Target class correction method and detection method based on video dynamic foreground mask
CN110211119B (en) Image quality evaluation method and device, electronic equipment and readable storage medium
CN111444966A (en) Media information classification method and device
CN108335293B (en) Image quality determination method and device
CN110597965B (en) Emotion polarity analysis method and device for article, electronic equipment and storage medium
Li et al. Automatic comic page segmentation based on polygon detection
CN111182367A (en) Video generation method and device and computer system
US11605156B2 (en) Iterative image inpainting with confidence feedback
US8538171B2 (en) Method and system for object detection in images utilizing adaptive scanning
CN109934789A (en) Image de-noising method, device and electronic equipment
US20200293570A1 (en) Information processing method, information processing apparatus, and non-transitory computer-readable storage medium for storing information processing program
CN111753729A (en) False face detection method and device, electronic equipment and storage medium
CN111401465A (en) Training sample optimization method, device, equipment and storage medium
CN113516328B (en) Data processing method, service providing method, device, equipment and storage medium
CN115115901A (en) Method and device for acquiring cross-domain learning model
CN107609401A (en) Automatic test approach and device
Breus Flexible Variable Star Extractor-new software for variable stars detection using CCD photometry
CN108287817B (en) Information processing method and device
Leszczuk et al. User-Generated Content (UGC)/In-The-Wild Video Content Recognition
CN115602245B (en) Method, device, equipment and storage medium for screening fluorescent images
Ko et al. SickZil-machine: a deep learning based script text isolation system for comics translation
US20240037717A1 (en) Generating neural network based perceptual artifact segmentations in modified portions of a digital image
CN110781973B (en) Article identification model training method, article identification device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 101-8, 1st floor, building 31, area 1, 188 South Fourth Ring Road West, Fengtai District, Beijing

Applicant after: Guoxin Youyi Data Co., Ltd

Address before: 100070, No. 188, building 31, headquarters square, South Fourth Ring Road West, Fengtai District, Beijing

Applicant before: SIC YOUE DATA Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant