CN110889824A - Sample generation method and device, electronic equipment and computer readable storage medium - Google Patents

Sample generation method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN110889824A
CN110889824A CN201910969923.0A CN201910969923A CN110889824A CN 110889824 A CN110889824 A CN 110889824A CN 201910969923 A CN201910969923 A CN 201910969923A CN 110889824 A CN110889824 A CN 110889824A
Authority
CN
China
Prior art keywords
image
pig body
body mask
enhanced
mask image
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.)
Pending
Application number
CN201910969923.0A
Other languages
Chinese (zh)
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.)
Beijing Haiyi Tongzhan Information Technology Co Ltd
Original Assignee
Beijing Haiyi Tongzhan Information Technology 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 Beijing Haiyi Tongzhan Information Technology Co Ltd filed Critical Beijing Haiyi Tongzhan Information Technology Co Ltd
Priority to CN201910969923.0A priority Critical patent/CN110889824A/en
Publication of CN110889824A publication Critical patent/CN110889824A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration by the use of more than one image, e.g. averaging, subtraction
    • 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 invention relates to a sample generation method, a sample generation device, electronic equipment and a computer-readable storage medium, wherein the method comprises the following steps: acquiring an initial sample image containing a pig body and a plurality of background images; extracting a pig body mask image from the initial sample image; performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images; and finally, fusing each enhanced pig body mask image with a plurality of background images respectively to obtain a plurality of training sample images and marking information. The embodiment of the invention can reduce the loss of foreground information; the overfitting problem is avoided, manual labeling is not needed, and labor cost is saved.

Description

Sample generation method and device, electronic equipment and computer readable storage medium
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for generating a sample, an electronic device, and a computer-readable storage medium.
Background
Currently, the market demand for pork is greatest in weight among all animal meats. However, with the development of the pig industry in large scale, the number of the detections for the pig body is far higher than the labor cost, and the real-time situation of the pig can be found in time through the detection for the pig body. At present, a pig body detection method starts to use a deep learning related algorithm, but the requirement of training data is large, and manual class marking is difficult to achieve.
In order to expand a limited training data set, the existing data enhancement method in deep learning can generate new training data by randomly increasing jitter and disturbance on the original data, that is, the initial sample is subjected to certain processing such as blurring, clipping and deformation, and the labeling category of the picture is not changed.
However, existing data enhancement may suffer from information loss from the foreground and may easily result in a situation where the scene is over-fitted.
Disclosure of Invention
To solve the technical problem or at least partially solve the technical problem, the invention provides a sample generation method, a sample generation device, an electronic device and a computer-readable storage medium.
In a first aspect, the present invention provides a sample generation method, including:
acquiring an initial sample image containing a pig body and a plurality of background images;
extracting a pig body mask image from the initial sample image;
performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images;
and respectively fusing each enhanced pig body mask image with a plurality of background images to obtain a plurality of training sample images and labeling information.
Optionally, the fusing each enhanced pig body mask image with the plurality of background images respectively to obtain a plurality of training sample images and labeling information includes:
randomly generating an adding position of each enhanced pig body mask image in any background image when each enhanced pig body mask image is fused with the background image;
covering the enhanced pig body mask image on the background image according to the adding position;
carrying out image fusion on the enhanced pig body mask image and the background image to obtain a training sample image;
and generating the marking information according to the adding position.
Optionally, overlaying the enhanced pig body mask image on the background image according to the adding position, including:
acquiring the image size of the enhanced pig body mask image;
calculating an adding area according to the adding position and the image size of the enhanced pig body mask image;
adding the enhanced pig body mask image into the addition region.
Optionally, image fusion is performed on the enhanced pig body mask image and the background image to obtain a training sample image, including:
calculating a first gradient field of the enhanced pig body mask image according to the pixel value of each pixel point of the enhanced pig body mask image;
calculating a second gradient field of the regional image except the adding region in the background image according to the pixel points except the adding region in the background image;
calculating a gradient field of an image to be reconstructed according to the first gradient field and the second gradient field;
calculating divergence according to the gradient field of the image to be reconstructed;
and calculating the RGB value of each pixel point of the training sample image according to the divergence, a preset coefficient matrix and a Poisson equation.
Optionally, generating the labeling information according to the adding position includes:
acquiring the image size of the enhanced pig body mask image;
determining an annotation range according to the adding position and the image size;
and generating the labeling information according to the labeling range.
Optionally, the foreground enhancement mode includes: one or more of translation, rotation, scaling, horizontal flipping, vertical flipping, blur processing, and adding salt and pepper noise.
In a second aspect, the present invention provides a sample generation device comprising:
the acquisition module is used for acquiring an initial sample image containing a pig body and a plurality of background images;
the extraction module is used for extracting a pig body mask image from the initial sample image;
the foreground enhancement module is used for carrying out foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images;
and the fusion processing module is used for respectively fusing each enhanced pig body mask image with a plurality of background images to obtain a plurality of training sample images and labeling information.
Optionally, the fusion processing module includes:
the position generating unit is used for randomly generating the adding positions of the enhanced pig body mask images in the background images when each enhanced pig body mask image is fused with any background image;
the covering unit is used for covering the enhanced pig body mask image on the background image according to the adding position;
the fusion unit is used for carrying out image fusion on the enhanced pig body mask image and the background image to obtain a training sample image;
and the generating unit is used for generating the marking information according to the adding position.
Optionally, the covering unit includes:
the first acquisition subunit is used for acquiring the image size of the mask image of the enhanced pig body;
the first calculating subunit is used for calculating an adding area according to the adding position and the image size of the enhanced pig body mask image;
and the adding subunit is used for adding the enhanced pig body mask image into the adding area.
Optionally, the fusion unit includes:
the second calculation subunit is used for calculating a first gradient field of the enhanced pig body mask image according to the pixel value of each pixel point of the enhanced pig body mask image;
the third calculation subunit is used for calculating a second gradient field of the regional image except the adding region in the background image according to each pixel point except the adding region in the background image;
a fourth calculation unit, configured to calculate a gradient field of the image to be reconstructed according to the first gradient field and the second gradient field;
the fifth calculating unit is used for calculating the divergence according to the gradient field of the image to be reconstructed;
and the sixth calculating unit is used for calculating the RGB value of each pixel point of the training sample image according to the divergence, the preset coefficient matrix and the Poisson equation.
Optionally, the generating unit includes:
the second acquiring subunit is used for acquiring the image size of the enhanced pig mask image;
the determining subunit is used for determining an annotation range according to the adding position and the image size;
and the generating subunit is used for generating the labeling information according to the labeling range.
Optionally, the foreground enhancement mode includes: one or more of translation, rotation, scaling, horizontal flipping, vertical flipping, blur processing, and adding salt and pepper noise.
In a second aspect, the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method of generating a sample according to any one of the first aspect when executing a program stored in the memory.
In a second aspect, the present invention provides a computer-readable storage medium having stored thereon a program of a sample generation method, which when executed by a processor, implements the steps of the sample generation method of any one of the first aspects.
Compared with the prior art, the technical scheme provided by the embodiment of the invention has the following advantages:
the method comprises the steps of obtaining an initial sample image containing a pig body and a plurality of background images; extracting a pig body mask image from the initial sample image; performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images; and finally, fusing each enhanced pig body mask image with a plurality of background images respectively to obtain a plurality of training sample images and marking information.
According to the embodiment of the invention, because the foreground enhancement is only performed on the pig mask image, and the data enhancement processing is not performed on the whole image, the loss of foreground information can be reduced; the mask image of the enhanced pig body is fused with the background images to obtain a plurality of training sample images, and a large number of different background images are used, so that a model obtained by training based on the training sample images with rich background images can be prevented from being influenced by the change of the background images in subsequent use, and the embodiment of the invention can avoid the over-fitting problem, namely, the model obtained by training the training sample by using a single background image can be avoided, and in the subsequent use process, the situation that the category cannot be identified due to the fact that the images to be classified are acquired in other scenes and the background images are different from the training sample images is avoided; furthermore, the embodiment of the invention can directly obtain the labeling information corresponding to each training sample image while obtaining a large number of training sample images, can directly input the model for training, does not need manual labeling, and saves the labor cost.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic flow chart of a sample generation method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating step S104 in FIG. 1 according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating step S203 in FIG. 2 according to an embodiment of the present invention;
FIG. 4 is a block diagram of a sample generation device provided in accordance with one embodiment of the present invention;
fig. 5 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
The inventor finds that: since existing data enhancement is mainly based on some basic transformations of the whole image, information loss of the foreground may occur, and since there is no change to the fixed scene or limited change to the background complexity, it is easy to create a situation of overfitting to the scene. To this end, in a sample generation method, an apparatus, an electronic device, and a computer-readable storage medium provided in an embodiment of the present invention, as shown in fig. 1, the sample generation method may include the following steps:
step S101, obtaining an initial sample image containing a pig body and a plurality of background images;
in the embodiment of the present invention, the initial sample image may include the whole or part of the pig body, and the background image refers to an image acquired under different backgrounds, and is used as a background image in subsequent image fusion, for example: images collected at any angle in a pigsty, images collected at any angle indoors and outdoors, and the like.
Step S102, extracting a pig body mask image from the initial sample image;
in this step, a pig body mask image may be extracted from the initial sample image by a semantic segmentation technique.
Step S103, performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images;
in the embodiment of the present invention, the foreground enhancement mode includes: one or more of translation, rotation, scaling, horizontal flipping, vertical flipping, blur processing, and adding salt and pepper noise.
Through multiple foreground enhancement, a plurality of enhanced pig body mask images can be obtained, and preparation is made for generating a large number of training sample images.
And S104, respectively fusing each enhanced pig body mask image with a plurality of background images to obtain a plurality of training sample images and labeling information.
As shown in fig. 2, step S104 may include the steps of:
step S201, when each enhanced pig body mask image is fused with any background image, randomly generating an adding position of the enhanced pig body mask image in the background image;
step S202, covering the enhanced pig body mask image on the background image according to the adding position;
in this step, the image size of the enhanced pig body mask image may be acquired, an adding region may be calculated according to the adding position and the image size of the enhanced pig body mask image, and the enhanced pig body mask image may be added to the adding region.
Step S203, carrying out image fusion on the enhanced pig body mask image and the background image to obtain a training sample image;
as shown in fig. 3, step S203 may include the steps of:
step S301, calculating a first gradient field of the enhanced pig body mask image according to the pixel value of each pixel point of the enhanced pig body mask image;
step S302, calculating a second gradient field of the regional image except the adding region in the background image according to each pixel point except the adding region in the background image;
step S303, calculating a gradient field of an image to be reconstructed according to the first gradient field and the second gradient field;
step S304, calculating divergence according to the gradient field of the image to be reconstructed;
and S305, calculating the RGB value of each pixel point of the training sample image according to the divergence, the preset coefficient matrix and the Poisson equation.
In the embodiment of the present invention, the poisson equation may be Ax ═ b, where b is divergence, a is a preset coefficient matrix, and x is an RGB value of each pixel point of the training sample image.
In this step, the fused result can be quickly calculated by using the seamlessClone () method in OpenCV.
According to the embodiment of the invention, the computer vision Poisson fusion method is utilized, the mask image of the enhanced pig body is naturally fused into different background images, the edge can be well attached to the background, and the simulation degree is very high.
Step S204, generating the labeling information according to the adding position;
in the step, the image size of the enhanced pig mask image can be obtained, an annotation range is determined according to the adding position and the image size, and the annotation information is generated according to the annotation range.
The method comprises the steps of obtaining an initial sample image containing a pig body and a plurality of background images; extracting a pig body mask image from the initial sample image; performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images; and finally, fusing each enhanced pig body mask image with a plurality of background images respectively to obtain a plurality of training sample images and marking information.
According to the embodiment of the invention, because the foreground enhancement is only performed on the pig mask image, and the data enhancement processing is not performed on the whole image, the loss of foreground information can be reduced; the mask image of the enhanced pig body is fused with the background images to obtain a plurality of training sample images, and a large number of different background images are used, so that a model obtained by training based on the training sample images with rich background images can be prevented from being influenced by the change of the background images in subsequent use, and the embodiment of the invention can avoid the over-fitting problem, namely, the model obtained by training the training sample by using a single background image can be avoided, and in the subsequent use process, the situation that the category cannot be identified due to the fact that the images to be classified are acquired in other scenes and the background images are different from the training sample images is avoided; furthermore, the embodiment of the invention can directly obtain the labeling information corresponding to each training sample image while obtaining a large number of training sample images, can directly input the model for training, does not need manual labeling, and saves the labor cost.
In still another embodiment of the present invention, there is also provided a sample generation apparatus, as shown in fig. 4, including:
the acquisition module 11 is used for acquiring an initial sample image containing a pig body and a plurality of background images;
an extraction module 12, configured to extract a pig mask image from the initial sample image;
the foreground enhancement module 13 is used for performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images;
and the fusion processing module 14 is configured to perform fusion processing on each enhanced pig body mask image and the plurality of background images respectively to obtain a plurality of training sample images and labeling information.
The method comprises the steps of obtaining an initial sample image containing a pig body and a plurality of background images; extracting a pig body mask image from the initial sample image; performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images; and finally, fusing each enhanced pig body mask image with a plurality of background images respectively to obtain a plurality of training sample images and marking information.
According to the embodiment of the invention, because the foreground enhancement is only performed on the pig mask image, and the data enhancement processing is not performed on the whole image, the loss of foreground information can be reduced; the mask image of the enhanced pig body is fused with the background images to obtain a plurality of training sample images, and a large number of different background images are used, so that a model obtained by training based on the training sample images with rich background images can be prevented from being influenced by the change of the background images in subsequent use, and the embodiment of the invention can avoid the over-fitting problem, namely, the model obtained by training the training sample by using a single background image can be avoided, and in the subsequent use process, the situation that the category cannot be identified due to the fact that the images to be classified are acquired in other scenes and the background images are different from the training sample images is avoided; furthermore, the embodiment of the invention can directly obtain the labeling information corresponding to each training sample image while obtaining a large number of training sample images, can directly input the model for training, does not need manual labeling, and saves the labor cost.
In another embodiment of the present invention, the fusion processing module 14 includes:
the position generating unit is used for randomly generating the adding positions of the enhanced pig body mask images in the background images when each enhanced pig body mask image is fused with any background image;
the covering unit is used for covering the enhanced pig body mask image on the background image according to the adding position;
the fusion unit is used for carrying out image fusion on the enhanced pig body mask image and the background image to obtain a training sample image;
the generating unit is used for generating the labeling information according to the adding position;
in yet another embodiment of the present invention, the covering unit includes:
the first acquisition subunit is used for acquiring the image size of the mask image of the enhanced pig body;
the first calculating subunit is used for calculating an adding area according to the adding position and the image size of the enhanced pig body mask image;
and the adding subunit is used for adding the enhanced pig body mask image into the adding area.
In another embodiment of the present invention, the fusion unit includes:
the second calculation subunit is used for calculating a first gradient field of the enhanced pig body mask image according to the pixel value of each pixel point of the enhanced pig body mask image;
the third calculation subunit is used for calculating a second gradient field of the regional image except the adding region in the background image according to each pixel point except the adding region in the background image;
a fourth calculation unit, configured to calculate a gradient field of the image to be reconstructed according to the first gradient field and the second gradient field;
the fifth calculating unit is used for calculating the divergence according to the gradient field of the image to be reconstructed;
and the sixth calculating unit is used for calculating the RGB value of each pixel point of the training sample image according to the divergence, the preset coefficient matrix and the Poisson equation.
In another embodiment of the present invention, the generating unit includes:
the second acquiring subunit is used for acquiring the image size of the enhanced pig mask image;
the determining subunit is used for determining an annotation range according to the adding position and the image size;
and the generating subunit is used for generating the labeling information according to the labeling range.
In yet another embodiment of the present invention, the manner of foreground enhancement includes: one or more of translation, rotation, scaling, horizontal flipping, vertical flipping, blur processing, and adding salt and pepper noise.
In another embodiment of the present invention, an electronic device is further provided, which includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the sample generation method of the embodiment of the method when executing the program stored in the memory.
According to the electronic equipment provided by the embodiment of the invention, the processor realizes the acquisition of the initial sample image containing the pig body and a plurality of background images by executing the program stored in the memory; extracting a pig body mask image from the initial sample image; performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images; and respectively fusing each enhanced pig body mask image with a plurality of background images to obtain a plurality of training sample images and labeling information. Because only the foreground enhancement is carried out on the pig body mask image, the data enhancement processing is not carried out on the whole image, the loss of foreground information can be reduced; the mask image of the enhanced pig body is fused with the background images to obtain a plurality of training sample images, and a large number of different background images are used, so that a model obtained by training based on the training sample images with rich background images can be prevented from being influenced by the change of the background images in subsequent use, and the embodiment of the invention can avoid the over-fitting problem, namely, the model obtained by training the training sample by using a single background image can be avoided, and in the subsequent use process, the situation that the category cannot be identified due to the fact that the images to be classified are acquired in other scenes and the background images are different from the training sample images is avoided; furthermore, the embodiment of the invention can directly obtain the labeling information corresponding to each training sample image while obtaining a large number of training sample images, can directly input the model for training, does not need manual labeling, and saves the labor cost.
The communication bus 1140 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 1140 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 5, but this is not intended to represent only one bus or type of bus.
The communication interface 1120 is used for communication between the electronic device and other devices.
The memory 1130 may include a Random Access Memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The processor 1110 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the integrated circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
In yet another embodiment of the present invention, there is also provided a computer-readable storage medium having stored thereon a program of a sample generation method, which when executed by a processor, implements the steps of the sample generation method described in the aforementioned method embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The procedures or functions according to the embodiments of the invention are brought about in whole or in part when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (ssd)), among others.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (14)

1. A method of generating a sample, comprising:
acquiring an initial sample image containing a pig body and a plurality of background images;
extracting a pig body mask image from the initial sample image;
performing foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images;
and respectively fusing each enhanced pig body mask image with a plurality of background images to obtain a plurality of training sample images and labeling information.
2. The sample generation method according to claim 1, wherein the fusing each enhanced pig body mask image with the plurality of background images to obtain a plurality of training sample images and labeling information comprises:
randomly generating an adding position of each enhanced pig body mask image in any background image when each enhanced pig body mask image is fused with the background image;
covering the enhanced pig body mask image on the background image according to the adding position;
carrying out image fusion on the enhanced pig body mask image and the background image to obtain a training sample image;
and generating the marking information according to the adding position.
3. The sample generation method of claim 2, wherein overlaying the enhanced pig body mask image over the background image according to the addition location comprises:
acquiring the image size of the enhanced pig body mask image;
calculating an adding area according to the adding position and the image size of the enhanced pig body mask image;
adding the enhanced pig body mask image into the addition region.
4. The sample generation method of claim 3, wherein image fusing the enhanced pig body mask image with the background image to obtain a training sample image comprises:
calculating a first gradient field of the enhanced pig body mask image according to the pixel value of each pixel point of the enhanced pig body mask image;
calculating a second gradient field of the regional image except the adding region in the background image according to the pixel points except the adding region in the background image;
calculating a gradient field of an image to be reconstructed according to the first gradient field and the second gradient field;
calculating divergence according to the gradient field of the image to be reconstructed;
and calculating the RGB value of each pixel point of the training sample image according to the divergence, a preset coefficient matrix and a Poisson equation.
5. The sample generation method according to claim 2, wherein generating the labeling information according to the addition position includes:
acquiring the image size of the enhanced pig body mask image;
determining an annotation range according to the adding position and the image size;
and generating the labeling information according to the labeling range.
6. The sample generation method of claim 1, wherein the foreground enhancement mode comprises: one or more of translation, rotation, scaling, horizontal flipping, vertical flipping, blur processing, and adding salt and pepper noise.
7. A sample generation device, comprising:
the acquisition module is used for acquiring an initial sample image containing a pig body and a plurality of background images;
the extraction module is used for extracting a pig body mask image from the initial sample image;
the foreground enhancement module is used for carrying out foreground enhancement on the pig body mask image to obtain a plurality of enhanced pig body mask images;
and the fusion processing module is used for respectively fusing each enhanced pig body mask image with a plurality of background images to obtain a plurality of training sample images and labeling information.
8. The sample generation apparatus of claim 7, wherein the fusion processing module comprises:
the position generating unit is used for randomly generating the adding positions of the enhanced pig body mask images in the background images when each enhanced pig body mask image is fused with any background image;
the covering unit is used for covering the enhanced pig body mask image on the background image according to the adding position;
the fusion unit is used for carrying out image fusion on the enhanced pig body mask image and the background image to obtain a training sample image;
and the generating unit is used for generating the marking information according to the adding position.
9. The sample generation apparatus of claim 8, wherein the overlay unit comprises:
the first acquisition subunit is used for acquiring the image size of the mask image of the enhanced pig body;
the first calculating subunit is used for calculating an adding area according to the adding position and the image size of the enhanced pig body mask image;
and the adding subunit is used for adding the enhanced pig body mask image into the adding area.
10. The sample generation device according to claim 9, wherein the fusion unit comprises:
the second calculation subunit is used for calculating a first gradient field of the enhanced pig body mask image according to the pixel value of each pixel point of the enhanced pig body mask image;
the third calculation subunit is used for calculating a second gradient field of the regional image except the adding region in the background image according to each pixel point except the adding region in the background image;
a fourth calculation unit, configured to calculate a gradient field of the image to be reconstructed according to the first gradient field and the second gradient field;
the fifth calculating unit is used for calculating the divergence according to the gradient field of the image to be reconstructed;
and the sixth calculating unit is used for calculating the RGB value of each pixel point of the training sample image according to the divergence, the preset coefficient matrix and the Poisson equation.
11. The sample generation apparatus according to claim 8, wherein the generation unit includes:
the second acquiring subunit is used for acquiring the image size of the enhanced pig mask image;
the determining subunit is used for determining an annotation range according to the adding position and the image size;
and the generating subunit is used for generating the labeling information according to the labeling range.
12. The sample generation apparatus of claim 7, wherein the foreground enhancement comprises: one or more of translation, rotation, scaling, horizontal flipping, vertical flipping, blur processing, and adding salt and pepper noise.
13. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method of generating a sample according to any one of claims 1 to 7 when executing a program stored in a memory.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a program of a sample generation method, which when executed by a processor implements the steps of the sample generation method of any one of claims 1 to 7.
CN201910969923.0A 2019-10-12 2019-10-12 Sample generation method and device, electronic equipment and computer readable storage medium Pending CN110889824A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910969923.0A CN110889824A (en) 2019-10-12 2019-10-12 Sample generation method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910969923.0A CN110889824A (en) 2019-10-12 2019-10-12 Sample generation method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN110889824A true CN110889824A (en) 2020-03-17

Family

ID=69746111

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910969923.0A Pending CN110889824A (en) 2019-10-12 2019-10-12 Sample generation method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110889824A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111524100A (en) * 2020-04-09 2020-08-11 武汉精立电子技术有限公司 Defect image sample generation method and device and panel defect detection method
CN111652796A (en) * 2020-05-13 2020-09-11 上海连尚网络科技有限公司 Image processing method, electronic device, and computer-readable storage medium
CN112348765A (en) * 2020-10-23 2021-02-09 深圳市优必选科技股份有限公司 Data enhancement method and device, computer readable storage medium and terminal equipment
CN112381222A (en) * 2020-11-12 2021-02-19 北京乐学帮网络技术有限公司 Sample generation method and device, computer equipment and storage medium
CN112419214A (en) * 2020-10-28 2021-02-26 深圳市优必选科技股份有限公司 Method and device for generating labeled image, readable storage medium and terminal equipment
CN112967248A (en) * 2021-03-03 2021-06-15 北京百度网讯科技有限公司 Method, apparatus, medium, and program product for generating defect image sample
CN113486941A (en) * 2021-06-30 2021-10-08 广州方硅信息技术有限公司 Live image training sample generation method, model training method and electronic equipment
CN113505630A (en) * 2021-04-13 2021-10-15 新希望六和股份有限公司 Pig farm monitoring model training method and device, computer equipment and storage medium
CN113706519A (en) * 2021-09-01 2021-11-26 广州锟元方青医疗科技有限公司 Synthetic method and device of pathological cell detection training sample

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105654436A (en) * 2015-12-24 2016-06-08 广东迅通科技股份有限公司 Backlight image enhancement and denoising method based on foreground-background separation
CN109816014A (en) * 2019-01-22 2019-05-28 天津大学 Generate method of the deep learning target detection network training with labeled data collection
CN110084892A (en) * 2019-04-23 2019-08-02 南京邮电大学 A kind of image data set creation method based on augmented reality
US20190258901A1 (en) * 2017-11-01 2019-08-22 Salesforce.Com, Inc. Training a neural network using augmented training datasets

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105654436A (en) * 2015-12-24 2016-06-08 广东迅通科技股份有限公司 Backlight image enhancement and denoising method based on foreground-background separation
US20190258901A1 (en) * 2017-11-01 2019-08-22 Salesforce.Com, Inc. Training a neural network using augmented training datasets
CN109816014A (en) * 2019-01-22 2019-05-28 天津大学 Generate method of the deep learning target detection network training with labeled data collection
CN110084892A (en) * 2019-04-23 2019-08-02 南京邮电大学 A kind of image data set creation method based on augmented reality

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111524100A (en) * 2020-04-09 2020-08-11 武汉精立电子技术有限公司 Defect image sample generation method and device and panel defect detection method
CN111524100B (en) * 2020-04-09 2023-04-18 武汉精立电子技术有限公司 Defect image sample generation method and device and panel defect detection method
CN111652796A (en) * 2020-05-13 2020-09-11 上海连尚网络科技有限公司 Image processing method, electronic device, and computer-readable storage medium
CN112348765A (en) * 2020-10-23 2021-02-09 深圳市优必选科技股份有限公司 Data enhancement method and device, computer readable storage medium and terminal equipment
CN112419214A (en) * 2020-10-28 2021-02-26 深圳市优必选科技股份有限公司 Method and device for generating labeled image, readable storage medium and terminal equipment
CN112381222A (en) * 2020-11-12 2021-02-19 北京乐学帮网络技术有限公司 Sample generation method and device, computer equipment and storage medium
CN112967248A (en) * 2021-03-03 2021-06-15 北京百度网讯科技有限公司 Method, apparatus, medium, and program product for generating defect image sample
CN112967248B (en) * 2021-03-03 2024-01-23 北京百度网讯科技有限公司 Method, apparatus, medium and program product for generating defect image samples
CN113505630A (en) * 2021-04-13 2021-10-15 新希望六和股份有限公司 Pig farm monitoring model training method and device, computer equipment and storage medium
CN113486941A (en) * 2021-06-30 2021-10-08 广州方硅信息技术有限公司 Live image training sample generation method, model training method and electronic equipment
CN113706519A (en) * 2021-09-01 2021-11-26 广州锟元方青医疗科技有限公司 Synthetic method and device of pathological cell detection training sample

Similar Documents

Publication Publication Date Title
CN110889824A (en) Sample generation method and device, electronic equipment and computer readable storage medium
US10803554B2 (en) Image processing method and device
CN110176027B (en) Video target tracking method, device, equipment and storage medium
CN106254933B (en) Subtitle extraction method and device
CN108171677B (en) Image processing method and related equipment
CN109753971B (en) Correction method and device for distorted text lines, character recognition method and device
CN107911753A (en) Method and apparatus for adding digital watermarking in video
US10699751B1 (en) Method, system and device for fitting target object in video frame
CN109993824B (en) Image processing method, intelligent terminal and device with storage function
US10891471B2 (en) Method and system for pose estimation
CN114511041B (en) Model training method, image processing method, device, equipment and storage medium
CN111145202B (en) Model generation method, image processing method, device, equipment and storage medium
CN113436222A (en) Image processing method, image processing apparatus, electronic device, and storage medium
CN111292335A (en) Method and device for determining foreground mask feature map and electronic equipment
EP2783326A1 (en) Methods and apparatuses for facilitating detection of text within an image
CN108268138A (en) Processing method, device and the electronic equipment of augmented reality
CN108734712B (en) Background segmentation method and device and computer storage medium
CN111353325A (en) Key point detection model training method and device
EP3709666A1 (en) Method for fitting target object in video frame, system, and device
CN112218005A (en) Video editing method based on artificial intelligence
CN108776959B (en) Image processing method and device and terminal equipment
CN110719415A (en) Video image processing method and device, electronic equipment and computer readable medium
US11468658B2 (en) Systems and methods for generating typographical images or videos
KR20150094108A (en) Method for generating saliency map based background location and medium for recording the same
CN111127310B (en) Image processing method and device, electronic equipment and storage medium

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: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Information Technology Co.,Ltd.

Address before: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

Address after: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Shuke Haiyi Information Technology Co.,Ltd.

Address before: 601, 6 / F, building 2, No. 18, Kechuang 11th Street, Beijing Economic and Technological Development Zone, Beijing 100176

Applicant before: BEIJING HAIYI TONGZHAN INFORMATION TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20200317

RJ01 Rejection of invention patent application after publication