Method for automatically copying and automatically detecting picture
Through dynamic task generation, asynchronous scheduling and multi-model fusion detection methods, the problem of inefficient image copying and detection is solved, and efficient and accurate image management and analysis is achieved. It is suitable for industrial production, security monitoring and medical imaging and other fields.
Patent Information
- Application Number
- CN202510436448.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-07-18
AI Technical Summary
The prior art has problems of inefficiency and poor accuracy in image copying and detection, especially in industrial production, security monitoring and medical image analysis, which is difficult to meet the needs of efficient and accurate data management and analysis.
The dynamic task generation module is used to generate a copy task queue, and the asynchronous scheduling algorithm is used to copy pictures in parallel to multiple target storage nodes; the distributed inference engine and multi-model fusion detection algorithm are used for image detection, and the data is stored and managed by dynamic threshold adjustment and bidirectional index.
It realizes the efficiency, reliability and detection accuracy of image copying, improves the convenience of data management and query efficiency, adapts to the needs of different detection scenarios, reduces the misjudgment rate and data loss, and meets the requirements of real-time.
Smart Images

Figure CN120339233A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and specifically to a method for automatically copying pictures and automatically detecting pictures. Background Art
[0002] In today's digital age, picture data has grown explosively, and numerous fields such as industrial production, security monitoring, and medical image diagnosis have accumulated a vast amount of picture resources. How to efficiently manage and analyze these picture data has become an urgent problem to be solved.
[0003] In terms of industrial production quality inspection, the traditional manual inspection method is inefficient and prone to missed inspections and misjudgments. With the continuous expansion of production scale, the number of product pictures generated every day is huge. Relying on manual inspection one by one not only consumes a large amount of manpower, material resources, and time, but also manual fatigue and subjective factors will seriously affect the accuracy of inspection. For example, in an electronic component manufacturing enterprise, a large number of component pictures are produced per minute on the production line, and manual inspection cannot meet the requirements of rapid inspection, which may lead to defective products flowing into the market, damaging the enterprise's reputation and economic benefits.
[0004] In the field of security monitoring, surveillance cameras continuously shoot 24 hours a day, generating a vast amount of surveillance pictures. Existing monitoring systems often lack the ability of automated picture analysis and are difficult to quickly and accurately identify abnormal behaviors or events. For example, in crowded places such as large shopping malls and airports, once an emergency occurs, the method of manually checking surveillance pictures for investigation is extremely inefficient, unable to take effective countermeasures in time, and delaying the best treatment opportunity.
[0005] In terms of medical image analysis, with the progress of medical technology, more and more imaging data are generated by various medical imaging devices such as CT and MRI. Doctors need to spend a lot of time interpreting these images, and there are differences in the diagnostic levels of different doctors, which may lead to inconsistent diagnostic results. For example, in early cancer screening, accurate analysis of a large number of X-ray images is crucial, but manual analysis not only takes a long time but may also miss some signs of early lesions due to insufficient doctor experience.
[0006] In addition, existing picture copying and detection methods have many deficiencies. In the picture copying link, there is a lack of intelligent task scheduling and optimization mechanisms, unable to perform efficient copying according to the real-time status of storage nodes, and prone to problems such as slow copying speed and inability to automatically resume after interruption. In the picture detection link, a single detection model is difficult to meet the complex and changeable detection requirements, and the detection accuracy and efficiency need to be improved. At the same time, there are also no effective means for the management and query of detection results, unable to quickly and accurately obtain the detection information of specific pictures or search for relevant pictures according to the defect type. Summary of the Invention
[0007] The object of the present invention is to provide a method for automatically copying pictures and automatically detecting pictures, so as to solve the problems raised in the above-mentioned background art.
[0008] To achieve the above object, the present invention provides the following technical solution: A method for automatically copying pictures and automatically detecting pictures, the method comprising:
[0009] Step S1: Regularly scan a preset source directory through a dynamic task generation module, extract picture folders that meet the time naming rule, and generate a copy task queue containing the start time and end time according to the time window parameter;
[0010] Step S2: Extract tasks from the copy task queue according to the priority based on the asynchronous scheduling algorithm, traverse the picture folders in the source directory that match the time window through a multi-threaded script, and copy the picture files to multiple target storage nodes in parallel;
[0011] Step S3: Use a distributed inference engine to perform real-time path parsing on the copied pictures, generate an inference task queue containing the picture path and metadata, and allocate it to multiple detection nodes based on the load balancing strategy;
[0012] Step S4: Use a multi-model fusion detection algorithm to perform target detection on the pictures, including using the Yolo V5 model for defect location, combining with the ResNet-50 model for defect type classification, and outputting a structured detection result;
[0013] Step S5: Screen the detection results through a dynamic threshold adjustment module, retain the detection data higher than the adaptive threshold, and associate the screened results with the corresponding picture metadata;
[0014] Step S6: Store the associated data in a distributed database according to the time series, and establish a two-way index based on the defect type and the picture path.
[0015] Preferably, step S1 further includes:
[0016] Step S11: Poll the source directory according to a preset time interval to identify sub-folders named with timestamps;
[0017] Step S12: Based on the time window sliding algorithm, extract a list of target folders in the sub-folders that meet the start time and end time range;
[0018] Step S13: Package the list of target folders into a copy task and add it to a queue sorted by priority.
[0019] Preferably, the asynchronous scheduling algorithm in step S2 includes:
[0020] Step S21: Dynamically allocate the number of copy threads according to the real-time bandwidth and storage capacity of the target storage node;
[0021] Step S22: Use the breakpoint resumption mechanism to perform hash verification on the interrupted copy tasks and record the checksum of the completed files.
[0022] Preferably, the workflow of the distributed inference engine described in step S3 includes:
[0023] Step S31: Parse the log file of the copy task and extract the absolute path of the image and the storage node information;
[0024] Step S32: Dynamically allocate inference tasks according to the GPU computing power of the detection node and monitor the node status using the heartbeat mechanism.
[0025] Preferably, the multi-model fusion detection algorithm described in step S4 includes:
[0026] Step S41: Output the bounding box coordinates and confidence scores of the defects through the Yolo V5 model;
[0027] Step S42: Use the ResNet-50 model to perform multi-label classification on the image area within the bounding box and generate the probability distribution of the defect types;
[0028] Step S43: Perform weighted fusion on the outputs of the two types of models, and the calculation formula is:
[0029] C = α·S Yolo +(1 - α)·S ResNet
[0030] where C is the comprehensive confidence, representing the credibility score of the defect detection result after fusion, α is the dynamic weight coefficient, adjusted according to the historical detection accuracy; S Yolo is the confidence score of the Yolo V5 model, representing the prediction credibility of the object detection model for the defect position and the bounding box, S ResNet is the classification probability of the ResNet-50 model, representing the probability distribution of the defect types by the classification model.
[0031] Preferably, the calculation method of the adaptive threshold described in step S5 is:
[0032] Step S51: Statistically analyze the confidence distribution of the historical detection results and generate the mean μ and variance σ within the sliding window 2 ;
[0033] Step S52: Dynamically adjust the threshold T according to the real-time data volume of the current detection task according to the formula T = μ + k·σ, where k is the sensitivity coefficient.
[0034] Preferably, the method for constructing the bidirectional index in step S6 includes:
[0035] Step S61: Using the defect type as the key, aggregate the paths and detection times of all associated pictures;
[0036] Step S62: Using the picture path as the key, inversely map to the corresponding defect type set and detection parameters.
[0037] Preferably, the method further includes:
[0038] Step S7: Mark the tasks with copy or detection failures through the exception rollback module, and reassign them to the standby nodes based on the historical success rate.
[0039] Preferably, step S7 includes:
[0040] Step S71: Conduct a root cause analysis of the failed tasks to distinguish between network interruption, storage overflow, or model exception types;
[0041] Step S72: Select a retry strategy according to the root cause type, where the model exception tasks are assigned to the standby detection nodes.
[0042] Preferably, the method further includes:
[0043] Step S8: Collect the pictures corresponding to the low-confidence detection results as training samples, and use the federated learning algorithm to distributively update the model parameters on multiple detection nodes.
[0044] Compared with the prior art, the beneficial effects of the present invention are:
[0045] In the picture copying link, the dynamic task generation module regularly scans the source directory according to the preset rules, can accurately extract the picture folders that meet the time naming rules, and generates a copy task queue in combination with the time window parameters. This mechanism makes the planning of copy tasks more reasonable and orderly, avoiding blind copying and resource waste. The application of the asynchronous scheduling algorithm dynamically allocates the number of copy threads according to the real-time bandwidth and storage capacity of the target storage node, making full use of the advantages of storage resources. For example, in a multi-node storage system, nodes with high bandwidth and large storage capacity can be assigned more threads, thus realizing the parallel and efficient copying of pictures and greatly shortening the copying time. At the same time, the breakpoint resume mechanism cooperates with the hash check. When the copying process is interrupted for various reasons, the system can accurately resume the copying from the interruption point through the recorded checksum of the completed files, avoiding the repeated labor of copying from the beginning, effectively ensuring the integrity of data transmission and the reliability of copy tasks, and ensuring the smooth completion of copy tasks even in an environment with unstable network.
[0046] In terms of image detection, the multi-model fusion detection algorithm is a highlight of this patent. The Yolo V5 model focuses on defect location and can quickly and accurately determine the location of defects in the image; the ResNet-50 model is good at defect type classification and accurately judges the specific type of defects. The combination of the two achieves complementary advantages and significantly improves the accuracy of detection. By weighted fusion of the outputs of the two types of models, the comprehensive confidence obtained can more reliably reflect the credibility of the defect detection results. In the actual industrial production quality inspection scenario, facing complex and diverse product defects, a single model is often difficult to meet the high-precision detection requirements, and the misjudgment rate is high. The multi-model fusion algorithm of this patent can effectively reduce the misjudgment rate, improve the accuracy of product quality control, reduce the risk of defective products entering the market, and save a lot of costs and losses for enterprises. The dynamic threshold adjustment module dynamically calculates the adaptive threshold to screen the detection results based on the confidence distribution of historical detection results and the real-time data volume of the current detection task. This method can flexibly adapt to different detection scenarios and data characteristics to ensure that the retained detection data has high reliability and value. For example, the confidence distribution of the detection data of images obtained in different production batches and different environments may be different. This module can automatically adjust the threshold so that the screened detection results are more in line with the actual situation, providing a more accurate basis for subsequent analysis and decision-making.
[0047] The distributed reasoning engine and the load balancing strategy work together to reasonably distribute the reasoning tasks to multiple detection nodes, making full use of the computing resources of each node and avoiding the problem of low processing efficiency caused by excessive load on a single node. At the same time, the heartbeat mechanism monitors the node status in real time. Once a node failure is found, the task allocation can be adjusted in time to ensure the continuity and stability of the detection task. In large-scale image detection tasks, this method can significantly improve the overall detection efficiency, quickly process a large amount of image data, and meet application scenarios with high real-time requirements. In terms of data storage and management, the associated detection data is stored in a distributed database in time series, and a bidirectional index based on defect type and image path is established, which provides great convenience for data query and retrieval. Whether it is to quickly find all relevant images and their detection time according to the defect type, or to reversely obtain the corresponding defect type set and detection parameters through the image path, it can be quickly realized. This is of great significance in the fields of security monitoring, product quality traceability, etc., which facilitates staff to quickly obtain the required information, improve work efficiency and decision-making accuracy.
[0048] The abnormal rollback module marks and processes tasks that fail in copying or detection, determines the failure type through root cause analysis, and selects appropriate retry strategies according to different types. In particular, tasks with model abnormalities are assigned to standby detection nodes, effectively ensuring the stability and reliability of the system, reducing data loss or incomplete detection caused by task failures, and ensuring the smooth progress of the entire image processing process. In addition, images corresponding to low-confidence detection results are collected as training samples, and the federated learning algorithm is used to distributively update model parameters on multiple detection nodes, enabling the model to continuously adapt to new detection requirements and data changes. Over time and with the accumulation of data, the detection performance of the model will be continuously optimized, and the accuracy and generalization ability of detection will be continuously improved, thus providing higher-quality and more accurate image detection services for various application fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 is the working principle diagram of the method for automatically copying and automatically detecting images according to the present invention;
[0050] Figure 2 is the schematic flow diagram of the execution of the asynchronous scheduling algorithm;
[0051] Figure 3 is the schematic flow diagram of the working process of the distributed inference engine;
[0052] Figure 4 is the schematic flow diagram of the adaptive threshold calculation and screening results. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0054] Please refer to Figures 1-4 , the present invention provides a method for automatically copying and automatically detecting images, and its overall implementation scheme is as follows:
[0055] Step S1: Generate a copy task queue: Use the dynamic task generation module to regularly scan a preset source directory at a preset time period. During the scanning process, image folders that meet specific time naming rules are identified. These folders may be named in a way that conforms to the time naming rules, such as with timestamps. Then, based on the given time window parameters, the start time and end time are determined, and a copy task queue containing the start time and end time is generated. This queue will serve as the basis for extracting subsequent image copy tasks.
[0056] Step S2: Parallel Copy of Images: Based on the asynchronous scheduling algorithm, tasks are extracted from the above copy task queue according to task priorities. With the help of a multi-threaded script, traverse the image folders in the source directory that match the time window. During the traversal, copy the image files to multiple target storage nodes in parallel. This can improve the copy efficiency and reduce the copy time.
[0057] Step S3: Generate and Allocate Inference Tasks: Use a distributed inference engine to perform real-time path parsing on the copied images. During the parsing process, extract the paths and relevant metadata of the images to generate an inference task queue containing the image paths and metadata. Then, based on the load balancing strategy, reasonably allocate these inference tasks to multiple detection nodes to ensure relatively balanced loads on each detection node and make full use of computing resources.
[0058] Step S4: Multi-Model Fusion Detection: Adopt a multi-model fusion detection algorithm to perform object detection on the images. Among them, use the Yolo V5 model to locate the defects in the images and determine the position information of the defects in the images; at the same time, combine the ResNet-50 model to classify the types of defects. Through the collaborative work of these two models, output structured detection results, that is, clearly indicate whether there are defects in the images, and if so, the position and type information of the defects.
[0059] Step S5: Filter Detection Results by Confidence: Filter the detection results by confidence through a dynamic threshold adjustment module. The dynamic threshold adjustment module will calculate an adaptive threshold according to certain rules, retain the detection data with confidence higher than the adaptive threshold in the detection results, and associate these filtered results with the corresponding image metadata for convenient subsequent query and use.
[0060] Step S6: Store Data and Establish Indexes: Store the associated data in a distributed database according to the time series for long-term preservation and management of the data. At the same time, establish two-way indexes based on the defect types and image paths. In this way, all relevant image paths, detection times, etc. information can be quickly found through the defect types, and the corresponding defect type sets, detection parameters, etc. content can be queried in reverse through the image paths, improving the efficiency of data query and retrieval.
[0061] The following further illustrates the implementation of the present invention in combination with Embodiments 1 to 6.
[0062] Embodiment 1:
[0063] In the specific implementation of Step S1, it is further refined into the following sub-steps:
[0064] Step S11: The system will periodically poll the source directory at a preset time interval. This time interval can be adjusted according to actual needs, for example, set to poll every 5 minutes. During the polling process, the system will carefully identify each subfolder in the source directory and specifically look for those subfolders named with timestamps. The timestamp naming method has uniqueness and time identification, which facilitates the system to quickly and accurately filter out the folders that meet the requirements.
[0065] Step S12: Based on the time window sliding algorithm, the system will further process the identified subfolders named with timestamps. This algorithm will extract a list of target folders that meet the conditions from numerous subfolders according to the set start time and end time range. For example, assuming the current time window is set from 9 am to 10 am on the same day, the system will filter out the subfolders created or modified within this time period.
[0066] Step S13: Package the extracted list of target folders into copy tasks. These tasks will be sorted according to certain rules for priority and then added to the priority sorted queue. The priority setting can be determined according to factors such as the importance of the folder and the size of the data volume. For example, the folder tasks related to important projects can be set with a higher priority to perform the copy operation first. In this way, the orderliness of the copy tasks is ensured, and the overall processing efficiency is improved. In an actual application scenario, assume that in a quality inspection system of a manufacturing enterprise, a large number of product pictures are generated every day, and these pictures are stored in the source directory named with timestamps. Through the above steps, the system can accurately and quickly filter out the picture folders that need to be copied and detected, providing a data basis for subsequent quality inspection work. In a certain day's inspection task, when the system polls at 10 am, it identifies 100 subfolders named with timestamps. After filtering by the time window sliding algorithm, 20 target folders that meet the time range from 9 am to 10 am are determined, packaged as copy tasks and added to the queue, waiting for subsequent copy operations.
[0067] Example 2:
[0068] In the asynchronous scheduling algorithm involved in step S2, the specific implementation includes the following steps:
[0069] Step S21: The system will monitor the status information of each target storage node in real time, including real-time bandwidth and storage capacity. Based on this information obtained in real time, the number of copy threads is dynamically allocated. For example, if a certain target storage node currently has sufficient bandwidth and a large storage capacity, the system will allocate more copy threads to it to make full use of the resources of this node and speed up the copying speed; conversely, if a node has a small bandwidth or the storage capacity is close to the upper limit, the system will reduce the number of copy threads allocated to it to avoid copy failure or low efficiency due to insufficient resources. Suppose there are three target storage nodes A, B, and C in a distributed storage system. The current bandwidth of node A is 100 Mbps, and the remaining storage capacity is 500 GB; the bandwidth of node B is 50 Mbps, and the remaining storage capacity is 200 GB; the bandwidth of node C is 30 Mbps, and the remaining storage capacity is 100 GB. Based on this information, the system allocates 5 copy threads to node A, 3 copy threads to node B, and 1 copy thread to node C.
[0070] Step S22: During the picture copying process, a breakpoint resume mechanism is adopted. When the copy task is interrupted, the system will perform a hash check on the interrupted task. Hash check is a method to verify the integrity of a file by calculating the hash value of the file through a specific algorithm. The system will record the checksum of the completed file so that when resuming the copy, it can accurately determine which parts have been successfully copied and which parts need to be copied again. For example, when copying a folder containing 100 pictures, the network is briefly interrupted when copying the 50th picture. After the interruption, the system determines through hash check that the first 49 pictures have been completely copied and records their checksums, and then continues to copy from the 50th picture, avoiding the time waste of copying from the beginning and greatly improving the reliability and efficiency of the copy. In practical applications, this mechanism performs particularly well in an environment with unstable network, ensuring the smooth completion of the picture copy task and reducing the repetitive work caused by network problems.
[0071] Embodiment 3:
[0072] The working process of the distributed inference engine in Step S3 is specifically as follows:
[0073] Step S31: After the image copy is completed, the distributed inference engine will first parse the log file of the copy task. The log file details various information during the image copy process, including the absolute path of the image and the storage node information. By parsing these log files, the engine can accurately extract the absolute path of each image and the storage node where it is stored. For example, in an image processing system in a large data center, a large number of images are copied to different storage nodes every day. The distributed inference engine can quickly obtain the storage location information of the images by parsing the log files, providing a basis for subsequent inference task allocation. Suppose in a certain day's task, 1000 images are copied. After parsing the log files, the distributed inference engine accurately extracts the absolute path and storage node information of each image, preparing for the subsequent inference tasks.
[0074] Step S32: Dynamically allocate inference tasks according to the GPU computing power of each detection node. Nodes with stronger GPU computing power are allocated relatively more inference tasks to fully utilize their computing advantages. At the same time, a heartbeat mechanism is used to monitor the node status. The heartbeat mechanism is a technology that periodically sends signals to confirm whether a node is running normally. Every certain period, the detection node sends a heartbeat signal to the distributed inference engine. If the engine does not receive the heartbeat signal of a certain node within the specified time, it will determine that the node has failed, and then adjust the inference task allocation strategy in a timely manner, reallocating the tasks originally assigned to the failed node to other normal nodes. For example, in a system consisting of 10 detection nodes, the GPU computing power of nodes 1 to 3 is relatively strong, and the GPU computing power of nodes 4 to 10 is relatively weak. The distributed inference engine allocates 70% of the inference tasks to nodes 1 to 3 and 30% of the tasks to nodes 4 to 10 according to the computing power. During operation, if node 5 fails and is detected by the heartbeat mechanism, the distributed inference engine will reallocate the tasks originally assigned to node 5 to other normal nodes to ensure the smooth progress of the inference tasks and improve the reliability and stability of the system.
[0075] Example 4:
[0076] The specific implementation steps of the multi-model fusion detection algorithm in Step S4 are as follows:
[0077] Step S41: Input the image to be detected into the Yolo V5 model. The Yolo V5 model is an efficient object detection model. It comprehensively analyzes the image and outputs the bounding box coordinates and confidence scores of the defects. The bounding box coordinates determine the specific location of the defect in the image, while the confidence score represents the credibility of the detected defect by the model. For example, for an image containing a product, the Yolo V5 model may detect a suspected defect area on the product and output the bounding box coordinates of this area as (x1, y1, x2, y2), and the confidence score is 0.9. This means that the model believes the credibility of the defect existing in this area is 90%.
[0078] Step S42: Extract the image area within the bounding box detected by the Yolo V5 model and input it into the ResNet-50 model. The ResNet-50 model is a commonly used image classification model. It performs multi-label classification on this image area and generates the probability distribution of defect types. For example, after analysis by the ResNet-50 model, the probability that this defect area belongs to a scratch defect is 0.7, the probability that it belongs to a crack defect is 0.2, and the probability that it belongs to other defects is 0.1.
[0079] Step S43: Perform weighted fusion on the outputs of the two types of models. The calculation formula is: C = α·S Yolo +(1 - α)·S ResNet . Where C is the comprehensive confidence, representing the credibility score of the defect detection result after fusion. It combines the detection results of the Yolo V5 model and the ResNet-50 model and more accurately reflects the reliability of defect detection; α is the dynamic weight coefficient, adjusted according to the historical detection accuracy. It determines the relative importance of the Yolo V5 model and the ResNet-50 model in the fusion result; S Yolo is the confidence score of the Yolo V5 model, representing the prediction credibility of the object detection model for the defect location and bounding box; S ResNet is the classification probability of the ResNet-50 model, representing the probability distribution of the defect type by the classification model. In practical applications, assume that after statistical analysis of historical detection data for a period of time, the value of α is determined to be 0.6. For a certain image, the confidence score S Yolo of the YoloV5 model is 0.8, and the classification probability S ResNet of the ResNet-50 model for a certain defect type is 0.7. According to the formula calculation, the comprehensive confidence C = 0.6×0.8+(1 - 0.6)×0.7 = 0.76. Through this multi-model fusion method, the accuracy and reliability of defect detection can be improved, providing more powerful support for subsequent decision-making.
[0080] Example 5:
[0081] Step S51: In step S5, the dynamic threshold adjustment module will statistically analyze the confidence distribution of historical detection results. The system will collect the confidence data of all detection results within a period of time, such as collecting the detection results in the past week. Then, the mean μ and variance σ within the sliding window are generated through a specific algorithm. 2 . The mean μ reflects the average level of the confidence of detection results during this period, and the variance σ 2 reflects the degree of dispersion of the confidence data. For example, after collecting the confidence data of 1000 detection results, through calculation, the mean μ within the sliding window is 0.8, and the variance σ 2 is 0.04.
[0082] Step S52: According to the real-time data volume of the current detection task, the threshold T is dynamically adjusted according to the formula T = μ + k·σ. Where k is the sensitivity coefficient, which can be adjusted according to actual needs. The larger the sensitivity coefficient k, the more sensitive the threshold T is to data fluctuations. For example, when the data volume of the current detection task is large, in order to ensure the accuracy and reliability of the detection results, the value of k can be appropriately increased. Suppose the current μ = 0.8, σ = 0.2 (calculated from the variance σ 2 = 0.04), and k is set to 1.5, then the calculated threshold T = 0.8 + 1.5×0.2 = 1.1 (here it is assumed that the confidence score has been normalized in a certain way and the value range is suitable for this calculation). The detection data with a confidence higher than this threshold T in the detection results is retained and associated with the corresponding picture metadata.
[0083] Step S61: In step S6, when constructing the bidirectional index, using the defect type as the key, aggregate the paths and detection times of all associated pictures. For example, for the defect type of "scratch", the system will collect the paths of all pictures detected with scratch defects and the corresponding detection times, and store them in the index item with "scratch" as the key. In this way, when it is necessary to query all pictures with scratch defects, the relevant picture paths and detection time information can be quickly obtained through the key of "scratch".
[0084] Step S62: Using the image path as the key, reverse map it to the corresponding defect type set and detection parameters. For example, when the path of a certain image is known, through this reverse index, the defect type set corresponding to the image and related detection parameters, such as detection time, confidence level, etc., can be quickly found. This construction method of two-way index greatly improves the efficiency of data query, facilitating users to quickly obtain the required detection data. Whether querying from the perspective of defect type or image path, accurate results can be obtained quickly. In a large image detection database, a large number of product detection images are stored. Through this two-way index mechanism, when quality inspection personnel want to view all images with a certain specific defect or want to know the detailed detection information of a certain image, relevant data can be obtained within a short time, improving work efficiency and the accuracy of decision-making.
[0085] Example 6:
[0086] During the entire process of automatically copying and detecting images, the following operations are also included:
[0087] Step S71: When a task of copying or detection fails, the exception rollback module will perform a root cause analysis on the failed task. By analyzing various information during the task execution process, distinguish problems such as network interruption, storage overflow, or model abnormality. For example, if a network connection timeout error occurs during the copying process, it can be judged as a network interruption problem; if a storage space shortage is prompted when storing images, it is a storage overflow problem; if an error prompt appears during the operation of the detection model, it indicates a model abnormality problem.
[0088] Step S72: Select a retry strategy according to the root cause type. For model abnormality tasks, they will be assigned to standby detection nodes. For example, assume that during the detection process, the model on the main detection node has an abnormality, and the system will reassign the detection task to the standby detection node and use the normal model on the standby node for detection to ensure that the detection task can continue. For network interruption and storage overflow problems, appropriate retry timing and methods can be selected according to the specific situation, such as waiting for the network to recover and then copying again, or cleaning up the storage space and then trying to store again.
[0089] Step S8: The system collects the images corresponding to the low-confidence detection results as training samples. The low-confidence detection results may indicate that the current model has deficiencies in detecting certain situations. The federated learning algorithm is used to distributively update the model parameters on multiple detection nodes. The federated learning algorithm is a distributed machine learning algorithm that allows each detection node to collaboratively update the model parameters without sharing the original data. For example, each detection node calculates the update gradients of the model parameters based on the locally collected low-confidence detection result image samples, and then uploads this gradient information to a central server. The central server aggregates and processes the gradient information uploaded by each node, and then distributes the updated model parameters to each detection node, thereby realizing the distributed update of the model. In this way, the performance of the model can be continuously optimized, the accuracy and reliability of detection can be improved, and it can adapt to the changing detection requirements. In practical applications, as time goes by and new product types or defect situations emerge, by collecting low-confidence detection result images and using the federated learning algorithm to update the model parameters, the system can continuously improve its detection ability and better meet the needs of production and quality control.
[0090] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device.
[0091] Although the embodiments of the present invention have been shown and described, it will be understood by those of ordinary skill in the art that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of the present invention, and the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for automatically copying pictures and automatically detecting pictures, characterized in that, It includes the following steps: Step S1: Regularly scan a preset source directory through a dynamic task generation module, extract picture folders that meet the time naming rule, and generate a copy task queue containing the start time and end time according to the time window parameters; Step S2: Extract tasks from the copy task queue according to the priority based on the asynchronous scheduling algorithm, traverse the picture folders in the source directory that match the time window through a multi-threaded script, and copy the picture files to multiple target storage nodes in parallel; Step S3: Use a distributed inference engine to perform real-time path parsing on the copied pictures, generate an inference task queue containing the picture paths and metadata, and allocate it to multiple detection nodes based on the load balancing strategy; Step S4: Adopt a multi-model fusion detection algorithm to perform target detection on the pictures, including using the Yolo V5 model for defect localization and combining the ResNet-50 model for defect type classification, and output structured detection results; Step S5: Screen the detection results through a dynamic threshold adjustment module for confidence, retain the detection data higher than the adaptive threshold, and associate the screened results with the corresponding picture metadata; Step S6: Store the associated data in a distributed database in time series and establish a two-way index based on the defect type and the picture path.
2. The method for automatically copying pictures and automatically detecting pictures according to claim 1, characterized in that Step S1 further includes: Step S11: Poll the source directory according to the preset time interval and identify the sub-folders named with timestamps; Step S12: Based on the time window sliding algorithm, extract the list of target folders in the sub-folders that meet the start time and end time range; Step S13: Package the list of the target folders into copy tasks and add them to the queue sorted by priority.
3. The method for automatically copying pictures and automatically detecting pictures according to claim 1, characterized in that The asynchronous scheduling algorithm in Step S2 includes: Step S21: Dynamically allocate the number of copy threads according to the real-time bandwidth and storage capacity of the target storage nodes; Step S22: Adopt the breakpoint resumption mechanism to perform hash verification on the interrupted copy tasks and record the checksum of the completed files.
4. The method for automatically copying pictures and automatically detecting pictures according to claim 1, characterized in that, The working process of the distributed inference engine in Step S3 includes: Step S31: Parse the log file of the copy task, extract the absolute path of the picture and the storage node information; Step S32: Dynamically allocate inference tasks according to the GPU computing power of the detection nodes and monitor the node status by using the heartbeat mechanism.
5. The method for automatically copying pictures and automatically detecting pictures according to claim 1, wherein The multi-model fusion detection algorithm in Step S4 includes: Step S41: Output the bounding box coordinates and confidence scores of the defects through the Yolo V5 model; Step S42: Use the ResNet-50 model to perform multi-label classification on the image area within the bounding box and generate the defect type probability distribution; Step S43: Perform weighted fusion on the outputs of the two types of models, and the calculation formula is: C = α·S Yolo +(1 - α)·S ResNet Among them, C is the comprehensive confidence level, representing the credibility score of the defect detection result after fusion. α is the dynamic weight coefficient, which is adjusted according to the historical detection accuracy; S Yolo is the confidence score of the Yolo V5 model, representing the prediction credibility of the target detection model for the defect position and the bounding box. S ResNet is the classification probability of the ResNet-50 model, representing the probability distribution of the defect types by the classification model.
6. The method for automatically copying pictures and automatically detecting pictures according to claim 1, wherein The calculation method of the adaptive threshold in Step S5 is: Step S51: Statistically analyze the confidence distribution of historical detection results to generate the mean μ and variance σ within the sliding window 2 ; Step S52: Dynamically adjust the threshold T according to the real-time data volume of the current detection task according to the formula T = μ + k·σ, where k is the sensitivity coefficient.
7. The method for automatically copying pictures and automatically detecting pictures according to claim 1, characterized in that, The construction method of the two-way index in Step S6 includes: Step S61: Use the defect type as the key to aggregate the paths and detection times of all associated pictures; Step S62: Using the image path as the key, inversely map it to the corresponding defect type set and detection parameters.
8. The method for automatically copying pictures and automatically detecting pictures according to claim 1, wherein, It further includes: Step S7: Use the exception rollback module to mark tasks with copy or detection failures, and reassign them to standby nodes based on the historical success rate.
9. The method for automatically copying pictures and automatically detecting pictures according to claim 8, wherein Step S7 includes: Step S71: Conduct a root cause analysis on the failed tasks to distinguish between network interruption, storage overflow, or model anomaly types; Step S72: Select a retry strategy according to the root cause type, where model anomaly tasks are assigned to standby detection nodes.
10. The method for automatically copying pictures and automatically detecting pictures according to claim 1, characterized in that It further includes: Step S8: Collect images corresponding to low-confidence detection results as training samples, and use the federated learning algorithm to distributively update model parameters on multiple detection nodes.
Citation Information
Cited By
Multi-dimensional vehicle picture quality inspection auditing method and system
CN121259511A