Edge configuration switching and fine identification method and system for railway defect detection
Patent Information
- Application Number
- CN202611158829.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-27
AI Technical Summary
[0006]本发明公开了铁路沿线缺陷检测的边缘配置切换与精细识别方法及系统,拟解决缺陷检测模型边缘部署时推理配置难以稳定选择、配置切换易造成帧或轨迹状态不一致、精细模型重复调用以及在线与离线结果难以统一的技术问题
[0064]1.本发明通过任务状态、资源状态和内容状态三类状态联合决策,不只依赖固定场景或单一精度阈值;通过硬约束过滤掉显存超限、偏差较大和高时延的预设配置,计算并选择其中多目标代价较小的配置,将时延、队列、显存、温度、功耗和内容难度转化为可计算的配置选择依据;同时,设计滞回和驻留策略降低频繁切换,有效降低了配置的切换频率。
Smart Images

Figure CN122990437A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of edge-end model inference optimization technology, specifically involving a method and system for edge configuration switching and fine identification of defects along railway lines. Background Technology
[0002] Facilities and equipment along railway lines (such as tracks, guardrails, license plates, and track equipment) are crucial to the safety of railway transportation. However, due to the wide distribution, complex environment, and harsh operating conditions of these facilities, their inspection and maintenance have always been a significant challenge for railway operations. When implementing defect detection and identification along railway lines, numerous models are often used for defect extraction and identification, such as the YOLO model, OCR recognition technology, and Kalman filter models. In practical scenarios, railway defect identification models are often deployed on trains or inspection trolleys. When models are deployed at the edge, they continuously consume video frames, and their service rate determines whether the input queue will back up. If subsequent models are called frame by frame, it will cause redundant computation and memory contention, leading to a decrease in overall defect identification efficiency.
[0003] Existing PyTorch-ONNX-TensorRT links can handle model format conversion; for example, Chinese patent 202511877040.9 discloses edge deployment of PyTorch, ONNX, and TensorRT, and deployment of INT8 models to the NPU of an inspection vehicle. However, it does not specifically address how to select configurations when resources and load fluctuate, how to maintain frame and trajectory consistency during switching, how online and offline systems can share the service chain, and how to utilize trajectory optimization to reduce subsequent model calls.
[0004] Existing edge deployment solutions typically focus on model format conversion, quantization, or single-precision switching, lacking a runtime configuration decision-making mechanism that simultaneously addresses task constraints, device resources, and video content. Especially in situations where railway inspection videos arrive continuously and targets form trajectories across frames, simply changing the inference engine or batch size may lead to queue backlogs, interruptions in activity trajectories, repeated writing of the same result, or excessive calls to fine-grained models during high-load periods.
[0005] Therefore, a closed-loop inference optimization scheme is needed that can perform pre-launch health checks on candidate inference configurations, quantify configuration benefits and switching costs during runtime, save frame water level and trajectory status during switching, and incorporate online low-latency processing and offline supplementary processing into a unified result version system. Summary of the Invention
[0006] This invention discloses a method and system for edge configuration switching and fine identification of defects along railway lines, which aims to solve the technical problems of unstable selection of inference configuration when deploying defect detection models at the edge, inconsistency of frame or trajectory states caused by configuration switching, repeated calls to fine models, and difficulty in unifying online and offline results.
[0007] To solve the aforementioned technical problems, the present invention adopts the following technical solution:
[0008] A method for switching edge configurations in railway defect detection includes the following steps:
[0009] S1: Obtain the preliminary detection model and representative samples, and establish baseline output; the baseline output is the defect identification result of the preliminary detection model at the edge based on representative samples;
[0010] S2: Construct a configuration pool based on the preliminary detection model, use representative samples to obtain defect identification results, perform consistency verification, and form a healthy configuration pool;
[0011] S3: Receive video tasks and establish task, segment, frame and trajectory identifiers, obtain state vectors and calculate configuration load rate;
[0012] S4: Based on the configuration load rate in S3, perform hard constraint filtering on the healthy configuration pool, calculate the multi-objective cost, and determine the target configuration;
[0013] S5: Construct configuration switching conditions based on multi-objective cost, number of consecutive windows, and minimum configuration dwell time, and perform configuration switching according to the configuration switching conditions.
[0014] This invention does not directly switch precision based on a single device utilization rate or a fixed threshold. Instead, it first forms a healthy configuration pool through baseline consistency indicators, then concatenates task status, resource status, and content status into a status vector. Finally, it determines the target configuration that can be safely deployed through hard constraint filtering and multi-objective cost analysis.
[0015] Furthermore, the k-th inference configuration and its attribute vector in the configuration pool of S2 are defined as follows:
[0016]
[0017]
[0018] For engine identification, For accuracy, Input dimensions, For batch size, For dynamic shapes, This is a post-processing version; For time delay, For swallowing and spitting, For peak video memory, For power consumption or temperature rise, For quality deviation, The engine is in a healthy state; the engine identifier. Including batch=1, batch=4, batch=8, or dynamic shape engines, the precision Including FP32, FP16 and INT8 precision;
[0019] In S2, consistency verification uses the configuration pool to initially detect the model and uses representative samples to identify defects. Based on the defect identification results and baseline output, consistency verification metrics are calculated, including the detection box matching rate. Category consistency rate Mean confidence bias Incremental amount of missed detection And the intersection-over-union ratio of the candidate output with the baseline. When , , and At that time, the configuration will enter the health pool.
[0020] Furthermore, in S3, the state vector is composed of the task state, resource state, and content state. Specifically:
[0021]
[0022] In the formula, The task status includes input type, latency limit, queue length, arrival frame rate, priority, network status, and whether supplementary processing is allowed. This includes resource status, such as GPU / NPU utilization, available video memory, CPU, temperature, power consumption, remaining storage, and resident engines; The content status includes the number of targets, the proportion of small targets, the average confidence level, fuzziness, occlusion, trajectory stability, and the proportion of difficult examples;
[0023] The specific calculation of the load rate in S3 is as follows:
[0024]
[0025] In the formula, The video arrival rate is obtained by dividing the number of frames entering the queue within the sliding window by the window duration. The configuration service rate is obtained by dividing the number of frames that configuration k completes inference within the same window by the window duration. This indicates that the queue will continue to grow.
[0026] Furthermore, the hard constraint filtering in S4 specifically includes:
[0027]
[0028] Available video memory, For safety margin, This is the upper limit of the deviation. To incorporate the end-to-end latency predicted based on the current load;
[0029] The multi-objective cost in S4 is as follows:
[0030]
[0031] In the formula, To predict latency, To accumulate risks, For resource consumption, To mitigate the risk of rising temperatures, For quality deviation, For loading, warm-up, and cache migration costs, To optimize revenue for content, various parameters are normalized.
[0032] The configuration for obtaining the minimum multi-objective cost under hard-constraint filtering conditions is as follows:
[0033]
[0034] Furthermore, the switching conditions in S5 are configured as follows: The configuration is true in N consecutive windows, and ;
[0035] In the formula, Where N is the revenue threshold, and N is the number of consecutive windows. To minimize dwell time; the configuration switching trigger types mentioned in S5 include normal trigger and protection trigger, and a six-state security verification mechanism is used for secure switching for both configuration switching trigger types; the six-state security switching are PREPARE, DRAIN, SNAPSHOT, WARMUP, COMMIT and ROLLBACK.
[0036] This invention separates normal triggering and protection triggering from the specific execution process. It uses a six-state process of PREPARE, DRAIN, SNAPSHOT, WARMUP, COMMIT, and ROLLBACK to record the water level of the batch in transit, the snapshot of the activity trajectory, and the final confirmed output water level. This ensures that changes in inference configuration do not reset the trajectory tracker and supports abnormal rollback.
[0037] A method for fine-grained edge identification in railway defect detection, after completing the initial edge deployment of the detection model based on the aforementioned edge configuration switching method for railway defect detection, further includes:
[0038] S6: Perform preliminary defect detection using the configuration determined in S1 to S5, and input the results into the trajectory tracker to construct the defect trajectory;
[0039] S7: Calculate the optimal quality of all frames in the same trajectory to determine the optimal frame, and calculate the trajectory uncertainty to schedule the fine model;
[0040] S8: Perform position calibration based on the above trajectory selection frame, calculate the idempotency key of the result and feed back the statistics.
[0041] This invention optimizes the quality and trajectory uncertainty of candidate frames for the same trajectory, and uses the trajectory rather than each frame as the unit for calling the fine model. It selects between direct output, fine inference and offline processing to reduce redundant calculations and memory contention.
[0042] Furthermore, the calculation of the preferred quality in S7 is as follows:
[0043]
[0044] In the formula, For confidence level, For the target size, For clarity, For completeness, To cover up, Penalty for touching the edge;
[0045] The calculation of trajectory uncertainty in S7 is as follows:
[0046]
[0047] In the formula, H is the category entropy. , The probability of each frame category within the trajectory; For cross-frame category inconsistency rate, For low confidence frame ratio, For trajectory stability.
[0048] Furthermore, the idempotency key in the result of S8 is specifically as follows:
[0049]
[0050] The feedback update calculates the current configuration load rate, and performs step S3 to switch configurations based on the configuration load rate.
[0051] This invention uses task ID, frame ID, trajectory ID, model stage / model version, and processing version to form idempotent keys, enabling online results, offline supplementary processing results, retry results, and rollback results to identify the same business object and merge them according to version rules. At the same time, it feeds back the running statistics to the state vector to trigger the next round of configuration decisions.
[0052] An edge configuration switching system for defect detection along railway lines includes a baseline output module, a configuration pool management module, a status acquisition module, a constraint decision module, and a safe switching module;
[0053] Baseline output module: used to acquire the preliminary detection model and representative samples, and establish baseline output; the baseline output is the defect identification result of the preliminary detection model at the edge based on representative samples;
[0054] Configuration pool management module: Constructs a configuration pool based on the preliminary detection model, uses representative samples to obtain defect identification results, performs consistency verification, and forms a healthy configuration pool;
[0055] Status acquisition module: used to receive video tasks and establish task, segment, frame and trajectory identifiers, obtain status vectors and calculate configuration load rate;
[0056] Constraint Decision Module: Based on the above configuration load rate, perform hard constraint filtering on the healthy configuration pool, calculate multi-objective costs to determine the target configuration;
[0057] The secure switching module constructs configuration switching conditions based on multi-objective cost, number of consecutive windows, and minimum configuration dwell time, and performs configuration switching according to the configuration switching conditions.
[0058] The edge configuration switching system for railway defect detection is used to implement the aforementioned edge configuration switching method for railway defect detection.
[0059] A railway defect detection edge fine recognition system, after completing edge deployment according to the above-mentioned railway defect detection edge configuration switching system, also includes a preliminary detection and trajectory tracking module, a trajectory optimization and fine recognition module, and a position calibration and feedback update module;
[0060] Preliminary detection and trajectory tracking module: Performs preliminary defect detection using the configuration determined in the edge configuration switching system described above, and inputs the results into the trajectory tracker to construct the defect trajectory;
[0061] Trajectory optimization and fine recognition module: used to calculate the optimization quality of all frames in the same trajectory to determine the optimal frame, and to calculate the trajectory uncertainty to schedule the fine model;
[0062] Position calibration and feedback update module: Perform position calibration based on the above trajectory optimization frames, calculate the idempotency key of the result and provide feedback statistics.
[0063] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0064] 1. This invention makes joint decisions based on three states: task state, resource state, and content state, rather than relying solely on fixed scenarios or single precision thresholds. It filters out preset configurations with excessive memory, large deviations, and high latency through hard constraints, calculates and selects configurations with lower multi-objective costs, and transforms latency, queue, memory, temperature, power consumption, and content difficulty into calculable criteria for configuration selection. At the same time, it designs hysteresis and dwell strategies to reduce frequent switching, effectively reducing the frequency of configuration switching.
[0065] 2. This invention designs a six-state secure switching mechanism: PREPARE, DRAIN, SNAPSHOT, WARMUP, COMMIT, and ROLLBACK. It ensures data consistency before and after configuration switching through frame water level, trajectory snapshot, idempotent writing, and rollback.
[0066] 3. This invention calculates trajectory quality and uncertainty, and calls a refined identification model based on trajectory quality and uncertainty, changing the call of the refined model from frame-by-frame to on-demand call;
[0067] 4. This invention divides configuration switching into online low-latency processing and offline throughput and supplementary processing, enabling online fast processing and offline supplementary processing to share identifiers and versions. Attached Figure Description
[0068] The present invention will be described by way of example and with reference to the accompanying drawings, wherein:
[0069] Figure 1 This is a flowchart of the edge deployment configuration switching process in Embodiment 1 of the present invention;
[0070] Figure 2 This is a flowchart of the fine edge recognition process in Embodiment 2 of the present invention;
[0071] Figure 3 This is a structural diagram of the edge deployment and fine recognition system module in Embodiment 4 of the present invention. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the embodiments and accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and marked in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0073] In the description of the embodiments of this application, it should be noted that the terms "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the invention / product is in use. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. In addition, the terms "first," "second," and "third," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0074] This invention uses a railway defect detection model and its subsequent refined processing model as the controlled inference object. The specific network structure and training method of the model are not necessary restrictions for implementing the closed-loop optimization mechanism. As long as the candidate configuration can output detection boxes, categories, and confidence scores, and can associate the processing results through task, frame, and trajectory identifiers, the configuration health verification, target configuration decision, safe switching, trajectory-based scheduling, and idempotent merging mechanisms of this invention can be adopted.
[0075] The following presents an automatic defect identification and location calibration method along railway lines. The defect detection, trajectory tracking, image selection, fine identification, and location calibration processes are used to illustrate the data form of the controlled business chain and the dependencies between each processing stage. The closed-loop control variables of this invention include inference configuration, state vector, switching level, trajectory snapshot, fine calculation budget, and result version.
[0076] The following is a method for automatic identification and location marking of defects along railway lines, and its specific steps are as follows:
[0077] Step 1: Use an optimized YOLO model to perform preliminary defect detection on the video to be detected, and obtain a preliminary defect video; the preliminary defect detection includes generating defect target detection boxes, calculating confidence scores, and preliminary matching of defect types;
[0078] In this embodiment, the YOLO11 series model is used as the basic detection model, and a special training dataset is constructed for training on defects along the railway line.
[0079] Specifically, the model incorporates samples of small targets, blurred targets, occluded targets, and high-speed moving scenes, dividing these samples into training, validation, and test sets. The defect category system is redesigned, including categories such as signs, license plates, bird nests, and foreign object intrusion. Data augmentation of the training set is performed using random scaling, cropping, brightness variations, and motion blur. Initial input image size, confidence threshold, and non-maximum suppression (NMS) parameters are set, and transfer training is conducted based on YOLO11 pre-trained weights. The learning rate, training epochs, input image size, confidence threshold, and NMS threshold are adjusted using the validation set to adapt to the target detection requirements in high-speed inspection videos, ultimately obtaining a defect detection model suitable for railway lines. The test set is used to test the defect detection model, further validating its accuracy.
[0080] The transfer learning process first loads pre-trained weights for general object detection and replaces the category outputs in the detection head with a railway defect dataset. In the early stages of training, some convolutional layers of the backbone network are frozen, and only the detection head and high-level feature fusion layers are trained, enabling the model to quickly adapt to defect categories such as signs, license plates, bird nests, and foreign object intrusions. Subsequently, all or part of the backbone network is unfrozen, and fine-tuning is performed with a small learning rate. During training, bounding box regression loss, category loss, and object confidence loss are jointly optimized, and the optimal weights are selected based on the small object recall rate, false detection rate, and overall mAP on the validation set.
[0081] The selection criteria for small target samples are that the area of the target detection box is less than a preset proportion of the total image area, or the width and height of the detection box are less than a preset pixel threshold. For example, the area of the detection box is less than 1%, or either the width or height is less than 32 pixels.
[0082] The adjustment of the input image size, confidence threshold, and NMS threshold specifically involves increasing the input image size from 640 to 960 or 1280; setting the confidence threshold to 0.25-0.5; and setting the NMS threshold to 0.45-0.7. During training, adjustments are made based on the recall, false positive rate, and small target detection rate of the validation set. In this embodiment, the initial image size is set to 960, the initial confidence threshold is set to 0.35, and the initial NMS threshold is set to 0.5.
[0083] The preliminary defect detection includes generating target defect detection boxes, calculating confidence scores, and making preliminary judgments about the defect type. Specifically, for the video to be detected, based on the defect type to be identified, the YOLO model identifies the defect type of each frame in the video, generates corresponding defect detection boxes, and calculates the confidence score of the defect in the detection box. The confidence score is determined by the probability of the target's existence and the class probability, and is used to measure the likelihood that the detection box contains the target defect and the class judgment is correct. It can be expressed as:
[0084]
[0085] In the formula, Confidence is the confidence score of the detection box, P(object) is the probability that a target defect exists within the detection box, and P(class|object) is the probability that the target belongs to the corresponding defect category given the existence of the target defect. The confidence score serves as a quality reference for trajectory association, occlusion recovery, and false detection filtering in step 2, and as one of the criteria for judging obvious defects and fuzzy defects in S4.
[0086] In another embodiment, the input to the defect detection module is an image or camera device, and the image type includes JPEG, PNG, and BMP.
[0087] Step 2: Extract defect image frames from the defective video, identify and enhance small target defects, perform multi-frame association and occlusion judgment on the defect image frames, and construct defect trajectories based on the preliminary matched defect types;
[0088] refer to Figure 2 , Figure 2 This is a schematic diagram of the trajectory tracking process in S2 of this embodiment. The identification of small target defects is based on the minimum detection box threshold set by the small target type. The area of the defect target detection box is calculated and compared with the threshold. When the area of the defect target detection box is less than the threshold, the enhancement of the small target defect is performed.
[0089] For consecutive video frames identified by the YOLO model, the small target recognition unit sets the minimum detection box threshold as follows:
[0090]
[0091]
[0092]
[0093] In the formula, and These are the proportional coefficients for the width and height of the detection frame, respectively. and Based on the validation set parameter tuning results and the target context preservation requirements, min_width and min_height are the minimum detection box thresholds for the width and height of the detection box, respectively, and min_area is the minimum detection box threshold for the area of the detection box. The scaling factor is selected from 0.2 to 0.8, preferably... and All were selected as 0.5.
[0094] When both the width and height of the detection frame are less than the minimum defect threshold for the width and height, it is determined to be a small target; when only one of the width and height of the detection frame meets the minimum detection frame threshold for the width and height, the area of the detection frame is calculated and compared with the minimum detection frame threshold for the area. If the area is less than the minimum detection frame threshold, it is determined to be a small target.
[0095] In another preferred embodiment, the minimum detection box threshold is adjusted according to the target category; for target types such as bird nests or license plates, which are small in shape and have neat detection boxes, the proportional coefficient is adjusted accordingly. and The selected range is set to 0.2 to 0.3, preferably, the scaling factor. and All are 0.25; for target types with larger weight supports, the proportionality coefficient is... and The selected range is set to 0.5 to 0.7, preferably, the scaling factor. and Both are 0.6.
[0096] For image frames with defects that meet the criteria, enhancement processing is performed on small target defects. Specifically, for small target defects that meet the criteria, the width and height are proportionally expanded based on the center point of the detection box, and the expanded box is limited to not exceeding the image boundary. The expansion ratio ranges from 1.1 to 1.5, preferably 1.2. When the expanded width exceeds the image boundary, the expanded box is truncated according to the image boundary. The expanded detection box is used not only for trajectory association but also for subsequent optimal image cropping, thereby preserving the contextual information around the small target and reducing the risk of missed associations caused by the target being too small, having blurred edges, or being partially occluded.
[0097] The multi-frame association is used to match and associate defect image frames with defect trajectories. The specific steps are as follows:
[0098] Step 21: Maintain and extract the trajectory state from the existing trajectory. The trajectory state includes trajectory number, the center coordinates of the most recent detection box, the width and height of the box, velocity vector, category, confidence level, number of consecutive hits, and number of lost frames.
[0099] Step 22: When a new frame detection result arrives, use Kalman prediction in OCSORT to predict the trajectory state and obtain the predicted position of the current frame;
[0100] Specifically, using consecutive frame numbers as a time series, observations are generated for each detection box. Where x and y are the center points of the target bounding box, w and h are the width and height of the bounding box, and c represents the category and confidence information. The velocity vector is used to predict the current frame state using a motion model on an existing trajectory. The trajectory state is constructed using the center coordinates of the detection box, the box width and height, and the velocity vector. A uniform motion state transition model is established based on the time interval between adjacent frames to predict the target position in the current frame.
[0101] Here, 'c' is not used as a spatial coordinate in the equation of uniform motion for position prediction, but is used as an association constraint and trajectory attribute. When the detection box category is consistent with the trajectory category and the confidence level is high, the category penalty term in the matching cost is reduced, and the category penalty term is increased when the categories are inconsistent. After a successful match, the category confidence information of the trajectory is updated with the new category and confidence level.
[0102] Step 23: Calculate the matching degree between the predicted position and the detection result, and update the trajectory state based on the matching degree; the calculation of the matching degree between the predicted position and the detection result adopts Hungarian matching or equivalent minimum matching cost.
[0103] In this embodiment, the Hungarian matching algorithm is used to calculate the matching degree between the predicted location and the detection result. At least one of 1-IOU, center point distance, and class consistency is used as the matching cost, and a cost threshold is used to determine whether the detection box matches the predicted trajectory. Specifically, a matching cost matrix is constructed, and the matching cost is calculated for the i-th predicted trajectory and the j-th detection box in the matching cost matrix. Matching cost The cost is calculated by weighting location cost, scale cost, velocity direction cost, appearance cost, and category penalty. Location cost is calculated as 1 - IOU or normalized center point distance; scale cost is the normalized value of the width-height difference; velocity direction cost is the angle between the motion directions or the velocity difference; appearance cost is the extended bounding box feature distance; and a penalty term is added when categories are inconsistent. The Hungarian algorithm is used to find the trajectory-detection box combination with the minimum total cost in the matching cost matrix. If the cost of a combination is lower than a preset matching threshold, it is considered a match, and trajectory updates are performed; otherwise, the detection box is used as a new trajectory candidate, or the original trajectory is marked as temporarily lost.
[0104] After a successful match, the updated trajectory state is corrected using the detection box observations to adjust the Kalman prediction position, and the corrected state is then updated to the corresponding trajectory.
[0105] The occlusion discrimination is used to distinguish between short-term occlusion of the trajectory, detection of intermittent interruptions, and actual disappearance of the target. The occlusion discrimination is set with a maximum number of lost frames as a threshold. Short-term occlusion is when the target is temporarily occluded but the predicted trajectory position is continuous and the number of lost frames does not exceed the threshold. Detection of intermittent interruptions is when the target is not substantially occluded but due to blurring, lighting, or detector misses, some frames have no detection box. The number of lost frames is even smaller and the position after re-hitting is highly consistent with the predicted position. Actual disappearance is when the number of lost frames exceeds the threshold or the predicted position cannot match the detection result continuously.
[0106] Within the maximum number of lost frames, the target position is predicted based on the trajectory state, and the matching degree between the predicted target position and the detected position is calculated. When the matching condition is met, the detected position is re-incorporated into the trajectory. The maximum number of lost frames can be set to 3-10 frames, preferably 5 frames.
[0107] For defect trajectories that have not received new defect image frames for an extended period, the occlusion processing sets a maximum number of lost frames as a threshold. When a trajectory does not match a detection box in the current frame, the system marks it as temporarily lost and accumulates the number of lost frames, while retaining the predicted position and historical features. If the number of lost frames does not exceed the threshold, the trajectory can still be recovered from detection boxes in subsequent frames that are close to the predicted position and have the same category and appearance features. When the number of lost frames exceeds the threshold, the trajectory is terminated.
[0108] For all terminated defect trajectories, the number of consecutive hits in the trajectory state is extracted. Only when the defect trajectory successfully matches the detection result in multiple consecutive frames is it confirmed as a valid defect trajectory. Occasional false detections are filtered out by the number of consecutive hits, and the image corresponding to the valid defect trajectory is selected first when optimizing the trajectory image in step S3.
[0109] Step 3: Calculate the detection box size of all defect image frames in the defect trajectory, and weight it with the confidence score to obtain the quality score of the defect image frame. Select the image with the highest quality score in the trajectory as the result output.
[0110] refer to Figure 3 , Figure 3 This is a schematic diagram of the trajectory optimization process in embodiment S3. For each complete trajectory obtained, the clearest and most complete target image needs to be filtered out. This invention uses a weighted quality score based on the target bounding box confidence and its size, with the specific formula as follows:
[0111]
[0112] In the formula, α and β are the weighting coefficients for confidence and target size, respectively. The weighting coefficients are determined based on the validation set experiment to take into account detection confidence, target scale, sharpness and trajectory stability.
[0113] In a preferred embodiment, the weighting coefficients are first set equally, and then a grid search or empirical adjustment is performed based on the false detection rate, false negative rate and preferred image recognition accuracy to select the group with the highest overall accuracy as the actual weights used.
[0114] In this embodiment, the module maintains a list to store the identified trajectories, and maintains a dictionary for each trajectory to store the maximum detection bounding box and image of the defective image frame quality score in the trajectory.
[0115] When the number of lost frames reaches the maximum number of lost frames, the trajectory is considered to have ended, and the target bounding box with the highest score is output for subsequent processing steps.
[0116] Step 4: For obvious defects in the output, make a direct judgment; for ambiguous defects in the output, introduce a fine classification model for accurate identification.
[0117] For the output results, if the defect type is obvious and can be directly identified, it is directly determined as a defect. Specifically, a significant defect threshold is set, and the confidence score is compared with the significant defect threshold to determine whether the defect can be directly identified. The significant defect threshold is set to 0.50-0.65, preferably 0.60.
[0118] If the defect type cannot be directly determined, and only a suspected image can be identified, then a fine classification model is required. The fine classification model includes a granular image classification model, a lightweight object detection model, and a semantic segmentation or instance segmentation model.
[0119] The granular image classification model is used to determine whether the target in the preferred image belongs to a specific defect type, or to determine the degree, level, angle, etc. of the defect; the lightweight target detection model is used to re-detect local abnormal areas in the preferred image to eliminate false alarms in the initial detection or to achieve more accurate local positioning; the semantic segmentation or instance segmentation model is used to perform pixel-level segmentation of contaminated areas, intrusion areas, abnormal parts, etc., thereby improving the ability to judge the boundaries and degree of complex defects.
[0120] Specifically, the granular image classification model can be a ResNet model, an EfficientNet model, or a MobileNet model; the lightweight object detection model can be a YOLO11n model, a YOLO11s model, or a similar lightweight model; the semantic segmentation or instance segmentation model can be a DeepLab model, a U-Net model, a Mask R-CNN model, or a YOLO segmentation model. In actual implementation, one or more of these models can be selected according to the defect type.
[0121] The fine classification model is retrained for railway scene samples, mined for difficult samples, weighted for class imbalance, data augmentation, model pruning, and quantization or distillation, so that the fine classification model can balance recognition accuracy and on-site inference speed.
[0122] In practice, regular targets such as signs and license plates can be located first using a lightweight target detection model, and then the category can be confirmed by combining OCR or classification models; targets with large morphological differences, such as bird nests and foreign object intrusions, can be located a second time using a lightweight target detection model; targets that need to be classified in terms of degree, such as occlusion, dirt, and damage, can be classified in a fine-grained manner using ResNet, EfficientNet, or MobileNet; and defects with irregular boundaries or that require calculation of area proportion can be segmented using U-Net, DeepLab, Mask R-CNN, or YOLO models.
[0123] Step 5: Extract background information from the output trajectory, query the railway database to obtain and update railway section information, associate the railway section information with the defect identification result, generate detailed defect association results, and write them to the corresponding JSON file.
[0124] The following is combined with Figures 1-3 The present invention will be described in detail below.
[0125] Example 1
[0126] refer to Figure 1 This invention discloses an edge-end closed-loop reasoning optimization method for defect detection along railway lines, comprising the following steps:
[0127] S1: Obtain the preliminary detection model and representative samples, and establish baseline output; the baseline output is the defect identification result of the preliminary detection model at the edge based on representative samples.
[0128] This invention first constructs multiple replaceable edge inference configurations for the same initial detection model, and evaluates the latency, throughput, memory usage, temperature rise, and quality deviation of each configuration without changing the semantics of the model's business output. Subsequent runtime decisions, configuration switching, and feedback updates are all based on the healthy configuration pool, thus forming a closed loop for configuration selection, execution, and verification.
[0129] The preliminary detection model is the YOLO model used in the preliminary identification in step 1 of the above-mentioned automatic identification and location calibration method for defects along the railway line; the representative samples consist of small targets, blurred targets, occluded targets and high-speed moving scene samples obtained locally in the above-mentioned automatic identification and location calibration method for defects along the railway line.
[0130] In one specific implementation, the baseline runtime environment uses the original framework with unquantized raw model weights, FP32 as the baseline accuracy, and fixed input preprocessing, confidence thresholds, non-maximum suppression parameters, and post-processing versions. Candidate configurations only change deployment parameters such as engine, accuracy, input size, batch size, or dynamic shape to ensure that consistency checks reflect changes in deployment configuration rather than changes in business rules.
[0131] S2: Based on the preliminary detection model, construct multiple configurations, measure attributes and perform consistency checks to form a healthy configuration pool.
[0132] When deploying to the edge, in order to improve the performance of the preliminary detection model at the edge, this invention constructs multiple configurations for the preliminary detection model, performs consistency verification on each configuration, and selects healthy configurations to build a healthy configuration pool.
[0133] Specifically, the k-th inference configuration and its attribute vector They are defined as follows:
[0134]
[0135]
[0136] In the formula, For engine identification, For accuracy, Input dimensions, For batch size, For dynamic shapes, This is a post-processing version; For time delay, For swallowing and spitting, For peak video memory, For power consumption or temperature rise, For quality deviation, In good health;
[0137] In one specific implementation, the health configuration pool includes online configuration, offline configuration, and difficult case configuration. The online configuration is used to output defect detection results in real time, using batch=1 and a fixed input size to reduce single-frame latency. The offline configuration is used for historical video review or supplementary processing, using bucketing, multiple batches, or dynamic shapes to improve throughput. The difficult case configuration is used for small targets, occlusions, or low-confidence trajectories, using a larger input size or higher precision to improve quality. In addition, the resource protection configuration uses smaller size, lower precision, or controlled sampling to maintain service continuity when there is temperature rise, power consumption, or memory shortage.
[0138] The online and offline configurations are not independent steps, but rather are part of the processing mode field written to the task status when the task is received in step S3, and are integrated throughout the entire process. Step S3 identifies the task mode based on input type, latency limit, priority, and whether supplementary processing is allowed; step S4 performs hard constraint filtering and target configuration selection within the set of configurations allowed for the corresponding mode; and step S5 performs a safe switch within the same mode or when switching modes.
[0139] This invention uses baseline output as a reference and representative samples to perform consistency verification on the edge-end model inference configuration. In the aforementioned method for automatic defect identification and location calibration along railway lines, the preliminary detection model is used to generate defect target detection boxes, calculate confidence scores, and initially match defect types. Therefore, consistency verification of the model inference configuration deployed at the edge includes calculating the detection box matching rate. Category consistency rate Mean confidence bias Incremental amount of missed detection The intersection-union ratio of the inference configuration output to the baseline output;
[0140] The IOU between the candidate output and the baseline output is calculated as follows:
[0141]
[0142] In the formula, These represent the detection boxes output using representative samples from the candidate output and the baseline output, respectively; the detection box matching rate... Category consistency rate Mean confidence bias and the increase in missed detections All statistical methods are based on the detection box matching pairs after the candidate inference configuration output and the baseline output are matched one-to-one. Specifically, the candidate relationship between the candidate box and the baseline box is first established according to the category-independent IoU, and then one-to-one matching is performed according to the IoU from high to low. The same candidate box or baseline box can only enter one matching pair, and boxes with IoU below the matching threshold do not constitute a matching pair.
[0143] In one specific implementation, the matching threshold is set to 0.50; when the railway defect category has high requirements for location overlap, the matching threshold is selected in the range of 0.50 to 0.75 on the validation set.
[0144] Based on the IoU above, the matched detection box pairs are determined. Let the baseline output box set be B, the candidate configuration output box set be C, the detection box matching pair set be M, and the number of detection box matching pairs where the candidate box and the corresponding baseline box belong to the same category be N. Detection box matching rate. Category consistency rate Mean confidence bias This is the arithmetic mean of the absolute differences between the candidate box confidence and the baseline box confidence for each matched pair in M. Unmatched candidate boxes and baseline boxes are used to calculate the candidate configuration false negative rate. Missed detection rate compared to baseline configuration Increase in missed detections for .
[0145] when , , and At that time, the configuration enters the health pool, where , , and These are the detection matching rate threshold, the category consistency rate threshold, the average confidence deviation threshold, and the missed detection increment threshold, which are determined by the validation set and the railway safety business tolerance.
[0146] In one specific implementation, the detection box matching rate is not less than 95%, the category consistency rate is not less than 98%, the average confidence deviation is not higher than 0.05, and the missed detection increment is not higher than 0.5 percentage points.
[0147] S3: Receive video tasks and establish task, segment, frame and trajectory identifiers, obtain state vectors and calculate configuration load rate.
[0148] Specifically, the state vector is composed of the task state, resource state, and content state. Specifically:
[0149]
[0150] In the formula, The task status includes input type, latency limit, queue length, arrival frame rate, priority, network status, and whether supplementary processing is allowed. This includes resource status, such as GPU / NPU utilization, available video memory, CPU, temperature, power consumption, remaining storage, and resident engines; The content status includes the number of targets, the proportion of small targets, the average confidence level, fuzziness, occlusion, trajectory stability, and the proportion of difficult examples.
[0151] The specific calculation of the configuration load rate is as follows:
[0152]
[0153] In the formula, Video reach rate Configure service rate, This indicates that the queue will continue to grow; the invention relates to the combined queue length. Waiting time and Determine if the current configuration meets the online requirements.
[0154] In a preferred embodiment, for the current configuration, the configuration service rate is obtained based on the number of frames completed for inference within the same sliding window; for candidate configurations that have not yet been deployed, the configuration service rate is obtained based on the throughput attributes measured offline in the configuration pool, and corrected in conjunction with the current temperature, power consumption limits, and input size. This allows for comparison of the predicted load rate of each candidate configuration under the current video arrival rate in step S4, without the need to first switch to a candidate configuration for trial operation.
[0155] S4: Apply hard constraint filtering to the healthy configuration pool and calculate the multi-objective cost to determine the target configuration.
[0156] Specifically, the hard constraint filtering calculation formula is as follows:
[0157]
[0158] In the formula, Available video memory, For safety margin, This is the upper limit of the deviation. To incorporate the end-to-end latency predicted by the current load, this invention removes configurations that are currently unsafe to go online from the healthy configuration pool using the above hard constraint filtering calculation formula, and only compares multiple target costs among the remaining candidates.
[0159] The multi-objective cost calculation formula in S4 is as follows:
[0160]
[0161] In the formula, To predict latency, To accumulate risks, For resource consumption, To mitigate the risk of rising temperatures, For quality deviation, To account for the costs of loading, warming up, and cache migration, To adapt content to revenue, These are the weights of the aforementioned cost indicators; after normalizing the above indicators, the multi-objective cost is calculated, where the normalization of each item is as follows:
[0162] Normalized latency = Actual inference latency / Latency cap threshold;
[0163] Normalized backlog risk = Current request queue length / Maximum queue capacity;
[0164] Normalized resource usage = Current video memory / Computational resource usage / Total resource capacity;
[0165] Normalized temperature rise risk = Current equipment temperature / Safe operating temperature threshold;
[0166] Normalized quality deviation = Actual detection accuracy / Target accuracy requirement;
[0167] Normalized handover cost = Configured handover overhead / Maximum allowed handover overhead;
[0168] Normalized content adaptation benefit = Performance gain after adaptation / Theoretical maximum gain;
[0169] Weight The weights are obtained through offline playback calibration and adjusted based on device resource availability and task processing. Tasks with higher security levels have increased weights for latency and quality deviation, while resource-constrained devices have increased weights for video memory and temperature rise. Specifically, the weight acquisition steps through offline playback are as follows: First, latency, backlog risk, resource consumption, temperature rise risk, quality deviation, switching cost, and content adaptation benefits are normalized. Using online latency compliance rate, quality compliance rate, switching frequency, and energy consumption as verification targets, grid search or Bayesian optimization is employed to determine the optimal weight combination.
[0170] In one specific implementation, the initial weights of each indicator are set as follows: It is 0.25. It is 0.15. It is 0.15. It is 0.10. It is 0.20. It is 0.10. The threshold is 0.05. After system deployment, no new evaluation function is introduced. Instead, the weights in Table 1 are optimized using grid search or Bayesian methods while maintaining the constraint that the sum of the weights in each group is 1. Each candidate weight is calculated on the same validation set or offline replay set to achieve the predetermined evaluation objective. After meeting the safety lower limit, the weight group with the smaller overall cost is selected. During operation, only small updates are allowed within preset upper and lower limits, and the version number and rollback weights are retained.
[0171] The configuration that minimizes the cost of multi-objective operations under hard-constraint filtering conditions is:
[0172]
[0173] S5: Build state transition conditions and switch configurations based on the state transition conditions.
[0174] Specifically, the state transition condition is as follows: It is true for N consecutive windows, and
[0175] In the formula, Where N is the revenue threshold, and N is the number of consecutive windows. For the shortest possible stay;
[0176] The configuration switching trigger types include normal triggering and protection triggering. Normal triggering is used when the current configuration is still available but the overall cost of the target configuration is lower. Normal switching is performed when the multi-objective cost of the target configuration relative to the current configuration decreases by more than the benefit threshold Δ, the advantage is established for N consecutive monitoring windows, and the current configuration has been running for more than the minimum dwell time. Protection triggering is used when there is insufficient video memory, device overheating, configuration failure, or predicted latency exceeding the mandatory upper limit. It has a higher priority than normal triggering, is not limited by the minimum dwell time, and is used to ensure basic system availability. The abnormal conditions include insufficient video memory, device overheating, configuration failure, or predicted latency exceeding the mandatory upper limit.
[0177] For both configuration switching trigger types mentioned above, a six-state security verification mechanism is used for secure switching to ensure that the switching operation does not introduce security risks.
[0178] The six-state secure transitions are PREPARE, DRAIN, SNAPSHOT, WARMUP, COMMIT, and ROLLBACK.
[0179] PREPARE: Locks the target configuration, checks the model, cache, and video memory, and generates... ;
[0180] DRAIN: Stop submitting new batches, allow batches in transit to complete, and record the last submission watermark. ;
[0181] SNAPSHOT: Saves the activity trajectory status and the last confirmed water level output. ;
[0182] WARMUP: Activates the target configuration to verify frame warm-up; the warm-up result is not written into the final result.
[0183] COMMIT: From Continue submitting, keep the original trajectory tracker running, and enter the observation window;
[0184] ROLLBACK: Restores the previous healthy configuration when startup fails, output is abnormal, or quality deviation exceeds limits.
[0185] Example 2
[0186] refer to Figure 2 This embodiment discloses a fine-grained edge-end identification method for defect detection along railway lines. Specifically, based on the edge-end deployment method for defect detection along railway lines disclosed in Embodiment 1, it further includes the following steps:
[0187] S6: Perform preliminary defect detection using the configuration determined in S1 to S5, and input the results into the trajectory tracker to construct the defect trajectory;
[0188] S7: Calculate the optimal quality of all frames in the same trajectory to determine the optimal frame, and calculate the trajectory uncertainty to schedule the fine model.
[0189] Specifically, the calculation of the preferred mass in S7 is as follows:
[0190]
[0191] In the formula, For confidence level, For the target size, For clarity, For completeness, To the degree of obstruction, To compensate for edge-fitting penalties, all components are normalized to [0,1]; trajectory optimization frames. Among them, weight , , , , and The independent weights for trajectory optimization quality are separately labeled with the weights for configuring multi-target costs; the trajectory optimization quality weights are determined by the subsequent recognition accuracy on the validation set.
[0192] The confidence level The output probability of the target category in this frame is obtained from the preliminary detection model; the target size is... The ratio of the detection frame area to the total frame area is piecewise linearly normalized; the sharpness... The Laplacian variance of the grayscale image of the detection box region is taken and normalized by truncating it according to the 5th and 95th percentiles of the validation set; the completeness... The ratio of the area of the effective target region within the detection frame to the area of the complete target region estimated based on trajectory history; the degree of occlusion. The percentage of the area within the detection bounding box that overlaps with adjacent target boxes, or the occlusion probability output by the occlusion classifier; the edge-fitting penalty. The value is 1 when the minimum distance between the detection box and the image boundary is less than a preset boundary threshold, and 0 otherwise; in another embodiment, the edge-fitting penalty... The values are linearly segmented based on the minimum distance between the detection box and the image boundary.
[0193] This invention sets an optimal quality threshold. By comparing the optimal quality Q of all frames in the trajectory, the trajectory frame with the largest optimal quality Q is selected as the optimal frame. If the optimal quality Q of the optimal frame is lower than the optimal quality threshold, the trajectory is marked as having insufficient image quality.
[0194] In one specific implementation, confidence weights are set during initial deployment. The target size weight is 0.30. The resolution weight is 0.20. The completeness weight is 0.20. The occlusion weight is 0.15. The edge penalty weight is 0.10. The value is 0.05, and the preferred quality threshold is 0.55.
[0195] Specifically, the trajectory uncertainty in S7 is calculated as follows:
[0196]
[0197] In the formula, H is the category entropy. , The probability of each frame category within the trajectory; For cross-frame category inconsistency rate, For low confidence frame ratio, For trajectory stability; , , and The weights are denoted as , and the sum of all weights is 1. By comparing the upgrade recall, invalid upgrade rate, and average computational cost under different weights, the weighted reassemblies that meet the lower limit of upgrade recall and have lower costs are selected. Among them, category entropy, cross-frame category inconsistency rate, and low-confidence frame ratio are positive risk terms, while trajectory stability is a negative risk term.
[0198] It should be noted that "upgrade" means that the trajectory is identified through refined model processing. The upgrade recall rate is the number of trajectories that are successfully identified and trigger refined inference by the system among all trajectories that actually require refined model processing. It is used to measure whether the system has missed any difficult cases. Specifically, it is calculated as the ratio of the number of trajectories that correctly triggered the upgrade to the total number of trajectories that actually need to be upgraded. The number of trajectories that actually need to be upgraded refers to trajectories whose initial detection results have category errors, insufficient confidence, positioning bias, or insufficient information, but whose results can be corrected or supplemented after calling the refined model. The upgrade recall rate is calculated as follows:
[0199]
[0200] In the formula, TP: an upgrade is indeed required and the system has already triggered the upgrade; FN: an upgrade is indeed required, but was incorrectly output directly or not processed.
[0201] In one specific implementation, if 100 trajectories in the validation set are confirmed to require upgrade processing after manual annotation or fine model verification, and the system successfully triggers 95 of them, then the upgrade recall rate is 95%.
[0202] The invalid upgrade rate is calculated as the ratio of the number of trajectories that were incorrectly upgraded without triggering an upgrade to the total number of trajectories that actually need to be upgraded; the average computational cost is calculated as the average model cost for each trajectory upgrade.
[0203] When the upgrade recall rate is higher, it means that the trajectory that needs fine processing is less likely to be missed. When the trajectory uncertainty threshold is too loose, it will cause trajectories that do not need fine identification to be upgraded, resulting in an increase in invalid upgrade rate and computational overhead. Based on the upgrade recall rate, invalid upgrade rate and average computational overhead, a weighted reassembly that meets the lower limit of upgrade recall rate and has low overhead is selected.
[0204] The category entropy H is calculated based on the average category probability of each frame within the trajectory and normalized by dividing by the logarithm of the number of categories; the cross-frame category inconsistency rate is the ratio of the number of times the predicted categories of adjacent valid frames differ to the total number of adjacent valid frame pairs; the low confidence frame ratio is the ratio of the number of valid frames with a trajectory built-in confidence of less than 0.50 to the total number of valid frames; the trajectory stability is the stability score after motion prediction compensation for the displacement and scale changes of the detection box center in adjacent frames, and the smaller the changes, the higher the stability.
[0205] This invention sets low trajectory uncertainty thresholds and high trajectory uncertainty thresholds, and each threshold is adjusted based on a validation set and the processing version is recorded.
[0206] In one specific implementation, the initial weight of trajectory uncertainty is set as the category entropy H weight. The cross-frame category inconsistency rate is 0.35. Weight 0.25; Low confidence frame ratio Weight The stability of the trajectory is 0.20. Weight The threshold value is 0.20; the threshold value for low trajectory uncertainty is 0.30; and the threshold value for high trajectory uncertainty is 0.65.
[0207] This invention utilizes a refined model based on the preferred quality Q, trajectory uncertainty threshold U, preferred quality threshold, low trajectory uncertainty threshold, and high trajectory uncertainty threshold as follows: If Q is higher than the preferred quality threshold and U is less than the low trajectory uncertainty threshold, the model is output directly; if Q is higher than the preferred quality threshold, U is between the two thresholds, and refined budgeting is available, only the preferred frame is used for fine classification, local detection, segmentation, OCR, or position modeling; if Q is lower than the preferred quality threshold, U is higher than the high trajectory uncertainty threshold, or the queue exceeds the limit, the model enters the offline supplementary processing queue, saving the preferred frame, adjacent frames, and cause code.
[0208] In a preferred embodiment, the present invention forms a closed-loop inference process for edge configuration switching and fine recognition of railway defect detection based on steps S1 to S5 and steps S6 to S8 as follows: In step S2, the online mode of the present invention is oriented towards real-time video streams, prioritizing batch=1, fixed input size, and resident engines, and using the end-to-end latency upper limit as a hard constraint; when the trajectory requires fine processing but the online computation budget is insufficient, i.e., when the preferred quality Q is higher than the preferred quality threshold, the trajectory uncertainty U is between the two thresholds, and the fine budget is unavailable, step S7 writes the preferred frame, adjacent frames, trajectory snapshot, cause code, and model version into the supplementary processing queue. The offline mode is oriented towards historical video review and the supplementary processing queue, i.e., when Q is lower than the preferred quality threshold, U is higher than the high trajectory uncertainty threshold, or the queue exceeds the limit, multi-batch, bucketing, or dynamic shape engines are used to improve throughput, and in step S8, the results are merged using the same task ID, frame ID, trajectory ID, and version identifier, thereby avoiding duplicate writing.
[0209] S8: Perform position calibration based on the above trajectory selection frame, calculate the idempotency key of the result and feed back the statistics.
[0210] Specifically, the input frame has , and The trajectory has Snapshots save the most recent detection bounding box, motion state, category confidence, hit count, number of lost frames, and best frame. Switching between the initial detection engines does not reset the tracker. The idempotency key for the result is:
[0211]
[0212] In the formula, For model stage / model version identification, To handle version identification: the former is obtained from the release version number of the currently invoked initial detection, fine classification, segmentation, OCR, or location model, while the latter is obtained from the threshold, NMS, and rule configuration versions used when generating the results. Both are written to the configuration management table along with the model or post-processing rules, and together with the task ID, frame ID, and trajectory ID, form an idempotent key, thereby distinguishing the results of the same trajectory under different processing stages or versions, supporting retries, rollbacks, and merging of online / offline results.
[0213] Specifically, the feedback update calculates the current configuration load rate, and performs step S3 to switch configurations based on the configuration load rate.
[0214] Example 3
[0215] This embodiment discloses an edge configuration switching system for defect detection along railway lines, including a baseline output module, a configuration pool management module, a status acquisition module, a constraint decision module, and a safe switching module;
[0216] Baseline output module: used to acquire the preliminary detection model and representative samples, and establish baseline output; the baseline output is the defect identification result of the preliminary detection model at the edge based on representative samples;
[0217] Configuration pool management module: Constructs a configuration pool based on the preliminary detection model, uses representative samples to obtain defect identification results, performs consistency verification, and forms a healthy configuration pool;
[0218] Status acquisition module: used to receive video tasks and establish task, segment, frame and trajectory identifiers, obtain status vectors and calculate configuration load rate;
[0219] Constraint Decision Module: Based on the above configuration load rate, perform hard constraint filtering on the healthy configuration pool, calculate multi-objective costs to determine the target configuration;
[0220] The secure switching module constructs configuration switching conditions based on multi-objective cost, number of consecutive windows, and minimum configuration dwell time, and performs configuration switching according to the configuration switching conditions.
[0221] The edge configuration switching system for railway defect detection is used to implement the aforementioned edge configuration switching method for railway defect detection.
[0222] Example 4
[0223] refer to Figure 3 This embodiment discloses an edge fine recognition system for railway defect detection. After the edge deployment is completed according to the above-mentioned edge configuration switching system for railway defect detection, the edge fine recognition system for railway defect detection also includes a preliminary detection and trajectory tracking module, a trajectory optimization and fine recognition module, and a position calibration and feedback update module.
[0224] Preliminary detection and trajectory tracking module: Performs preliminary defect detection using the configuration determined in the edge configuration switching system described above, and inputs the results into the trajectory tracker to construct the defect trajectory;
[0225] Trajectory optimization and fine recognition module: used to calculate the optimization quality of all frames in the same trajectory to determine the optimal frame, and to calculate the trajectory uncertainty to schedule the fine model;
[0226] Position calibration and feedback update module: Perform position calibration based on the above trajectory optimization frames, calculate the idempotency key of the result and provide feedback statistics.
[0227] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for switching edge configurations in railway defect detection, characterized in that, Includes the following steps: S1: Obtain the preliminary detection model and representative samples, and establish baseline output; the baseline output is the defect identification result of the preliminary detection model at the edge based on representative samples; S2: Construct a configuration pool based on the preliminary detection model, use representative samples to obtain defect identification results, perform consistency verification, and form a healthy configuration pool; S3: Receive video tasks and establish task, segment, frame and trajectory identifiers, obtain state vectors and calculate configuration load rate; S4: Based on the configuration load rate in S3, perform hard constraint filtering on the healthy configuration pool, calculate the multi-objective cost, and determine the target configuration; S5: Construct configuration switching conditions based on multi-objective cost, number of consecutive windows, and minimum configuration dwell time, and perform configuration switching according to the configuration switching conditions.
2. The edge configuration switching method for railway defect detection according to claim 1, characterized in that: In S2, the k-th inference configuration and its attribute vector in the configuration pool are defined as follows: ; ; For engine identification, For accuracy, Input dimensions, For batch size, For dynamic shapes, This is a post-processing version; For time delay, For swallowing and spitting, For peak video memory, For power consumption or temperature rise, For quality deviation, The engine is in a healthy state; the engine identifier. Including batch=1, batch=4, batch=8, or dynamic shape engines, the precision Including FP32, FP16 and INT8 precision; In S2, consistency verification uses the configuration pool to initially detect the model and uses representative samples to identify defects. Based on the defect identification results and baseline output, consistency verification metrics are calculated, including the detection box matching rate. Category consistency rate Mean confidence bias Incremental amount of missed detection And the intersection-over-union ratio of the candidate output with the baseline. When , , and At that time, the configuration will enter the health pool.
3. The edge configuration switching method for railway defect detection according to claim 1, characterized in that: In S3, the state vector is composed of task state, resource state, and content state. Specifically: ; In the formula, The task status includes input type, latency limit, queue length, arrival frame rate, priority, network status, and whether supplementary processing is allowed. This includes resource status, such as GPU / NPU utilization, available video memory, CPU, temperature, power consumption, remaining storage, and resident engines; The content status includes the number of targets, the proportion of small targets, the average confidence level, fuzziness, occlusion, trajectory stability, and the proportion of difficult examples; The specific calculation of the load factor in S3 is as follows: ; In the formula, The video arrival rate is obtained by dividing the number of frames entering the queue within the sliding window by the window duration. The configuration service rate is obtained by dividing the number of frames that configuration k completes inference within the same window by the window duration. This indicates that the queue will continue to grow.
4. The edge configuration switching method for railway defect detection according to claim 1, characterized in that: Hard constraint filtering in S4 specifically refers to: ; Available video memory, For safety margin, This is the upper limit of the deviation. To incorporate the end-to-end latency predicted based on the current load; The multi-objective cost in S4 is as follows: ; In the formula, To predict latency, To accumulate risks, For resource consumption, To mitigate the risk of rising temperatures, For quality deviation, For loading, warm-up, and cache migration costs, To optimize revenue for content, various parameters are normalized. The configuration for obtaining the minimum multi-objective cost under hard-constraint filtering conditions is as follows: 。 5. The edge configuration switching method for railway defect detection according to claim 1, characterized in that: The switching conditions in S5 are configured as follows: The configuration is true in N consecutive windows, and ; In the formula, Where N is the revenue threshold, and N is the number of consecutive windows. To minimize dwell time; the configuration switching trigger types mentioned in S5 include normal trigger and protection trigger, and a six-state security verification mechanism is used for secure switching for both configuration switching trigger types; the six-state security switching are PREPARE, DRAIN, SNAPSHOT, WARMUP, COMMIT and ROLLBACK.
6. A method for fine edge recognition in railway defect detection, characterized in that, After completing the edge deployment of the preliminary detection model according to the edge configuration switching method for railway defect detection in claims 1 to 5, the method further includes: S6: Perform preliminary defect detection using the configuration determined in S1 to S5, and input the results into the trajectory tracker to construct the defect trajectory; S7: Calculate the optimal quality of all frames in the same trajectory to determine the optimal frame, and calculate the trajectory uncertainty to schedule the fine model; S8: Perform position calibration based on the above trajectory selection frame, calculate the idempotency key of the result and feed back the statistics.
7. The method for fine edge recognition of railway defect detection according to claim 6, characterized in that: The calculation of the preferred quality in S7 is as follows: ; In the formula, For confidence level, For the target size, For clarity, For completeness, To cover up, Penalty for touching the edge; The calculation of trajectory uncertainty in S7 is as follows: ; In the formula, H is the category entropy. , The probability of each frame category within the trajectory; For cross-frame category inconsistency rate, For low confidence frame ratio, For trajectory stability.
8. The method for fine edge recognition of railway defect detection according to claim 1, characterized in that: The idempotency key in the result of S8 is specifically: ; The feedback update calculates the current configuration load rate, and performs step S3 to switch configurations based on the configuration load rate.
9. An edge configuration switching system for defect detection along railway lines, characterized in that, It includes a baseline output module, a configuration pool management module, a status acquisition module, a constraint decision module, and a secure switching module; Baseline output module: used to acquire the preliminary detection model and representative samples, and establish baseline output; the baseline output is the defect identification result of the preliminary detection model at the edge based on representative samples; Configuration pool management module: Constructs a configuration pool based on the preliminary detection model, uses representative samples to obtain defect identification results, performs consistency verification, and forms a healthy configuration pool; Status acquisition module: used to receive video tasks and establish task, segment, frame and trajectory identifiers, obtain status vectors and calculate configuration load rate; Constraint Decision Module: Based on the above configuration load rate, perform hard constraint filtering on the healthy configuration pool, calculate multi-objective costs to determine the target configuration; The secure switching module constructs configuration switching conditions based on multi-objective cost, number of consecutive windows, and minimum configuration dwell time, and performs configuration switching according to the configuration switching conditions. The edge configuration switching system for railway defect detection is used to implement the edge configuration switching method for railway defect detection as described in any one of claims 1 to 5.
10. A fine-grained edge recognition system for defect detection along railway lines, characterized in that, The edge fine recognition system for railway defect detection according to claim 9, after being deployed at the edge end of the edge configuration switching system for railway defect detection, further includes a preliminary detection and trajectory tracking module, a trajectory optimization and fine recognition module, and a position calibration and feedback update module. Preliminary detection and trajectory tracking module: Performs preliminary defect detection using the configuration determined in the edge configuration switching system described above, and inputs the results into the trajectory tracker to construct the defect trajectory; Trajectory optimization and fine recognition module: used to calculate the optimization quality of all frames in the same trajectory to determine the optimal frame, and to calculate the trajectory uncertainty to schedule the fine model; Position calibration and feedback update module: Perform position calibration based on the above trajectory optimization frames, calculate the idempotency key of the result and provide feedback statistics.
Citation Information
Patent Citations
Water chilling unit fault diagnosis system based on MATE-Net and edge deployment method
CN121743974A