Model training method, method and device for predicting acetabular prosthesis implantation angle
By training the acetabular prosthesis implantation angle using a convolutional neural network model, the problems of high cost and low accuracy in existing technologies are solved, achieving efficient and accurate acetabular prosthesis positioning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-29
- Publication Date
- 2026-05-26
AI Technical Summary
Current methods for acetabular prosthesis implantation rely on customized 3D printing and the doctor's subjective experience, resulting in high material and time costs, as well as insufficient positioning accuracy and reliability.
A convolutional neural network model training method was adopted. By acquiring sample acetabular region images and angle data, the model parameters were adjusted to predict the abduction angle and anteversion angle of the acetabular prosthesis. The prediction accuracy was improved by using a Transformer encoder and a one-dimensional convolutional neural network module.
It reduces the cost of computer modeling and 3D printing, improves the positioning accuracy and reliability of acetabular prosthesis implantation angle, and reduces subjective errors by doctors.
Smart Images

Figure CN122089828A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of deep learning technology, and in particular to a model training method, a method and apparatus for predicting the implantation angle of an acetabular prosthesis. Background Technology
[0002] An acetabular prosthesis is a metal shell (usually made of titanium alloy) that mimics the "bowl-shaped" structure of the human pelvis, covered with an inner liner (such as a pad) made of high-molecular-weight polyethylene, ceramic, or other wear-resistant materials. Its function is to provide a stable support surface for the femoral head prosthesis, forming a new sliding bearing system. The acetabular prosthesis is a key component of total hip arthroplasty (THA), primarily used to replace diseased or damaged natural acetabular structures, restoring joint function and relieving pain. During implantation, the acetabular prosthesis needs to be installed according to the abduction and anteversion angles to ensure the patient can move freely after implantation, while minimizing the incidence of postoperative complications such as dislocation and acetabular impingement, and maximizing postoperative comfort. However, different patients often have different comfortable abduction and anteversion angles; therefore, individualized positioning is necessary to obtain the appropriate abduction and anteversion angles for each patient.
[0003] In related technologies, customized 3D printing guide plate technology or robot-assisted navigation technology are usually used. Through the three-dimensional model of the patient's femoral head, professional doctors use computer-aided simulation to test the degree of fit. In some cases, an actual printed model is needed to assess whether the expected abduction angle and anteversion angle are suitable for the patient.
[0004] However, the above methods waste a lot of material costs, and because computer modeling, simulation and 3D printing usually take a long time, they can also cause problems with untimely implantation. In addition, since the measurement of abduction angle and anteversion angle by positioning instruments during the operation mainly depends on the doctor's subjective experience, its accuracy and compatibility with the patient are often not high. Summary of the Invention
[0005] In view of the above problems, embodiments of this application provide a model training method, a method for predicting the acetabular prosthesis implantation angle, an apparatus, an electronic device, and a readable storage medium to overcome or at least partially solve the above problems.
[0006] In a first aspect, embodiments of this application provide a model training method, the method comprising: Acquire images of the acetabulum region, abduction angle, and anteversion angle of the sample patients; The sample acetabular region image is input into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model; Based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, the first model loss value of the first convolutional neural network model is determined. Based on the first model loss value, the model parameters and hyperparameters of the first convolutional neural network model are adjusted to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle of the target user's acetabular prosthesis based on the first acetabular region image of the target user.
[0007] Optionally, acquiring the acetabular region image of the sample patient includes: Obtain medical images of the femoral head of the sample patients; The acetabular region in the medical image of the femoral head of the sample is marked to obtain the image of the acetabular region of the sample.
[0008] Optionally, the first convolutional neural network model includes a Transformer encoder and a one-dimensional convolutional neural network module. The step of inputting the sample acetabular region image into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model includes: The sample acetabular region image is input into the Transformer encoder to obtain the first image code output by the Transformer encoder; The first image encoding is input into the one-dimensional convolutional neural network module to obtain the first predicted abduction angle and the first predicted forward tilt angle output by the one-dimensional convolutional neural network module.
[0009] Optionally, determining the first model loss value of the first convolutional neural network model based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle includes: Based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, the mean squared error loss value and the focus loss value of the first convolutional neural network model are determined respectively. Based on the mean squared error loss value and the focus loss value, the first model loss value of the first convolutional neural network model is determined.
[0010] Optionally, determining the first model loss value of the first convolutional neural network model based on the mean squared error loss value and the focus loss value includes: Determine the focus weight value of the focus loss value; Based on the focus weight value, the mean squared error loss value, and the focus loss value, the first model loss value of the first convolutional neural network model is determined.
[0011] Optionally, determining the first model loss value of the first convolutional neural network model based on the focus weight value, the mean squared error loss value, and the focus loss value includes: Calculate the first product of the focus weight value, the mean squared error loss value, and the focus loss value; Calculate the first weighted sum of the focus weight value, the mean squared error loss value, and the focus loss value; The ratio of the first product to the first weighted sum is calculated to obtain the first model loss value of the first convolutional neural network model.
[0012] Secondly, embodiments of this application provide a method for predicting the implantation angle of an acetabular prosthesis, the method comprising: Acquire images of the target acetabulum of the target patient; The image of the target acetabulum is input into the target acetabular prosthesis implantation angle prediction model to obtain the target predicted abduction angle and the target predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is obtained by the model training method described in any of the above; the target predicted abduction angle and the target predicted anteversion angle are used for the implantation positioning of the acetabular prosthesis in the target patient.
[0013] Thirdly, embodiments of this application provide a model training apparatus, the apparatus comprising: The first acquisition module is used to acquire images of the acetabulum region of the sample patient, the abduction angle of the sample, and the anteversion angle of the sample. The first input / output module is used to input the sample acetabular region image into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model. The determination module is used to determine the first model loss value of the first convolutional neural network model based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle. An adjustment module is used to adjust the model parameters and hyperparameters of the first convolutional neural network model based on the first model loss value to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle corresponding to the acetabular prosthesis of the target user based on the first acetabular region image of the target user.
[0014] Fourthly, embodiments of this application provide a device for predicting the implantation angle of an acetabular prosthesis, the device comprising: The second acquisition module is used to acquire images of the target acetabulum of the target patient. The second input / output module is used to input the image of the target acetabular region into the target acetabular prosthesis implantation angle prediction model to obtain the target predicted abduction angle and the target predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is obtained based on the model training method described in any of the above; the target predicted abduction angle and the target predicted anteversion angle are used for the implantation positioning of the acetabular prosthesis in the target patient.
[0015] Fifthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the model training method as described above, or the acetabular prosthesis implantation angle prediction method.
[0016] Sixthly, embodiments of this application provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the model training method described above, or the acetabular prosthesis implantation angle prediction method.
[0017] The specific beneficial effects are as follows: This embodiment of the application acquires a sample acetabular region image, sample abduction angle, and sample anteversion angle from a sample patient. The sample acetabular region image is input into a first convolutional neural network model to obtain a first predicted abduction angle and a first predicted anteversion angle output by the first convolutional neural network model. Based on the sample abduction angle, sample anteversion angle, first predicted abduction angle, and first predicted anteversion angle, a first model loss value is determined for the first convolutional neural network model. Based on the first model loss value, the model parameters and hyperparameters of the first convolutional neural network model are adjusted to obtain a target acetabular prosthesis implantation angle prediction model. The target acetabular prosthesis implantation angle prediction model is used to predict the first acetabular region angle based on the first acetabular region angle of the target user. The system generates images of the acetabular prosthesis and outputs the target abduction angle and target anteversion angle corresponding to the acetabular prosthesis of the target user. The first convolutional neural network model can be trained using acetabular prosthesis images and acetabular prosthesis implantation positioning data from different sample patients to obtain a target acetabular prosthesis implantation angle prediction model. When using the target acetabular prosthesis implantation angle prediction model for targeted positioning of the target patient, it can save the high material and time costs caused by computer modeling, simulation testing and 3D printing. At the same time, it can avoid excessive subjective evaluation errors by doctors to a certain extent, thereby improving the positioning accuracy and reliability of acetabular prosthesis implantation angle prediction to a certain extent. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A schematic flowchart illustrating a model training method provided in an embodiment of this application; Figure 2 A schematic diagram of a sample acetabular region image provided for an embodiment of this application; Figure 3 A schematic diagram of an abduction angle and a forward tilt angle provided for an embodiment of this application; Figure 4 A flowchart illustrating another model training method provided in an embodiment of this application; Figure 5 A flowchart illustrating a method for predicting the implantation angle of an acetabular prosthesis, provided in an embodiment of this application; Figure 6 A logic block diagram of a model training device provided in an embodiment of this application; Figure 7 A logic block diagram of a acetabular prosthesis implantation angle prediction device provided in the embodiments of this application; Figure 8 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.
[0021] Reference Figure 1 , Figure 1 This is a flowchart illustrating a model training method provided in an embodiment of this application. The method may include: Step 101: Obtain the sample acetabular region image, sample abduction angle, and sample anteversion angle of the sample patient.
[0022] In the embodiments of this application, the abduction angle refers to the angle between the acetabular prosthesis opening plane and the sagittal plane (similar to the degree of "bowl opening outwards"), with a value ranging from 35° to 50°. The anteversion angle refers to the angle between the acetabular prosthesis opening plane and the horizontal plane (the angle of forward tilt), with a value ranging from 15° to 25°. Desensitized images of the acetabular region taken by medical imaging equipment can be collected from a local hospital database and used as a training dataset. Simultaneously, the abduction and anteversion angles of the patient's acetabular prosthesis implantation, among other implantation positioning data, are used as annotations for the acetabular region images. This allows for the acquisition of sample acetabular region images, sample abduction angles, and sample anteversion angles from sample patients.
[0023] For example, such as Figure 2 and Figure 3 As shown, Figure 2 This is a schematic diagram of a sample acetabular region image provided in an embodiment of this application. Figure 3 This is a schematic diagram of an abduction angle and a forward tilt angle provided for an embodiment of this application. Figure 2 It can be used directly as a training sample, or the acetabulum area can be manually marked and the marked image can be used as a training sample. Figure 3 (1) is a schematic diagram of the abduction angle, (2) is a schematic diagram of the anteversion angle, and (3) is a schematic diagram of the acetabular prosthesis bone and the acetabular mounting recipient.
[0024] Step 102: Input the sample acetabular region image into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model.
[0025] In the embodiments of this application, a conventional convolutional neural network or its variants (such as ResNet, 1D CNN, etc.) can be used as the baseline network model for training, i.e., the first convolutional neural network model. Simultaneously, the output layer of the first convolutional neural network model can be improved by adding two independent output ports after the original output layer. The activation function of both output ports is a softmax function with weighted hyperparameters. In this way, the sample acetabular region image can be input into the first convolutional neural network model, thereby obtaining the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model.
[0026] Step 103: Based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, determine the first model loss value of the first convolutional neural network model.
[0027] In embodiments of this application, the mean squared error loss value or a combined loss value consisting of the mean squared error loss value and other types of loss values can be used as the first model loss value. The sample abduction angle and the first predicted abduction angle can be grouped together, and the sample anteversion angle and the first predicted anteversion angle can be grouped together, and their respective model loss values can be calculated separately. Considering that the abduction angle and anteversion angle have equal importance in prosthesis implantation, the model loss values calculated separately can be directly added together to obtain the first model loss value. If the first model loss value is a combined loss value, loss values of the same type can be directly added together, while loss values of different types can be weighted and summed according to their respective weights to obtain the first model loss value.
[0028] Step 104: Based on the first model loss value, adjust the model parameters and hyperparameters of the first convolutional neural network model to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle of the target user's acetabular prosthesis based on the first acetabular region image of the target user.
[0029] In the embodiments of this application, the model parameters and hyperparameters of the first convolutional neural network model can be adjusted based on the first model loss value to obtain a target acetabular prosthesis implantation angle prediction model. Here, the hyperparameters may include the weight hyperparameters of the model output port. Multiple adjustments can be made to the model parameters and hyperparameters. After each parameter adjustment, steps 101 to 104 can be repeated to adjust the parameters again. When the first model loss value of the first convolutional neural network model reaches a preset convergence condition (e.g., the number of consecutive occurrences of the first model loss value being less than a preset threshold meets the requirement, or the number of training iterations of the model meets the requirement), the adjustment of the model parameters and hyperparameters can be stopped, and the first convolutional neural network model obtained after the last parameter adjustment is determined as the target acetabular prosthesis implantation angle prediction model.
[0030] In the embodiments of this application, by acquiring the sample acetabular region image, sample abduction angle, and sample anteversion angle of the sample patient, the sample acetabular region image is input into a first convolutional neural network model to obtain the first predicted abduction angle and first predicted anteversion angle output by the first convolutional neural network model. Based on the sample abduction angle, sample anteversion angle, first predicted abduction angle, and first predicted anteversion angle, a first model loss value of the first convolutional neural network model is determined. Based on the first model loss value, the model parameters and hyperparameters of the first convolutional neural network model are adjusted to obtain a target acetabular prosthesis implantation angle prediction model. The target acetabular prosthesis implantation angle prediction model is used to predict the first acetabular prosthesis implantation angle based on the first predicted acetabular prosthesis implantation angle of the target user. The image of the acetabulum is used to output the target abduction angle and target anteversion angle of the acetabular prosthesis for the target user. The first convolutional neural network model can be trained using acetabular prosthesis images and acetabular prosthesis implantation positioning data from different sample patients to obtain a target acetabular prosthesis implantation angle prediction model. When using the target acetabular prosthesis implantation angle prediction model for targeted positioning of the target patient, it can save the high material and time costs caused by computer modeling, simulation testing and 3D printing. At the same time, it can avoid excessive subjective evaluation errors by doctors to a certain extent, thereby improving the positioning accuracy and reliability of acetabular prosthesis implantation angle prediction to a certain extent.
[0031] Reference Figure 4 , Figure 4 This is a flowchart illustrating another model training method provided in an embodiment of this application. The method may include: Step 201: Obtain the sample acetabular region image, sample abduction angle, and sample anteversion angle of the sample patient.
[0032] In the embodiments of this application, the implementation of this step can be referred to the embodiment of step 101, and will not be repeated here.
[0033] Optionally, step 201 may include the following sub-steps: Sub-step 2011: Obtain medical images of the femoral head of the sample patient.
[0034] Sub-step 2012: Mark the acetabulum region in the medical image of the femoral head of the sample to obtain the image of the acetabulum region of the sample.
[0035] In the embodiments of this application, a medical image of the femoral head can be obtained by taking pictures of the sample patient using medical imaging equipment. Then, the acetabulum region in the sample femoral head medical image can be marked using markers (such as red rectangles or red circles), thereby obtaining an image of the acetabulum region. This allows the model to learn the image features of the acetabulum region that should be of interest more quickly, thus improving the training efficiency and accuracy of the model to a certain extent.
[0036] Step 202: Input the sample acetabular region image into the Transformer encoder to obtain the first image code output by the Transformer encoder.
[0037] Step 203: Input the first image encoding into the one-dimensional convolutional neural network module to obtain the first predicted abduction angle and the first predicted forward tilt angle output by the one-dimensional convolutional neural network module.
[0038] In the embodiments of this application, the first convolutional neural network model can be composed of a Transformer encoder and a one-dimensional convolutional neural network module. Two output ports can be added after the output layer of a conventional one-dimensional convolutional neural network to form the one-dimensional convolutional neural network module. The activation functions of these two output ports can be set to independent softmax functions with weighted hyperparameters. The data type of the output ports is defined as floating-point. During data input, the sample acetabular region image can first be input into the Transformer encoder for encoding, obtaining the first image encoding output by the Transformer encoder. Then, the first image encoding can be input into the one-dimensional convolutional neural network module to obtain the first predicted abduction angle and the first predicted anteversion angle output by the one-dimensional convolutional neural network module. Its prediction accuracy is two decimal places. The first convolutional neural network model, composed of a Transformer encoder and an improved one-dimensional convolutional neural network module, can quickly learn the image features of the acetabulum through the self-attention mechanism and the fast encoding processing capability of the one-dimensional convolutional neural network. This enables high-precision model training, resulting in a target acetabular prosthesis implantation angle prediction model with high prediction accuracy. To a certain extent, this can improve the accuracy and reliability of the final acetabular prosthesis implantation angle prediction.
[0039] Step 204: Based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, determine the mean squared error loss value and the focus loss value of the first convolutional neural network model, respectively.
[0040] In the embodiments of this application, the first model loss value can be composed of the mean squared error loss value and the focus loss value. The mean squared error loss value is calculated as shown in Equation 1 below: (Equation 1) In equation 1 above, For the sample abduction angle, As the first predicted abduction angle, Forward tilt angle of the sample The first predicted anteversion angle, For the number of patients in the sample, This represents the mean squared error loss value.
[0041] The method for calculating the focus loss value is shown in Equation 2 below: (Equation 2) In equation 2 above, For the sample abduction angle, As the first predicted abduction angle, Forward tilt angle of the sample The first predicted anteversion angle, The serial number of the sample patients. To balance the weighting parameters of positive and negative samples, where the positive and negative samples are determined by the fit between the sample abduction angle and sample tilt angle and the sample patient, if the number of positive samples is greater than the number of negative samples, then... If the number of positive samples is less than 1, then If the number of positive samples equals the number of negative samples, then... It equals 1.
[0042] Step 205: Based on the mean squared error loss value and the focus loss value, determine the first model loss value of the first convolutional neural network model.
[0043] In the embodiments of this application, the first model loss value of the first convolutional neural network model can be calculated based on the mean squared error loss value and the focal loss value. The calculation method can be direct addition or weighted addition. This allows the first model loss value to be constructed from the mean squared error loss value and the focal loss value, which can, to some extent, enhance the role of the first model loss value in model training and improve the overall efficiency of model training.
[0044] Optionally, step 205 may include the following sub-steps: Sub-step 2051: Determine the focus weight value of the focus loss value.
[0045] Sub-step 2052: Based on the focus weight value, the mean squared error loss value, and the focus loss value, determine the first model loss value of the first convolutional neural network model.
[0046] In the embodiments of this application, a focus weight value can be assigned to the focus loss value so that the focus loss value can be calculated in a weighted manner when calculating the first model loss value. This allows for flexible adjustment of the composition of the first model loss value according to actual needs, which can improve the accuracy and reliability of the first model loss value to a certain extent.
[0047] Optionally, sub-step 2052 may include the following sub-steps: Sub-step A1: Calculate the first product of the focus weight value, the mean square error loss value, and the focus loss value.
[0048] Sub-step A2: Calculate the first weighted sum of the focus weight value, the mean squared error loss value, and the focus loss value.
[0049] Sub-step A3: Calculate the ratio of the first product to the first weighted sum to obtain the first model loss value of the first convolutional neural network model.
[0050] In the embodiments of this application, a novel weighted calculation method is constructed to calculate the first model loss value using the focus weight value, the mean squared error loss value, and the focus loss value. The calculation method is shown in Equation 3 below: (Equation 3) In equation 3 above, This is the loss value of the first model. This is the focus weight value, which takes a value greater than 1. and These are the mean squared error loss value and the focus loss value, respectively. Thus, the first model loss value will have a large value when the model prediction error is large, and this value will rise rapidly as the error increases. This can promote faster model convergence. At the same time, when the prediction error is small, the rate of change of the first model loss value will be lower than the rate of change of the prediction error, effectively avoiding the problem of model overfitting. Therefore, the accuracy and reliability of the first model loss value can be greatly improved.
[0051] Step 206: Based on the first model loss value, adjust the model parameters and hyperparameters of the first convolutional neural network model to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle of the target user's acetabular prosthesis based on the first acetabular region image of the target user.
[0052] By following the steps above, a more accurate prediction model for the target acetabular prosthesis implantation angle can be obtained.
[0053] Reference Figure 5 , Figure 5 This application provides a flowchart illustrating a method for predicting the implantation angle of an acetabular prosthesis, which may include: Step 301: Obtain an image of the target acetabulum of the target patient.
[0054] Step 302: Input the image of the target acetabulum into the target acetabular prosthesis implantation angle prediction model to obtain the target predicted abduction angle and the target predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is obtained based on the model training method described above; the target predicted abduction angle and the target predicted anteversion angle are used for the implantation positioning of the acetabular prosthesis in the target patient.
[0055] In the embodiments of this application, when locating the acetabular prosthesis for a target patient, an image of the target acetabular region can first be acquired. This image can be labeled with the same marking method as the sample acetabular region image. Then, the target acetabular region image can be input into a target acetabular prosthesis implantation angle prediction model obtained using any of the aforementioned model training methods to obtain the first predicted abduction angle and the first predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model. Since the abduction angle and anteversion angle have non-overlapping value ranges, the physician will not be confused by the two values output by the model. Thus, by using the target acetabular prosthesis implantation angle prediction model to predict the abduction angle and anteversion angle, the accuracy and reliability of the positioning prediction can be improved.
[0056] The embodiments of this application provide the architectural code for the improved model, as follows: import torch from torch import nn from torch.nn import functional as F from typing import List, Tuple class PositionalEncoding(nn.Module): """Sine Position Encoding Module""" def __init__(self, d_model: int, max_len: int = 5000): super().__init__() pe = torch.zeros(max_len, d_model) position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1) div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-np.log(10000.0) / d_model)) pe[:, 0::2] = torch.sin(position * div_term) pe[:, 1::2] = torch.cos(position * div_term) pe = pe.unsqueeze(0).transpose(0, 1) # [max_len, 1, d_model] self.register_buffer('pe', pe) def forward(self, x: torch.Tensor) -> torch.Tensor: Input shape: (seq_len, batch_size, d_model) return x + self.pe[:x.size(0), :].to(x.device) class WeightedSoftmax(nn.Module): """Softmax activation function with learnable weights""" def __init__(self, num_classes: int, init_weights: float = 1.0): super().__init__() self.num_classes = num_classes # Learnable category weight parameters self.weights = nn.Parameter(torch.full((num_classes,), init_weights)) def forward(self, x: torch.Tensor) -> torch.Tensor: Input shape: (batch_size, num_classes) weighted_logits = self.weights * x # Element-wise multiplication return F.softmax(weighted_logits, dim=-1) class HybridModel(nn.Module): "Transformer + 1D CNN combined model, with dual independent output ports" def __init__( self, input_channels: int = 1, cnn_config: List[int] = [32, 64], # List of hidden layer units in CNN kernel_size: int = 3, pool_size: int = 2, transformer_d_model: int = 128, transformer_nhead: int = 8, transformer_num_layers: int = 2, transformer_dim_feedforward: int = 256, mlp_units: int = 128, num_classes: int = 10, dropout: float = 0.5 ): super().__init__() # =========== 1D CNN Module ========== self.cnn_blocks = nn.ModuleList() prev_channels = input_channels For units in cnn_config: self.cnn_blocks.extend([ nn.Conv1d(prev_channels, units, kernel_size, padding='same'), nn.BatchNorm1d(units), nn.ReLU(), nn.MaxPool1d(pool_size) ) prev_channels = units # =========== Transformer Encoder =========== self.pos_encoder = PositionalEncoding(transformer_d_model) encoder_layer = nn.TransformerEncoderLayer( d_model=transformer_d_model, nhead=transformer_nhead, dim_feedforward=transformer_dim_feedforward, dropout=dropout ) self.transformer_encoder = nn.TransformerEncoder( encoder_layer, num_layers=transformer_num_layers ) # =========== Multi-Head Output MLP =========== self.mlp = nn.Sequential( nn.Linear(transformer_d_model, mlp_units), nn.ReLU(), nn.Dropout(dropout), nn.Linear(mlp_units, num_classes * 2) # Double output channels ) # =========== Dual Independent Output Heads ========== self.output1 = WeightedSoftmax(num_classes) self.output2 = WeightedSoftmax(num_classes) def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor,torch.Tensor]: """ Input shape: (batch_size, input_channels, sequence_length) Returns: (output1, output2) two probability distribution tensors """ # CNN Feature Extraction for layer in self.cnn_blocks: x = layer(x) # Prepare Transformer input (seq_len, batch_size, d_model) x = x.permute(2, 0, 1) # Convert to (seq_len, batch_size, channels) x = self.pos_encoder(x) # Add position encoding # Transformer encoding x = self.transformer_encoder(x) # (seq_len, batch_size, d_model) # Global Average Pooling x = x.mean(dim=0) # (batch_size, d_model) # MLP projection into dual output space logits = self.mlp(x) # (batch_size, num_classes*2) # Split into dual outputs and apply weighted Softmax logits1 = logits[:, :num_classes] logits2 = logits[:, num_classes:] output1 = self.output1(logits1) output2 = self.output2(logits2) return output1, output2 # Example usage if __name__ == "__main__": # Configuration parameters config = { "input_channels": 1, "cnn_config": [32, 64], "kernel_size": 3, "pool_size": 2, "transformer_d_model": 128, "transformer_nhead": 8, "transformer_num_layers": 2, "transformer_dim_feedforward": 256, "mlp_units": 128, "num_classes": 10, "dropout": 0.5 } # Create a model instance model = HybridModel(**config) # Print model structure print("Model Architecture:") print(model) # Testing forward propagation batch_size = 32 sequence_length = 100 x = torch.randn(batch_size, config["input_channels"], sequence_length) output1, output2 = model(x) print("\nOutput shapes:") print(f"Output1: {output1.shape}") # Size is (32, 10) print(f"Output2: {output2.shape}") # Size is (32, 10) print(f"Sum of output1 probabilities: {output1.sum().item():.4f}") print(f"Sum of output2 probabilities: {output2.sum().item():.4f}") The training effects of the improved model were compared with those of a conventional convolutional neural network, with accuracy as the metric. The results are shown in Table 1 below.
[0057] Table 1
[0058] In the training effect comparison process, the total number of epochs was set to 10. CNN represents the conventional convolutional neural network model, and Transformer+1D CNN represents the target acetabular region localization model provided in the embodiment of this application. It can be seen that the performance of conventional CNN gradually improves with the increase of epochs, while Transformer+1D CNN shows excellent training effect in the early stage of training and its overall accuracy is higher than that of conventional CNN.
[0059] refer to Figure 6 , Figure 6 This is a logic block diagram of a model training device provided in an embodiment of this application. The model training device 600 may include: The first acquisition module 601 is used to acquire images of the acetabulum region of the sample patient, the abduction angle of the sample, and the anteversion angle of the sample. The first input / output module 602 is used to input the sample acetabular region image into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model. The determination module 603 is used to determine the first model loss value of the first convolutional neural network model based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle. The adjustment module 604 is used to adjust the model parameters and hyperparameters of the first convolutional neural network model based on the first model loss value to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle corresponding to the acetabular prosthesis of the target user based on the first acetabular region image of the target user.
[0060] Optionally, the first acquisition module 601 includes: The acquisition submodule is used to acquire medical images of the femoral head of sample patients; The labeling submodule is used to label the acetabular region in the medical image of the femoral head of the sample to obtain an image of the acetabular region of the sample.
[0061] Optionally, the first convolutional neural network model includes a Transformer encoder and a one-dimensional convolutional neural network module, and the first input-output module 602 includes: The first input / output submodule is used to input the sample acetabular region image into the Transformer encoder to obtain the first image code output by the Transformer encoder. The second input / output submodule is used to input the first image encoding into the one-dimensional convolutional neural network module to obtain the first predicted abduction angle and the first predicted forward tilt angle output by the one-dimensional convolutional neural network module.
[0062] Optionally, the determining module 603 includes: The first determining submodule is used to determine the mean squared error loss value and focus loss value of the first convolutional neural network model based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, respectively. The second determining submodule is used to determine the first model loss value of the first convolutional neural network model based on the mean squared error loss value and the focus loss value.
[0063] Optionally, the second determining submodule includes: The first determining unit is used to determine the focus weight value of the focus loss value; The second determining unit is used to determine the first model loss value of the first convolutional neural network model based on the focus weight value, the mean squared error loss value, and the focus loss value.
[0064] Optionally, the second determining unit includes: The first calculation subunit is used to calculate the first product of the focus weight value, the mean square error loss value, and the focus loss value; The second calculation subunit is used to calculate the focus weight value, the mean square error loss value, and the first weighted sum of the focus loss value; The third computational subunit is used to calculate the ratio of the first product to the first weighted sum, thereby obtaining the first model loss value of the first convolutional neural network model.
[0065] The model training device in this application embodiment can be integrated into an electronic device, or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices besides a terminal. For example, the electronic device can be a GPU box, a mobile phone, a robot, an ultra-mobile personal computer (UMPC), or a personal digital assistant (PDA), etc., and can also be a server, a personal computer (PC), etc. This application embodiment does not specifically limit the specific implementation.
[0066] The model training device in this application embodiment can be a device with an operating system. This operating system can be Android, Linux, Windows, or other possible operating systems; this application embodiment does not specifically limit it.
[0067] The model training device provided in this application embodiment can achieve... Figure 1 and Figure 4 The various processes implemented in the method embodiments will not be described again here to avoid repetition. Reference Figure 7 , Figure 7 This application provides a logic block diagram of a acetabular prosthesis implantation angle prediction device 700, which may include: The second acquisition module 701 is used to acquire an image of the target acetabulum of the target patient. The second input / output module 702 is used to input the image of the target acetabular region into the target acetabular prosthesis implantation angle prediction model to obtain the target predicted abduction angle and the target predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is obtained based on the model training method described above; the target predicted abduction angle and the target predicted anteversion angle are used for the implantation positioning of the acetabular prosthesis in the target patient.
[0068] The acetabular prosthesis implantation angle prediction device in this application embodiment can be integrated into an electronic device, or a component of an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices besides a terminal. For example, the electronic device can be a GPU BOX, mobile phone, tablet computer, laptop computer, PDA, robot, ultra-mobile personal computer (UMPC), or personal digital assistant (PDA), etc., and can also be a server, personal computer (PC), etc. This application embodiment does not specifically limit the device.
[0069] The acetabular prosthesis implantation angle prediction device in this application embodiment can be a device with an operating system. This operating system can be Android, Linux, Windows, or other possible operating systems; this application embodiment does not specifically limit it.
[0070] The acetabular prosthesis implantation angle prediction device provided in this application embodiment can achieve... Figure 3 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0071] This application provides an electronic device, see [link to relevant documentation] Figure 8 The electronic device 80 includes: a processor 801, a memory 802, and a computer program 8021 stored in the memory 802 and executable on the processor 801. When the processor 801 executes the program, it implements the model training method of the foregoing embodiments, or the acetabular prosthesis implantation angle prediction method.
[0072] This application also provides a computer-readable storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements the steps in the model training method or the acetabular prosthesis implantation angle prediction method disclosed in this application.
[0073] This application also provides a computer program product that, when run on an electronic device, enables a processor to execute the steps of the model training method or the acetabular prosthesis implantation angle prediction method disclosed in this application.
[0074] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0075] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, electronic devices, and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0076] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0077] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0078] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0079] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0080] The above provides a detailed description of the model training method, acetabular prosthesis implantation angle prediction method, and device provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A model training method, characterized in that, The method includes: Acquire images of the acetabulum region, abduction angle, and anteversion angle of the sample patients; The sample acetabular region image is input into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model; Based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, the first model loss value of the first convolutional neural network model is determined. Based on the first model loss value, the model parameters and hyperparameters of the first convolutional neural network model are adjusted to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle of the target user's acetabular prosthesis based on the first acetabular region image of the target user.
2. The method according to claim 1, characterized in that, The acquisition of the acetabular region image of the sample patient includes: Obtain medical images of the femoral head of the sample patients; The acetabular region in the medical image of the femoral head of the sample is marked to obtain the image of the acetabular region of the sample.
3. The method according to claim 1, characterized in that, The first convolutional neural network model includes a Transformer encoder and a one-dimensional convolutional neural network module. The step of inputting the sample acetabular region image into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model includes: The sample acetabular region image is input into the Transformer encoder to obtain the first image code output by the Transformer encoder; The first image encoding is input into the one-dimensional convolutional neural network module to obtain the first predicted abduction angle and the first predicted forward tilt angle output by the one-dimensional convolutional neural network module.
4. The method according to claim 1, characterized in that, The step of determining the first model loss value of the first convolutional neural network model based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle includes: Based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle, the mean squared error loss value and the focus loss value of the first convolutional neural network model are determined respectively. Based on the mean squared error loss value and the focus loss value, the first model loss value of the first convolutional neural network model is determined.
5. The method according to claim 4, characterized in that, Determining the first model loss value of the first convolutional neural network model based on the mean squared error loss value and the focus loss value includes: Determine the focus weight value of the focus loss value; Based on the focus weight value, the mean squared error loss value, and the focus loss value, the first model loss value of the first convolutional neural network model is determined.
6. The method according to claim 5, characterized in that, Determining the first model loss value of the first convolutional neural network model based on the focus weight value, the mean squared error loss value, and the focus loss value includes: Calculate the first product of the focus weight value, the mean squared error loss value, and the focus loss value; Calculate the first weighted sum of the focus weight value, the mean squared error loss value, and the focus loss value; The ratio of the first product to the first weighted sum is calculated to obtain the first model loss value of the first convolutional neural network model.
7. A method for predicting the implantation angle of a acetabular prosthesis, characterized in that, The method includes: Acquire images of the target acetabulum of the target patient; The image of the target acetabulum is input into the target acetabular prosthesis implantation angle prediction model to obtain the target predicted abduction angle and the target predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is obtained based on the model training method according to any one of claims 1 to 6; the target predicted abduction angle and the target predicted anteversion angle are used for the implantation positioning of the acetabular prosthesis in the target patient.
8. A model training device, characterized in that, The device includes: The first acquisition module is used to acquire images of the acetabulum region of the sample patient, the abduction angle of the sample, and the anteversion angle of the sample. The first input / output module is used to input the sample acetabular region image into the first convolutional neural network model to obtain the first predicted abduction angle and the first predicted anteversion angle output by the first convolutional neural network model. The determination module is used to determine the first model loss value of the first convolutional neural network model based on the sample abduction angle, the sample forward tilt angle, the first predicted abduction angle, and the first predicted forward tilt angle. An adjustment module is used to adjust the model parameters and hyperparameters of the first convolutional neural network model based on the first model loss value to obtain a target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is used to output the target abduction angle and target anteversion angle corresponding to the acetabular prosthesis of the target user based on the first acetabular region image of the target user.
9. A device for predicting the implantation angle of a acetabular prosthesis, characterized in that, The device includes: The second acquisition module is used to acquire images of the target acetabulum of the target patient. The input / output module is used to input the image of the target acetabular region into the target acetabular prosthesis implantation angle prediction model to obtain the target predicted abduction angle and the target predicted anteversion angle output by the target acetabular prosthesis implantation angle prediction model; wherein, the target acetabular prosthesis implantation angle prediction model is obtained based on the model training method according to any one of claims 1 to 6; the target predicted abduction angle and the target predicted anteversion angle are used for the implantation positioning of the acetabular prosthesis in the target patient.