A detection model training method, a detection method, and a detection model training device
By extracting and segmenting regions of interest from training ray images, performing grayscale mapping, and constructing multi-channel image groups to train the detection model, the problems of poor detection performance and high resource consumption in existing technologies are solved, achieving efficient detection model training and accurate detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AVIC BEIJING INST OF AERONAUTICAL MATERIALS
- Filing Date
- 2025-07-30
- Publication Date
- 2026-07-21
AI Technical Summary
Existing automated detection solutions based on detection models have poor detection performance, high resource consumption, and low training efficiency, which limits their rapid deployment and efficient operation in practical applications.
The region of interest is extracted from the training ray image and divided into several sub-region blocks. The minimum and maximum target gray values of each sub-region block are determined. Gray-scale mapping is performed according to the window width and window level. Multi-channel image groups are constructed for model training, avoiding the use of image enhancement techniques and increasing the number of training iterations.
The detection model's detection and recognition capabilities were improved, resulting in more accurate detection results. At the same time, resource consumption and training time were reduced, thus improving the model's detection efficiency.
Smart Images

Figure CN120913006B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automatic detection technology, and in particular to a detection model training method, a detection method, and a detection model training device. Background Technology
[0002] In recent years, with the rapid development of machine learning and deep learning technologies, automated inspection solutions based on detection models have gradually replaced manual inspection methods. These automated inspection solutions can be applied to many scenarios, such as X-ray defect detection and X-ray lesion detection.
[0003] The automated detection scheme based on the detection model involves obtaining training ray images from a constructed training ray image set (which includes multiple labeled training ray images; for example, in a ray workpiece defect detection scenario, the training ray image set includes multiple training ray images labeled with workpiece defect information), inputting the training ray images into the detection model for training, and after training, obtaining the target ray image and directly inputting the target ray image into the trained detection model for detection.
[0004] Although the aforementioned automated detection scheme based on detection models improves detection efficiency compared to manual detection methods, its detection effect is not good. Summary of the Invention
[0005] In view of this, this application provides a detection model training method, a detection method, and related apparatus to solve the problem of poor detection performance in existing detection schemes. The technical solution is as follows:
[0006] The first aspect of this application provides a method for training a detection model, including:
[0007] Obtain training ray images from the training ray image set;
[0008] The region of interest is extracted from the training ray image, and the region of interest is divided into several sub-region blocks to obtain a set of images to be processed, including the several sub-region blocks. Each sub-region block in the set of images to be processed is an image to be processed.
[0009] The minimum and maximum target gray values of each image in the image set to be processed are determined, and the window width and window level corresponding to each image in the image set to be processed are determined based on the minimum and maximum target gray values of each image in the image set to be processed.
[0010] For each image in the set of images to be processed, the pixel grayscale values of the image are mapped according to the window width and window level of the image, using a preset grayscale mapping rule, to obtain the grayscale mapped image of the image.
[0011] The training ray image and the grayscale mapped images corresponding to each image in the image set to be processed are respectively constructed into a multi-channel image group;
[0012] The detection model was trained using the multi-channel image set.
[0013] In one possible implementation, the set of images to be processed further includes the training ray images;
[0014] The step of constructing a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed includes:
[0015] The training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped images corresponding to the several sub-region blocks are constructed into a multi-channel image group.
[0016] In one possible implementation, determining the minimum and maximum target grayscale values for each image in the image set to be processed includes:
[0017] For each image in the set of images to be processed:
[0018] The image is scaled according to a preset scaling factor to obtain a thumbnail of the image.
[0019] Calculate the grayscale histogram of the image thumbnail to obtain the corresponding grayscale histogram of the image;
[0020] Based on the preset grayscale range ratio and the grayscale histogram corresponding to the image, the minimum target grayscale value and the maximum target grayscale value of the image are determined, wherein the grayscale range ratio is the proportion of the retained grayscale range to the entire grayscale range.
[0021] In one possible implementation, the training ray image is an N-bit grayscale ray image, where the grayscale range of the N-bit grayscale ray image is [0, M], and M is 2. N -1;
[0022] The step of mapping the pixel grayscale values of the image according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, includes:
[0023] Based on the window width and window level corresponding to the image, each gray value in the range [0, M] is mapped using a preset gray-scale mapping rule to obtain the gray-scale mapping table corresponding to the image. The gray-scale mapping table contains each gray value in the range [0, M] and the mapped gray values corresponding to each gray value in the range [0, M].
[0024] Based on the grayscale mapping table corresponding to the image, the pixel grayscale values of the image are mapped to obtain the grayscale mapped image.
[0025] In one possible implementation, the step of mapping the pixel grayscale values of the image according to the grayscale mapping table corresponding to the image to obtain the grayscale mapped image includes:
[0026] The image is tiled into a one-dimensional array, where each element of the one-dimensional array is the grayscale value of a pixel in the image;
[0027] For each gray value in the one-dimensional array, the mapped gray value corresponding to the gray value is obtained by querying the gray-scale mapping table corresponding to the image, and the mapped gray value corresponding to the gray value is used to replace the gray value in the one-dimensional array.
[0028] Generate the corresponding grayscale mapped image based on the one-dimensional array after grayscale value replacement.
[0029] In one possible implementation, the training ray image is an N-bit grayscale ray image, where the grayscale range of the N-bit grayscale ray image is [0, M], and M is 2. N -1; The step of mapping the pixel grayscale values of the image according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, to obtain the grayscale mapped image, includes:
[0030] Construct an initial grayscale mapping table corresponding to the image. The initial grayscale mapping table includes grayscale values in the range [0, M]. The mapped grayscale values corresponding to each grayscale value in the range [0, M] are empty.
[0031] For each pixel in the image, query the grayscale mapping table corresponding to the image to see if there is a mapped grayscale value corresponding to the grayscale value of that pixel;
[0032] If not, then based on the window width and window level corresponding to the image, the gray value of the pixel is directly mapped using the preset gray-scale mapping rules to obtain the mapped gray value corresponding to the gray value of the pixel, and the mapped gray value corresponding to the gray value of the pixel is stored in the gray-scale mapping table corresponding to the image; if yes, then the mapped gray value corresponding to the gray value of the pixel is directly obtained from the gray-scale mapping table corresponding to the image.
[0033] Based on the mapped gray values of each pixel in the image, generate the corresponding gray-mapped image.
[0034] In one possible implementation, the step of mapping the pixel grayscale values of the image according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, to obtain the grayscale mapped image, includes:
[0035] For each pixel in the image, based on the window width and window level corresponding to the image, the gray value of the pixel is mapped using a preset gray-scale mapping rule to obtain the mapped gray value corresponding to the gray value of the pixel.
[0036] Based on the mapped gray values of each pixel in the image, generate the corresponding gray-mapped image.
[0037] In one possible implementation, the image set to be processed further includes the training ray image; the step of constructing a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed includes:
[0038] For each sub-region block, by filling the area around the grayscale mapped image corresponding to the sub-region block with pixels of a set grayscale value, an image of the same size as the training ray image is constructed, resulting in the grayscale mapped extended image corresponding to the sub-region block. The position of the grayscale mapped image corresponding to the sub-region block in the grayscale mapped extended image corresponding to the sub-region block is the same as the position of the sub-region block in the training ray image.
[0039] The training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped extended images corresponding to the several sub-region blocks are combined into a multi-channel image group.
[0040] A second aspect of this application provides a detection method, comprising:
[0041] Acquire target ray image;
[0042] The target ray image is detected using a pre-trained detection model, wherein the detection model is trained using any of the above-mentioned detection model training methods.
[0043] A third aspect of this application provides a detection model training device, comprising: a training ray image acquisition module, a region of interest extraction and segmentation module, a grayscale threshold determination module, a window width and window level determination module, an image grayscale mapping module, a multi-channel image group construction module, and a model training module;
[0044] The training ray image acquisition module is used to acquire training ray images from the training ray image set;
[0045] The region of interest extraction and segmentation module is used to extract the region of interest from the training ray image and divide the region of interest into several sub-region blocks to obtain a set of images to be processed including the several sub-region blocks, wherein each sub-region block in the set of images to be processed is an image to be processed.
[0046] The grayscale threshold determination module is used to determine the minimum target grayscale value and the maximum target grayscale value of each image in the image set to be processed;
[0047] The window width and window level determination module is used to determine the window width and window level corresponding to each image in the image set to be processed based on the minimum target gray value and the maximum target gray value of each image in the image set to be processed.
[0048] The image grayscale mapping module is used to map the pixel grayscale values of each image in the image set to be processed according to the window width and window level of the image and using a preset grayscale mapping rule to obtain the grayscale mapped image of the image.
[0049] The multi-channel image group construction module is used to construct a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed.
[0050] The model training module is used to train the detection model using the multi-channel image group.
[0051] By employing the above technical solution, the detection model training method provided in this application, after obtaining the training ray image, does not directly use the training ray image to train the detection model. Instead, it extracts the region of interest from the training ray image, divides the region of interest into several sub-region blocks, and determines the minimum and maximum target gray values of each sub-region block. Then, based on the minimum and maximum target gray values of each sub-region block, it determines the window width and window level corresponding to each sub-region block. Finally, based on the window width and window level corresponding to each sub-region block, it maps the pixel gray values of each sub-region block using a preset gray-scale mapping rule. Through this mapping process, the details of the region of interest can be highlighted, improving the detection model's performance. To improve the readability of regions of interest, after obtaining the grayscale images corresponding to each sub-region, the training ray image and the grayscale images corresponding to each sub-region are constructed into a multi-channel image group. The detection model is trained using the multi-channel image group. Compared with directly training the detection model using the training ray image, training the detection model using the multi-channel image group enables the model to capture more comprehensive details in the image, thereby effectively improving the detection and recognition capabilities of the detection model. That is, the detection model training method provided in this application can train a detection model with better detection performance. Then, by using this detection model to detect the target ray image, more accurate detection results can be obtained. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0053] Figure 1 A schematic flowchart illustrating the detection model training method provided in this application embodiment;
[0054] Figure 2 This is a schematic diagram illustrating the extraction and division of the region of interest from the training ray image.
[0055] Figure 3 A schematic diagram for obtaining a multi-channel image group;
[0056] Figure 4 The training loss curve is obtained by directly using the original training ray images to train the detection model;
[0057] Figure 5 The training loss curve for training a detection model using the detection model training method provided in the embodiments of this application;
[0058] Figure 6 This diagram illustrates a performance comparison between the detection model trained directly using the original training ray images and the detection model trained using the training method provided in this application.
[0059] Figure 7 This is a schematic diagram of the structure of a detection model training device provided in an embodiment of this application. Detailed Implementation
[0060] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0061] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0062] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0063] Given the unsatisfactory detection performance of existing methods, the current strategy is to optimize model performance by enriching the amount of training data and increasing the number of training iterations. Specifically, after constructing the training ray image set, image enhancement techniques are used to augment the training ray images in the training ray image set (such as random offsetting, rotation, flipping, etc.) to expand the training ray image set. That is, image enhancement techniques are used to enhance the training ray images in the training ray image set, and the enhanced ray images are added as new training ray images to the training ray image set. This increases the quantity and diversity of training ray images. In addition, increasing the number of model training iterations allows the model to fit the data more fully, thereby improving the model's generalization ability and detection accuracy.
[0064] While the aforementioned solutions can improve the detection performance of the detection model, some problems still exist, such as high resource consumption and low training efficiency. Using image enhancement techniques to generate new training ray images can enrich the training data, but it also significantly increases the model's training time. Generating new training ray images not only places higher demands on storage and computing resources, but also extends the training time as the number of model iterations increases, resulting in longer resource occupation periods before they can be released. This contradiction between high resource consumption and low training efficiency limits the rapid deployment and efficient operation of the detection model in practical applications.
[0065] To address the problems of the aforementioned strategies, this application proposes a detection model training method, which will be described in the following embodiments.
[0066] Please see Figure 1 The diagram illustrates a flowchart of the detection model training method provided in this application embodiment, which may include:
[0067] Step S101: Obtain training ray images from the training ray image set.
[0068] The training ray image set includes multiple labeled training ray images.
[0069] The detection model training method provided in this embodiment can be applied to many scenarios, such as X-ray workpiece defect detection and X-ray lesion detection.
[0070] For example, in the scenario of X-ray workpiece defect detection, the training X-ray image set includes multiple training X-ray images labeled with workpiece defect information (such as defect location, defect type, etc.).
[0071] Step S102: Extract the region of interest from the training ray image and divide the region of interest into several sub-region blocks to obtain a set of images to be processed, including several sub-region blocks.
[0072] Each sub-region block in the set of images to be processed is an image to be processed.
[0073] In one possible implementation, the location of the region of interest can be pre-defined, and the region of interest can be extracted from the training ray image based on the location of the region of interest. In order to process different parts of the region of interest in detail, this embodiment further divides the region of interest into several sub-region blocks after extracting the region of interest.
[0074] In one possible implementation, the number of blocks can be preset, and then the region of interest can be divided according to the preset number of blocks. When dividing the region of interest, an average division method can be used. Of course, this embodiment is not limited to this. For example, a non-average division method can also be used to divide the region of interest.
[0075] For example, the training ray image is a 1024×1024 pixel 16-bit grayscale ray image, and the region of interest is located at (256, 256, 768, 768), where (256, 256) is the top-left corner coordinate and (768, 768) is the bottom-right corner coordinate. Figure 2 As shown, a 512×512 pixel region of interest is extracted from the training ray image based on the location of the region of interest (256, 256, 768, 768). After extracting the 512×512 pixel region of interest, it is divided into four regions on an even basis, resulting in four 256×256 pixel sub-region blocks.
[0076] In one possible implementation, the image set to be processed can be composed of several sub-region blocks obtained by dividing the region of interest into a set for subsequent processing.
[0077] In some application scenarios, such as X-ray defect detection, defects may not only appear in the region of interest of the X-ray image, but may also appear outside the region of interest. In view of this, in order to obtain more accurate and comprehensive detection results, another possible implementation is to form a set of images to be processed by dividing the region of interest into several sub-region blocks and training X-ray images for subsequent processing. That is, in addition to processing the sub-region blocks, the training X-ray images are also processed.
[0078] Step S103: Determine the minimum and maximum target gray values of each image in the image set to be processed, and determine the window width and window level corresponding to each image in the image set to be processed based on the minimum and maximum target gray values of each image in the image set to be processed.
[0079] This embodiment uses windowing technology to process each image in the image set to highlight the details in the image, improve the readability of the image, and thus improve the training effect of the detection model.
[0080] Specifically, first determine the minimum and maximum target gray values of each image in the image set to be processed, that is, determine the target gray value range of each image in the image set to be processed. Then, based on the minimum and maximum target gray values of each image in the image set to be processed, determine the window width and window level corresponding to each image in the image set to be processed. Next, execute step S104.
[0081] In this embodiment, different window widths and window levels can be determined for different images in the image set to be processed. For example, different window widths and window levels can be determined for each sub-region block. Based on different window widths and window levels, different parts of the region of interest can be processed in detail.
[0082] Step S104: For each image in the image set to be processed, according to the window width and window level corresponding to the image, the pixel gray values of the image are mapped using a preset gray-scale mapping rule to obtain the gray-scale mapped image corresponding to the image.
[0083] The image set to be processed includes several sub-region blocks obtained by dividing the region of interest. For each sub-region block, the pixel grayscale values of the sub-region block are mapped according to the window width and window level of the sub-region block using a preset grayscale mapping rule, resulting in the grayscale mapped image of the sub-region block. By mapping the pixel grayscale values of each sub-region block, the details of the region of interest can be highlighted.
[0084] If the set of images to be processed includes training ray images, then according to the window width and window level corresponding to the training ray images, the pixel gray values of the training ray images are mapped using preset gray-scale mapping rules to obtain the gray-scale mapped image corresponding to the training ray images. Compared with the training ray images, the details (such as edge details) of the gray-scale mapped image corresponding to the training ray images are more prominent.
[0085] Step S105: Construct a multi-channel image group by mapping the grayscale images corresponding to the training ray image and each image in the image set to be processed.
[0086] For example, the region of interest in the training ray image is divided into four regions on average, resulting in four sub-region blocks, such as... Figure 3 As shown, the pixel grayscale values of the training ray image are mapped to obtain the grayscale mapped image corresponding to the training ray image. The pixel grayscale values of the four sub-region blocks are mapped respectively to obtain the grayscale mapped images corresponding to the four sub-region blocks. The training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped images corresponding to the four sub-region blocks are constructed into a 6-channel image group.
[0087] Step S106: Train the detection model using a multi-channel image group.
[0088] Specifically, the multi-channel image set is input into the detection model. The detection model extracts features from the input multi-channel image set and gives the detection result (such as the workpiece defect detection result) based on the extracted features. The model prediction loss is determined based on the detection result (such as the workpiece defect detection result) and the information of the training ray image annotation (such as the annotated workpiece defect information). The parameters of the detection model are updated based on the model prediction loss.
[0089] The detection model is trained iteratively multiple times according to the above process until the training termination conditions are met (such as model convergence, reaching the preset number of training iterations, etc.).
[0090] The detection model training method provided in this application does not directly train the detection model using training ray images from the training ray image set. Instead, it extracts the region of interest (ROI) from the training ray images. To process different parts of the ROI in detail, the ROI is divided into several sub-region blocks, and the minimum and maximum target gray values of each sub-region block are determined. Then, based on the minimum and maximum target gray values of each sub-region block, the window width and window level corresponding to each sub-region block are determined. Finally, based on the window width and window level of each sub-region block, the pixel gray values of each sub-region block are mapped using a preset gray-scale mapping rule. Through this mapping process, the details of the ROI can be highlighted, improving its readability. The model training effect can also be improved by mapping the pixel grayscale values of the training ray image in the same way. After obtaining the grayscale mapped images corresponding to each sub-region block and the grayscale mapped images corresponding to the training ray image, the training ray image, the grayscale mapped images corresponding to the training ray image, and the grayscale mapped images corresponding to each sub-region block are constructed into a multi-channel image group. The detection model is trained using the multi-channel image group. Compared with directly training the detection model using the training ray image, training the detection model using the multi-channel image group allows the model to capture more comprehensive details in the image, thereby effectively improving the detection and recognition ability of the detection model. That is, the detection model training method provided in this application embodiment can train a detection model with better detection performance. In addition, the detection model training method provided in this application embodiment does not require expanding the training ray image set with image enhancement technology, nor does it require increasing the number of model training iterations to obtain a detection model with better detection performance.
[0091] In another embodiment of this application, the specific implementation process of "step S103: determine the minimum target gray value and the maximum target gray value of each image in the image set to be processed, and determine the window width and window level corresponding to each image in the image set to be processed based on the minimum target gray value and the maximum target gray value of each image in the image set to be processed" in the above embodiment will be described.
[0092] First, we will introduce the specific implementation process for determining the minimum and maximum target gray values of each image in the image set to be processed.
[0093] The process of determining the minimum and maximum target gray values for each image in the image set to be processed may include:
[0094] Step a1: For each image in the image set to be processed, scale the image by a preset scaling factor to obtain a thumbnail of the image.
[0095] Given the different sizes of the training ray image and the sub-region blocks, different scaling factors can be used for scaling.
[0096] Step a2: Calculate the grayscale histogram of the image thumbnail to obtain the corresponding grayscale histogram of the image.
[0097] It should be noted that in this embodiment, the image may not be scaled, and the grayscale histogram may be calculated directly to obtain the grayscale histogram corresponding to the image.
[0098] Step a3: Determine the minimum and maximum target gray values of the image based on the preset gray range ratio and the gray histogram corresponding to the image.
[0099] The grayscale range ratio is the proportion of the retained grayscale range to the entire grayscale range, such as 0.995.
[0100] Specifically, the cumulative probability distribution is calculated based on the grayscale histogram corresponding to the image, and the minimum and maximum target grayscale values of the image are determined based on the preset grayscale range ratio and the cumulative probability distribution.
[0101] Assuming the training ray image is an N-bit grayscale ray image, then the grayscale range of the N-bit grayscale ray image is [0, M], where M is 2. N -1, correspondingly, for each image in the image set to be processed, the gray range of the gray histogram corresponding to that image is [0, M].
[0102] For each image in the image set to be processed, the process of calculating the cumulative probability distribution based on the gray-level histogram of the image includes: calculating the cumulative sum corresponding to each gray value in the range [0, M] based on the gray-level histogram of the image (the cumulative sum corresponding to a gray value is the cumulative number of pixels from 0 to that gray value); normalizing the cumulative sum corresponding to each gray value in the range [0, M] based on the size of the image to obtain the cumulative probability corresponding to each gray value in the range [0, M]; and forming the cumulative probability distribution from the cumulative probabilities corresponding to each gray value in the range [0, M].
[0103] If the preset grayscale range ratio is represented as fraction, the minimum target grayscale value as threshold_low, and the maximum target grayscale value as threshold_high, then:
[0104] threshold_low=np.searchsorted(P,1-fraction) (1);
[0105] threshold_high=np.searchsorted(P, fraction)-1 (2).
[0106] Where P represents the cumulative probability distribution, np.searchsorted(P,1-fraction) means finding the gray value whose cumulative probability first exceeds 1-fraction, and np.searchsorted(P, fraction)-1 means finding the gray value whose cumulative probability first exceeds fraction.
[0107] The minimum and maximum target gray values of each image in the image set to be processed can be obtained through the above process.
[0108] After obtaining the minimum and maximum target gray values of each image in the image set to be processed, the window width and window level of each image in the image set to be processed are further determined based on the minimum and maximum target gray values of each image in the image set to be processed.
[0109] Specifically, for each image in the image set to be processed, the window width and window level can be determined according to the minimum and maximum target gray values of the image using the following formula:
[0110] ww=threshold_high-threshold_low+1 (3);
[0111] wl=(threshold_high+threshold_low) / 2 (4).
[0112] Where threshold_high is the maximum target gray value of the image, threshold_low is the minimum target gray value of the image, ww is the window width of the image, and wl is the window level of the image.
[0113] In another embodiment of this application, the specific implementation process of "step S104: for each image in the image set to be processed, according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, the pixel grayscale value of the image is mapped to obtain the grayscale mapped image corresponding to the image" in the above embodiment will be described.
[0114] There are multiple ways to implement step S104. This embodiment provides the following three implementation methods.
[0115] First implementation method:
[0116] Step b1: For each image in the image set to be processed, based on the window width and window level corresponding to the image, use the preset grayscale mapping rules to map each grayscale value in the range [0, M] to obtain the grayscale mapping table corresponding to the image.
[0117] The training ray image is an N-bit grayscale ray image, with a grayscale range of [0, M], where M is 2. N -1. For example, the training ray image is a 16-bit ray grayscale image, and the grayscale range of the 16-bit ray grayscale image is [0, 65535].
[0118] The grayscale mapping table contains grayscale values in the range [0, M] and their corresponding mapped grayscale values in the range [0, M]. In one possible implementation, the mapping table can be an array of length M+1, with indices from 0 to M. The indices represent the original grayscale values, and the values are the mapped grayscale values corresponding to the original grayscale values.
[0119] The grayscale mapping rules are as follows:
[0120] (5).
[0121] For any gray value x in the range [0, M], if the gray value x is less than If the grayscale value x is greater than 0, then the grayscale value is mapped to 0. Then the grayscale value is mapped to M. If the grayscale value x is greater than or equal to M, then the grayscale value is mapped to M. and less than or equal to Then the grayscale value is mapped to
[0122] Step b2: Based on the grayscale mapping table corresponding to the image, map the pixel grayscale values of the image to obtain the grayscale mapped image.
[0123] In one possible implementation, the image can be tiled into a one-dimensional array, where each element of the one-dimensional array is the grayscale value of a pixel in the image. For each grayscale value in the one-dimensional array, the mapped grayscale value corresponding to the grayscale value is obtained by querying the grayscale mapping table corresponding to the image. The grayscale value in the one-dimensional array is replaced with the mapped grayscale value corresponding to the grayscale value. Based on the one-dimensional array after the grayscale value replacement, the grayscale mapped image corresponding to the image is generated.
[0124] The second implementation method:
[0125] Step c1: For each image in the image set to be processed, construct the initial grayscale mapping table corresponding to that image.
[0126] The initial grayscale mapping table contains grayscale values in the range [0, M], and the mapped grayscale values corresponding to each grayscale value in the range [0, M] are empty. In one possible implementation, the mapping table can be an array of length M+1, with indices from 0 to M, and the initial array values are empty.
[0127] Step c2: For each pixel in the image, query the grayscale mapping table corresponding to the image to see if there is a mapped grayscale value corresponding to the grayscale value of the pixel.
[0128] Step c3-a: If the grayscale mapping table corresponding to the image does not contain the mapped grayscale value corresponding to the grayscale value of the pixel, then according to the window width and window level corresponding to the image, the grayscale value of the pixel is mapped using the preset grayscale mapping rules to obtain the mapped grayscale value corresponding to the grayscale value of the pixel, and the mapped grayscale value corresponding to the grayscale value of the pixel is stored in the grayscale mapping table corresponding to the image.
[0129] If the grayscale mapping table corresponding to the image does not contain the grayscale value of the pixel, then the grayscale value of the pixel is mapped directly using the grayscale mapping rule (such as the grayscale mapping rule in formula (5) above) according to the window width and window level corresponding to the image. After obtaining the mapped grayscale value corresponding to the grayscale value of the pixel, the mapped grayscale value corresponding to the grayscale value of the pixel is stored in the grayscale mapping table. In this way, when it is necessary to map the same grayscale value, the mapped grayscale value can be obtained directly from the grayscale mapping table without mapping based on the grayscale mapping rule.
[0130] Step c3-b: If the grayscale mapping table corresponding to the grayscale value of the pixel exists, then the mapped grayscale value corresponding to the grayscale value of the pixel is directly obtained from the grayscale mapping table corresponding to the image.
[0131] If the grayscale value of a pixel exists in the grayscale mapping table corresponding to the pixel's grayscale value, the mapped grayscale value of the pixel can be obtained directly from the grayscale mapping table without needing to perform mapping based on grayscale mapping rules.
[0132] Step c4: Generate the gray-mapped image corresponding to the image based on the gray values of each pixel in the image and their corresponding mapped gray values.
[0133] After obtaining the mapped gray values corresponding to the gray values of each pixel in the image, the ray image can be reconstructed based on the mapped gray values corresponding to the gray values of each pixel in the image, thereby obtaining the gray-mapped image corresponding to the image.
[0134] In one possible implementation, the image can be tiled into a one-dimensional array, where each element of the one-dimensional array is the gray value of a pixel in the image. For each gray value in the one-dimensional array, after obtaining the mapped gray value corresponding to the gray value based on the gray-level mapping rules or the gray-level mapping table corresponding to the image, the gray value in the one-dimensional array is replaced with the mapped gray value. Based on the one-dimensional array after the gray value replacement, the gray-level mapped image corresponding to the image is generated.
[0135] The third implementation method:
[0136] Step d1: For each image in the image set to be processed, based on the window width and window level corresponding to the image, directly use the preset grayscale mapping rules to map the grayscale value of each pixel of the image to obtain the mapped grayscale value corresponding to the grayscale value of each pixel of the image.
[0137] For each pixel of the image, based on the window width and window level corresponding to the image, the gray value of the pixel is mapped using a preset gray-scale mapping rule (such as the gray-scale mapping rule in formula (5) above) to obtain the mapped gray value corresponding to the gray value of the pixel.
[0138] Compared to the two implementation methods mentioned above, this embodiment directly uses a preset grayscale mapping rule to map the grayscale value of each pixel in the image, without the need to construct a grayscale mapping table.
[0139] Step d2: Generate the gray-mapped image corresponding to the image based on the gray values of each pixel in the image.
[0140] In one possible implementation, the image can be tiled into a one-dimensional array, where each element of the one-dimensional array is the gray value of a pixel in the image. For each gray value in the one-dimensional array, after obtaining the mapped gray value corresponding to the gray value based on the gray-scale mapping rule, the gray value in the one-dimensional array is replaced with the mapped gray value corresponding to the gray value. Based on the one-dimensional array after the gray value replacement, the gray-scale mapped image corresponding to the image is generated.
[0141] In another embodiment of this application, the specific implementation process of "step S105: constructing a multi-channel image group by mapping the grayscale images corresponding to the training ray image and each image in the image set to be processed" in the above embodiment is described.
[0142] When the image set to be processed contains training ray images and several sub-region blocks, the process of constructing a multi-channel image group from the grayscale mapping images corresponding to the training ray images and each image in the image set to be processed can include:
[0143] Step e1: For each sub-region block, by filling the area around the grayscale mapped image corresponding to the sub-region block with pixels of a set grayscale value, an image of the same size as the training ray image is constructed, thus obtaining the grayscale mapped extended image corresponding to the sub-region block.
[0144] In one possible implementation, an image of the same size as the training ray image can be constructed by filling the image with pixels of grayscale value 0 around the grayscale mapped image corresponding to the sub-region block.
[0145] The position of the grayscale mapped image corresponding to the sub-region block in the expanded image corresponding to the grayscale mapped image of the sub-region block is the same as the position of the sub-region block in the training ray image.
[0146] Step e2: Combine the training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped extended images corresponding to several sub-region blocks into a multi-channel image group.
[0147] A multi-channel image group can be obtained by stitching together the training ray image, the corresponding grayscale-mapped image of the training ray image, and the grayscale-mapped extended images corresponding to several sub-region blocks. The multi-channel image group can be represented as:
[0148] Result_images=[original_image, processed_image, processed_block1,…, processed_blockm] (6).
[0149] Wherein, original_image represents the training ray image, processed_image represents the image after mapping corresponding to the training ray image, there are m sub-region blocks, processed_block1 represents the grayscale extended image corresponding to the first sub-region block, processed_blockm represents the grayscale extended image corresponding to the m-th sub-region block, and Result_images is the multi-channel image group.
[0150] It should be noted that if the image set to be processed does not contain the training ray image, then the training ray image and the grayscale maps corresponding to several sub-region blocks are combined into a multi-channel image group, that is:
[0151] Result_images=[original_image, processed_block1,…, processed_blockm](7).
[0152] After obtaining the multi-channel image set, it can be input into the detection model for training. During training, Automated Model Optimization (AutoML) is employed to automatically adjust the model's hyperparameters and conduct multiple trials, thereby obtaining more feedback. By continuously trying different combinations of hyperparameters, the model has more opportunities to converge towards the optimal direction, ultimately achieving higher accuracy and better generalization.
[0153] It should be noted that since this application inputs multi-channel image groups into the detection model for training, the structure of the detection model needs to be adapted to the input. In one possible implementation, a detection model adapted to the input can be constructed. In another possible implementation, the structure of the detection model with the training ray image as input can be adjusted. For example, the network width can be increased (width expansion), and the number of channels can be increased in each branch or each convolutional layer to adapt to the input, so that the model can capture more feature patterns and better identify and segment small and complex objects.
[0154] In model training based on a batch of 16-bit grayscale ray images of 3000×2500 pixels, when training the detection model using multi-channel image groups obtained by processing the original training ray images, the average loss obtained after an average of about 200 training iterations is 0.07. Figure 4 As shown, when directly training the detection model using the original training ray images, it takes an average of more than 500 iterations to achieve the same fitting trend. Therefore, the detection model training method provided in this application significantly reduces the time required for resource consumption. Figure 5 As shown.
[0155] Taking X-ray workpiece defect detection as an example, the detection model trained using the detection model training method provided in this application significantly improves the detection of small defects (i.e., the model's false negative rate). Figure 6 As shown, the cross-union ratio (CUN) between the defect regions predicted by the model and the actual defect regions increased from about 40% (about 40% is the CUN between the defect regions predicted by the detection model and the actual defect regions obtained by directly training the original training ray images) to 75%. It can be seen that the prediction accuracy has been greatly improved. For the same batch of ray images and labeled data, both precision and recall have been effectively improved, which also shows that the generalization ability of the model has been improved.
[0156] Based on the detection model training method provided in the above embodiments, this application also provides a detection method, which may include:
[0157] Step f1: Obtain the target ray image.
[0158] The target ray image is the ray image to be detected, such as the ray image to be detected in the scenario of ray workpiece defect detection.
[0159] Step f2: Detect the target ray image based on the pre-trained detection model.
[0160] The detection model was trained using the detection model training method provided in the above embodiments.
[0161] Since the detection model in this embodiment is trained using the detection model training method provided in the above embodiment, it has a strong detection and recognition capability. Therefore, based on this detection model, a more accurate detection result can be obtained when detecting the target ray image.
[0162] This application also provides an apparatus for performing the detection model training method provided in the above embodiments. Please refer to... Figure 7 , Figure 7 This is a schematic diagram of the structure of a detection model training device provided in an embodiment of this application. The detection model training device may include: a training ray image acquisition module 701, a region of interest extraction and segmentation module 702, a grayscale threshold determination module 703, a window width and window level determination module 704, an image grayscale mapping module 705, a multi-channel image group construction module 706, and a model training module 707.
[0163] The training ray image acquisition module 701 is used to acquire training ray images from the training ray image set.
[0164] The region of interest extraction and segmentation module 702 is used to extract the region of interest from the training ray image and divide the region of interest into several sub-region blocks to obtain a set of images to be processed, each sub-region block in the set of images to be processed is an image to be processed.
[0165] The grayscale threshold determination module 703 is used to determine the minimum target grayscale value and the maximum target grayscale value of each image in the image set to be processed.
[0166] The window width and window level determination module 704 is used to determine the window width and window level of each image in the image set to be processed based on the minimum and maximum target gray values of each image.
[0167] The image grayscale mapping module 705 is used to map the pixel grayscale values of each image in the image set to be processed according to the window width and window level of the image and using a preset grayscale mapping rule to obtain the grayscale mapped image of the image.
[0168] The multi-channel image group construction module 706 is used to construct a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed.
[0169] Model training module 707 is used to train the detection model using a multi-channel image group.
[0170] In one possible implementation, the set of images to be processed also includes training ray images.
[0171] The multi-channel image group construction module 706, when constructing a multi-channel image group from the grayscale mappings of the training ray image and each image in the image set to be processed, is specifically used for:
[0172] The training ray image, the grayscale image corresponding to the training ray image, and the grayscale images corresponding to several sub-region blocks are constructed into a multi-channel image group.
[0173] In one possible implementation, the grayscale threshold determination module 703, when determining the minimum and maximum target grayscale values for each image in the image set to be processed, is specifically used for:
[0174] For each image in the set of images to be processed:
[0175] The image is scaled according to a preset scaling factor to obtain a thumbnail of the image.
[0176] Calculate the grayscale histogram of the image thumbnail to obtain the corresponding grayscale histogram of the image;
[0177] Based on the preset grayscale range ratio and the grayscale histogram corresponding to the image, the minimum target grayscale value and the maximum target grayscale value of the image are determined, wherein the grayscale range ratio is the proportion of the retained grayscale range to the entire grayscale range.
[0178] The training ray image is an N-bit grayscale ray image, with a grayscale range of [0, M], where M is 2. N -1.
[0179] In one possible implementation, the image grayscale mapping module 705, when mapping the pixel grayscale values of each image in the image set to be processed according to the corresponding window width and window level using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, is specifically used for:
[0180] Based on the window width and window level corresponding to the image, each gray value in the range [0, M] is mapped using a preset gray-scale mapping rule to obtain the gray-scale mapping table corresponding to the image. The gray-scale mapping table contains each gray value in the range [0, M] and the mapped gray values corresponding to each gray value in the range [0, M].
[0181] Based on the grayscale mapping table corresponding to the image, the pixel grayscale values of the image are mapped to obtain the grayscale mapped image.
[0182] In one possible implementation, when the image grayscale mapping module 705 maps the pixel grayscale values of the image according to the grayscale mapping table corresponding to the image to obtain the grayscale mapped image, it is specifically used for:
[0183] The image is tiled into a one-dimensional array, where each element of the array is the grayscale value of a pixel in the image.
[0184] For each gray value in the one-dimensional array, the mapped gray value corresponding to the gray value is obtained by querying the gray-scale mapping table corresponding to the image, and the mapped gray value corresponding to the gray value is used to replace the gray value in the one-dimensional array.
[0185] Generate the corresponding grayscale mapped image based on the one-dimensional array after grayscale value replacement.
[0186] In one possible implementation, the image grayscale mapping module 705, when mapping the pixel grayscale values of each image in the image set to be processed according to the corresponding window width and window level using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, is specifically used for:
[0187] Construct an initial grayscale mapping table corresponding to the image. The initial grayscale mapping table includes grayscale values in the range [0, M]. The mapped grayscale values corresponding to each grayscale value in the range [0, M] are empty.
[0188] For each pixel in the image, query the grayscale mapping table corresponding to the image to see if there is a mapped grayscale value corresponding to the grayscale value of that pixel;
[0189] If not, then based on the window width and window level corresponding to the image, the gray value of the pixel is directly mapped using the preset gray-scale mapping rules to obtain the mapped gray value corresponding to the gray value of the pixel, and the mapped gray value corresponding to the gray value of the pixel is stored in the gray-scale mapping table corresponding to the image; if yes, then the mapped gray value corresponding to the gray value of the pixel is directly obtained from the gray-scale mapping table corresponding to the image.
[0190] Based on the mapped gray values of each pixel in the image, generate the corresponding gray-mapped image.
[0191] In one possible implementation, the image grayscale mapping module 705, when mapping the pixel grayscale values of each image in the image set to be processed according to the corresponding window width and window level using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, is specifically used for:
[0192] For each pixel in the image, based on the window width and window level corresponding to the image, the gray value of the pixel is mapped using a preset gray-scale mapping rule to obtain the mapped gray value corresponding to the gray value of the pixel.
[0193] Based on the mapped gray values of each pixel in the image, generate the corresponding gray-mapped image.
[0194] In one possible implementation, the image set to be processed also includes training ray images. The multi-channel image group construction module 706, when constructing a multi-channel image group from the training ray images and the grayscale-mapped images corresponding to each image in the image set to be processed, is specifically used for:
[0195] For each sub-region block, by filling the surrounding image of the gray-mapped image corresponding to the sub-region block with pixels of a set gray value, an image of the same size as the training ray image is constructed, and the gray-mapped extended image corresponding to the sub-region block is obtained. The position of the gray-mapped image corresponding to the sub-region block in the gray-mapped extended image corresponding to the sub-region block is the same as the position of the sub-region block in the training ray image.
[0196] The training ray image, the grayscale image corresponding to the training ray image, and the grayscale extended images corresponding to several sub-region blocks are combined into a multi-channel image group.
[0197] The detection model is trained using the detection model training device provided in this application embodiment, which enables the model to capture more comprehensive details in the image, thereby effectively improving the detection and recognition capabilities of the detection model. In other words, a detection model with better detection performance can be trained using the detection model training device provided in this application embodiment.
[0198] This application also provides an electronic device, which may include at least one processor and a memory connected to the processor.
[0199] The processor may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application; the memory may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage.
[0200] The memory is used to store computer programs, and the processor is used to execute the computer programs so that the electronic device can implement the steps of the detection model training method and / or detection method provided in the above embodiments.
[0201] This application also provides a computer storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the steps of the detection model training method and / or detection method provided in the above embodiments.
[0202] This application also provides a computer program product, including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement the steps of the detection model training method and / or detection method provided in the above embodiments.
[0203] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0204] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0205] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0206] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, 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, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A method for training a detection model, characterized in that, include: Obtain training ray images from the training ray image set; The region of interest is extracted from the training ray image, and the region of interest is divided into several sub-region blocks to obtain a set of images to be processed, including the several sub-region blocks. Each sub-region block in the set of images to be processed is an image to be processed. The minimum and maximum target gray values of each image in the image set to be processed are determined, and the window width and window level corresponding to each image in the image set to be processed are determined based on the minimum and maximum target gray values of each image in the image set to be processed. For each image in the set of images to be processed, the pixel grayscale values of the image are mapped according to the window width and window level of the image, using a preset grayscale mapping rule, to obtain the grayscale mapped image of the image. The training ray image and the grayscale mapped images corresponding to each image in the image set to be processed are respectively constructed into a multi-channel image group; The detection model was trained using the multi-channel image set; The set of images to be processed also includes the training ray images; The step of constructing a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed includes: For each sub-region block, by filling the area around the grayscale mapped image corresponding to the sub-region block with pixels of a set grayscale value, an image of the same size as the training ray image is constructed, resulting in the grayscale mapped extended image corresponding to the sub-region block. The position of the grayscale mapped image corresponding to the sub-region block in the grayscale mapped extended image corresponding to the sub-region block is the same as the position of the sub-region block in the training ray image. The training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped extended images corresponding to the several sub-region blocks are combined into a multi-channel image group.
2. The detection model training method according to claim 1, characterized in that, The set of images to be processed also includes the training ray images; The step of constructing a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed includes: The training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped images corresponding to the several sub-region blocks are constructed into a multi-channel image group.
3. The detection model training method according to claim 1, characterized in that, Determining the minimum and maximum target grayscale values for each image in the image set to be processed includes: For each image in the set of images to be processed: The image is scaled according to a preset scaling factor to obtain a thumbnail of the image. Calculate the grayscale histogram of the image thumbnail to obtain the corresponding grayscale histogram of the image; Based on the preset grayscale range ratio and the grayscale histogram corresponding to the image, the minimum target grayscale value and the maximum target grayscale value of the image are determined, wherein the grayscale range ratio is the proportion of the retained grayscale range to the entire grayscale range.
4. The detection model training method according to claim 1, characterized in that, The training ray image is an N-bit grayscale ray image, and the grayscale range of the N-bit grayscale ray image is [0, M], where M is 2. N -1; The step of mapping the pixel grayscale values of the image according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, includes: Based on the window width and window level corresponding to the image, each gray value in the range [0, M] is mapped using a preset gray-scale mapping rule to obtain the gray-scale mapping table corresponding to the image. The gray-scale mapping table contains each gray value in the range [0, M] and the mapped gray values corresponding to each gray value in the range [0, M]. Based on the grayscale mapping table corresponding to the image, the pixel grayscale values of the image are mapped to obtain the grayscale mapped image.
5. The detection model training method according to claim 4, characterized in that, The step of mapping the pixel grayscale values of the image according to the grayscale mapping table corresponding to the image to obtain the grayscale mapped image includes: The image is tiled into a one-dimensional array, where each element of the one-dimensional array is the grayscale value of a pixel in the image; For each gray value in the one-dimensional array, the mapped gray value corresponding to the gray value is obtained by querying the gray-scale mapping table corresponding to the image, and the mapped gray value corresponding to the gray value is used to replace the gray value in the one-dimensional array. Generate the corresponding grayscale mapped image based on the one-dimensional array after grayscale value replacement.
6. The detection model training method according to claim 1, characterized in that, The training ray image is an N-bit grayscale ray image, and the grayscale range of the N-bit grayscale ray image is [0, M], where M is 2. N -1; The step of mapping the pixel grayscale values of the image according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, includes: Construct an initial grayscale mapping table corresponding to the image. The initial grayscale mapping table includes grayscale values in the range [0, M]. The mapped grayscale values corresponding to each grayscale value in the range [0, M] are empty. For each pixel in the image, query the grayscale mapping table corresponding to the image to see if there is a mapped grayscale value corresponding to the grayscale value of that pixel; If not, then based on the window width and window level corresponding to the image, the gray value of the pixel is mapped using a preset gray-scale mapping rule to obtain the mapped gray value corresponding to the gray value of the pixel, and the mapped gray value corresponding to the gray value of the pixel is stored in the gray-scale mapping table corresponding to the image; if yes, then the mapped gray value corresponding to the gray value of the pixel is directly obtained from the gray-scale mapping table corresponding to the image. Based on the mapped gray values of each pixel in the image, generate the corresponding gray-mapped image.
7. The detection model training method according to claim 1, characterized in that, The step of mapping the pixel grayscale values of the image according to the window width and window level corresponding to the image, using a preset grayscale mapping rule, to obtain the corresponding grayscale mapped image, includes: For each pixel in the image, based on the window width and window level corresponding to the image, the gray value of the pixel is mapped using a preset gray-scale mapping rule to obtain the mapped gray value corresponding to the gray value of the pixel. Based on the mapped gray values of each pixel in the image, generate the corresponding gray-mapped image.
8. A detection method, characterized in that, include: Acquire target ray image; The target ray image is detected using a pre-trained detection model, wherein the detection model is trained using the detection model training method as described in any one of claims 1 to 7.
9. A detection model training device, characterized in that, include: The training module includes a ray image acquisition module, a region of interest extraction and segmentation module, a grayscale threshold determination module, a window width and window level determination module, an image grayscale mapping module, a multi-channel image group construction module, and a model training module. The training ray image acquisition module is used to acquire training ray images from the training ray image set; The region of interest extraction and segmentation module is used to extract the region of interest from the training ray image and divide the region of interest into several sub-region blocks to obtain a set of images to be processed including the several sub-region blocks, wherein each sub-region block in the set of images to be processed is an image to be processed. The grayscale threshold determination module is used to determine the minimum target grayscale value and the maximum target grayscale value of each image in the image set to be processed; The window width and window level determination module is used to determine the window width and window level corresponding to each image in the image set to be processed based on the minimum target gray value and the maximum target gray value of each image in the image set to be processed. The image grayscale mapping module is used to map the pixel grayscale values of each image in the image set to be processed according to the window width and window level of the image and using a preset grayscale mapping rule to obtain the grayscale mapped image of the image. The multi-channel image group construction module is used to construct a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed. The model training module is used to train the detection model using the multi-channel image group; The image set to be processed also includes the training ray image; when the multi-channel image group construction module constructs a multi-channel image group from the training ray image and the grayscale mapped images corresponding to each image in the image set to be processed, it is specifically used for: For each sub-region block, by filling the area around the grayscale mapped image corresponding to the sub-region block with pixels of a set grayscale value, an image of the same size as the training ray image is constructed, resulting in the grayscale mapped extended image corresponding to the sub-region block. The position of the grayscale mapped image corresponding to the sub-region block in the grayscale mapped extended image corresponding to the sub-region block is the same as the position of the sub-region block in the training ray image. The training ray image, the grayscale mapped image corresponding to the training ray image, and the grayscale mapped extended images corresponding to the several sub-region blocks are combined into a multi-channel image group.