A method and system for detecting imperfect grains of wheat
By using a network-adaptive detection method on smartphone terminals, combined with cloud and edge models, high-precision real-time detection of imperfect wheat grains was achieved in field harvesting scenarios. This solved the dilemma of model accuracy and environmental adaptability, ensuring high efficiency and reliability of the detection.
Patent Information
- Application Number
- CN202611394148.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-11-20
AI Technical Summary
In field purchasing scenarios, the wheat imperfect grain detection technology faces a dilemma: insufficient accuracy of end-side models and the inability of cloud-based models to be used offline. This makes it difficult to simultaneously meet the requirements of high precision and field adaptability in terms of detection accuracy and usability.
By sensing the network status in real time through a smartphone terminal, the image processing is switched to a lightweight model in the cloud or locally. High-precision recognition is performed when the network is good by utilizing the high computing resources of the cloud, and offline detection is performed by relying on the lightweight model on the device when there is no network, thus realizing network adaptive detection.
It can achieve high-precision, fine-grained identification of imperfect granular categories under various network conditions, and ensure the continuous availability of detection services. It solves the problem of detection interruption in unstable network environments and improves detection efficiency and accuracy.
Smart Images

Figure CN123141933A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of food quality and safety testing technology, and in particular to a method and system for detecting imperfect grains in wheat. Background Technology
[0002] In wheat quality grading, the content of imperfect grains is one of the core indicators. In related technologies, the detection of imperfect grains mainly relies on manual sensory inspection. This involves inspectors, under specific lighting conditions, using a magnifying glass to observe, classify, count, and weigh each grain in a wheat sample, ultimately calculating the percentage content of each type of imperfect grain. This method depends on professionally trained inspectors and relatively stable ambient lighting conditions; the repeatability of the test results largely depends on the inspectors' subjective judgment and operational consistency.
[0003] In on-site testing scenarios such as field purchases, the applicable conditions for the above methods have changed significantly. Grassroots purchasing points typically lack systematically trained professional testing personnel and testing environments that provide standard lighting. Consequently, there are often significant discrepancies in the judgments of different testing personnel regarding the same batch of samples. Faced with the demand for large-scale centralized testing of samples during peak purchasing seasons, the pace of individual observation and classification is insufficient to meet the time requirements for rapid on-site processing.
[0004] To overcome the aforementioned difficulties, some technologies have emerged that utilize mobile smart terminals in conjunction with lightweight edge AI models for on-site testing. This approach involves capturing sample images with a mobile phone, after which the edge model directly outputs the test results. However, limited by the computing resources of mobile terminals, the parameter scale of the edge model is significantly compressed, resulting in insufficient ability to identify fine features such as minor lesions and early mold on the grain surface. The actual testing accuracy struggles to consistently reach professional testing levels, and the model is difficult to continuously update and optimize after deployment. To address the insufficient accuracy of edge models, other technologies have emerged that involve mobile terminals capturing images and uploading them to a cloud server, then calling a cloud-based AI model for identification. However, the effective operation of this approach entirely depends on a continuous network connection between the mobile terminal and the cloud. In field purchasing scenarios, grassroots purchasing points are often located in remote rural areas or mountainous regions, where unstable or even nonexistent network signal coverage is common. Once the network is interrupted, the testing app cannot return any usable results.
[0005] In other words, in on-site inspection scenarios such as field purchasing, image recognition detection solutions based on mobile smart terminals face a dilemma: if lightweight edge models are used, the limited expressive power of the models makes it difficult to guarantee detection accuracy, and the fine-grained classification capability is insufficient; if large cloud-based models are used for online inference, service availability cannot be guaranteed in field environments with poor network signal coverage, and the detection operation may be interrupted at any time due to network outages. These contradictions mean that grassroots purchasing points cannot simultaneously obtain high-precision and usable imperfect grain detection services in actual operation. Quality judgment at the purchasing site can only revert to inefficient and highly biased manual inspection methods, directly restricting the efficiency and accuracy of quality control in the grain purchasing process. Summary of the Invention
[0006] The purpose of this application is to provide a method and system for detecting imperfect grains in wheat, which can effectively balance high-precision identification with adaptability to complex field environments, and solve the dilemma of insufficient accuracy of end-side models and the inability of cloud models to be used offline in field testing scenarios such as field acquisition.
[0007] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a method for detecting imperfect grains in wheat, comprising: The smartphone terminal acquires the original image of the wheat sample to be tested and obtains the network status information at the current stage; Smartphones determine the current network level based on the current network status information; the network level includes good network status, poor network status, and no network status. When the current network level is either good or poor, the smartphone will encrypt the original image and upload it to the cloud server. The cloud server will perform cloud preprocessing on the original image to generate a cloud-standardized image, and then input the cloud-standardized image into the trained cloud visual recognition model for inference to obtain the online classification result of each seed. When the current network level is no network, the smartphone terminal stores the original image in the local cache, performs local preprocessing on the original image, generates a local standardized image, calls the locally deployed lightweight model to infer the local standardized image, and obtains the offline classification result of each seed. The cloud server counts the total number of seeds and the number of each type of imperfect seed based on the online classification results of each seed or the smartphone terminal counts the offline classification results of each seed. Based on the total number of seeds and the number of each type of imperfect seed, the percentage content of each type of imperfect seed is calculated. The cloud server or smartphone terminal generates a test report based on the percentage content of various imperfect grains and the preset wheat quality grade judgment standards.
[0008] Secondly, this application provides a wheat imperfect grain detection system, comprising: A standardized image acquisition auxiliary device is detachably and fixedly connected to a smartphone terminal. The standardized image acquisition auxiliary device includes a portable acquisition box, a standard background plate set at the bottom of the portable acquisition box, a 24-color card and a scale set on the surface of the standard background plate; the standard background plate is used to hold the wheat sample to be tested, the 24-color card is used to perform color correction on the original image, and the scale is used to correct the size of the original image. The smartphone terminal is equipped with an image acquisition module, a network status detection module, a caching module, and an offline inference module. The image acquisition module is used to acquire the original image of the wheat sample to be tested; The network status detection module is used to obtain network status information at the current stage and determine the network level at the current stage based on the network status information at the current stage; the network level includes good network status, poor network status, and no network status; The offline inference module is used to perform local preprocessing on the original image when the network level is in a no-network state at the current stage, generate a local standardized image, call the locally deployed lightweight model to perform inference on the local standardized image, and obtain the offline classification result of each seed. The caching module is used to store the original image and the offline classification results of each seed when the current network level is in a no-network state. The cloud server communicates with the smartphone terminal and is equipped with an image preprocessing engine and a cloud-based visual recognition model inference engine. The image preprocessing engine is used to receive the original image uploaded by the smartphone terminal after encryption, and to perform cloud preprocessing on the original image to generate a cloud-standardized image; The cloud-based visual recognition model inference engine is used to input standardized images from the cloud into the trained cloud-based visual recognition model for inference, and obtain the online classification result for each seed. The statistics and report generation module, located on a cloud server or smartphone terminal, is used to count the total number of grains and the number of various types of imperfect grains based on the online or offline classification results of each grain. It calculates the percentage content of each type of imperfect grain based on the total number of grains and the number of each type of imperfect grain, and generates a test report based on the percentage content of each type of imperfect grain and the preset wheat quality grade judgment standard.
[0009] According to the specific embodiments provided in this application, this application has the following technical effects: This application provides a method and system for detecting imperfect grains in wheat. It obtains the network status information of the current stage through a smartphone terminal and determines the network level of the current stage based on the network status information. This enables the detection method to perceive and adaptively identify the current network environment in real time. It solves the problem in related technologies that neither edge-side models nor cloud-based models can dynamically adapt to the optimal inference path according to network conditions. This allows the detection process to flexibly switch processing strategies according to the network level, laying the decision-making foundation for achieving network adaptive detection.
[0010] When the network is in a good or poor state, the smartphone uploads the encrypted original image to the cloud server. The cloud server preprocesses the original image and uses a trained cloud-based visual recognition model to perform inference to obtain the online classification result for each grain. Under network connectivity, the detection process can leverage the abundant computing resources of the cloud server to run a visual recognition model with larger parameters and stronger feature extraction capabilities. This solves the problem in related technologies where lightweight models on the mid-end side have insufficient computing resources, resulting in insufficient ability to identify fine features such as minor lesions and early mold on the grain surface, and the detection accuracy is difficult to reach the level of professional inspection. It achieves high-precision, fine-grained identification of imperfect grain categories. Simultaneously, when the network level is offline, the smartphone terminal stores the original image in a local cache and calls the locally deployed lightweight model to perform inference to obtain the offline classification result of each grain. This allows the detection process to independently complete inference and output usable detection results in field environments without network coverage, relying on the edge lightweight model. This solves the problem in related technologies where cloud-based inference solutions that rely entirely on continuous network connections cannot return any usable results and the detection operation is forced to be interrupted at grassroots acquisition points with unstable signal coverage or no signal at all. It achieves continuous availability of detection services in offline environments.
[0011] By using a cloud-based visual recognition model to obtain online classification results for each grain when the network is connected, and using a lightweight edge model to obtain offline classification results for each grain when there is no network, the system calculates the total number of grains and the number of various types of imperfect grains based on the online or offline classification results, calculates the percentage content of various types of imperfect grains, and generates a test report by combining the preset wheat quality grade judgment standards. This ensures that the test process can obtain classification results and complete the output from the original image to the standardized test report under any network conditions using a model inference strategy that is adapted to it. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is an application environment diagram of a method for detecting imperfect wheat grains provided in Embodiment 1 of this application; Figure 2 This is a general architecture diagram of a wheat imperfect grain detection system provided in Embodiment 2 of this application; Figure 3 This is a schematic diagram of the standardized image acquisition auxiliary device provided in Embodiment 2 of this application; Figure 4 This is a schematic diagram of the architecture of the cloud-based AI visual recognition model provided in Embodiment 2 of this application; Figure 5 This is a schematic diagram of the steps of the full-process detection method provided in Embodiment 2 of this application; Figure 6 A flowchart of the network adaptive and hybrid inference strategy provided in Embodiment 2 of this application; Figure 7 This is a schematic diagram of the expert annotation and model iteration closed loop provided in Embodiment 2 of this application; Figure 8 This is a schematic diagram of the user interface of the smartphone detection application provided in Embodiment 2 of this application. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0015] To address the aforementioned issues, improved solutions for on-site testing using mobile smart terminals have emerged in related technologies. These solutions analyze captured sample images using lightweight models built into the mobile terminal and output test results, achieving rapid on-site screening to a certain extent. However, limited by the computing resources and storage space of mobile terminals, the parameter scale and network depth of the edge model are significantly constrained. Its ability to characterize fine visual features such as minor lesions, early mold areas, and tiny insect-eaten holes on the grain surface is insufficient, and its ability to distinguish between different subtypes of imperfect grains (especially between black-embryo grains and Fusarium-infected grains) is limited. The actual detection accuracy is difficult to consistently reach professional testing levels. To further improve recognition accuracy, related technologies have also emerged that upload images to the cloud to call large-scale models for recognition, utilizing the abundant computing resources of the cloud to extract richer image features and output more refined classification results. However, the effective operation of this solution depends entirely on a continuous network connection between the mobile terminal and the cloud; image uploading, inference requests, and result returns all require a stable network connection. Field collection points are often located in remote rural areas or mountainous regions, where unstable network signal coverage, limited bandwidth, or even no signal are common occurrences. Once the network connection is interrupted or the latency increases, the testing process cannot obtain usable results, and the on-site collection operation is forced to stop.
[0016] In addition, some solutions propose using industrial cameras in conjunction with traditional machine learning algorithms for grain image recognition. However, these solutions have stringent environmental requirements, typically requiring operation in fixed experimental environments with dedicated hardware, making them difficult to implement in field settings. Furthermore, manual feature extraction methods have limited ability to identify subtle features in complex scenarios and are susceptible to interference from factors such as lighting, angle, and grain overlap, resulting in insufficient detection accuracy and stability. Other solutions have designed grain detection devices incorporating conveyor belts and fixed lighting systems, but these devices are large, complex, and costly to manufacture, making them suitable only for laboratories or fixed quality control lines. They are not suitable for mobile operations, and mechanical transport may cause secondary damage to grains. The single-pass processing efficiency is also insufficient to meet the rapid detection needs of large batches of samples. Simultaneously, existing solutions generally lack standardized image acquisition aids, leading to significant variability in the shooting angles, distances, and lighting conditions used by field operators. This makes it difficult to guarantee the repeatability of detection results, and the models struggle to adapt to new disease types or abnormal samples, lacking the ability for continuous optimization.
[0017] In summary, existing wheat imperfect grain detection technologies suffer from varying degrees of shortcomings in terms of identification accuracy, detection efficiency, environmental adaptability, continuous model optimization capabilities, and network dependence. These limitations make it difficult to simultaneously meet the comprehensive requirements of field harvesting scenarios, which demand high accuracy, high efficiency, portability, ease of use, offline availability, and continuous optimization. Therefore, there is an urgent need in this field for a wheat imperfect grain detection technology solution that can overcome these deficiencies.
[0018] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0019] Example 1 In one exemplary embodiment, such as Figure 1 As shown, a method for detecting imperfect grains in wheat is provided. In the embodiments of this application, a method is used... Figure 1 The following steps, 101 to 105, will be used as an example for illustration. Among them: Step 101: The smartphone terminal acquires the original image of the wheat sample to be tested and obtains the network status information of the current stage.
[0020] Step 102: The smartphone terminal determines the network level of the current stage based on the network status information of the current stage; the network level includes good network status, poor network status, and no network status.
[0021] Step 103a: When the network level at the current stage is either good or poor, the smartphone terminal encrypts the original image and uploads it to the cloud server. The cloud server performs cloud preprocessing on the original image to generate a cloud-standardized image, and inputs the cloud-standardized image into the trained cloud visual recognition model for inference to obtain the online classification result of each seed.
[0022] Step 103b: When the network level at the current stage is no network, the smartphone terminal stores the original image in the local cache, performs local preprocessing on the original image to generate a local standardized image, calls the locally deployed lightweight model to perform inference on the local standardized image, and obtains the offline classification result of each seed.
[0023] Step 104: The cloud server counts the total number of seeds and the number of each type of imperfect seed based on the online classification results of each seed or the smartphone terminal counts the offline classification results of each seed, and calculates the percentage content of each type of imperfect seed based on the total number of seeds and the number of each type of imperfect seed.
[0024] Step 105: The cloud server or smartphone terminal generates a test report based on the percentage content of various imperfect grains and the preset wheat quality grade judgment standard.
[0025] By implementing steps 101 to 105 above, this embodiment has the following beneficial effects: (1) By obtaining the network status information of the current stage through the smartphone terminal and judging the network level of the current stage based on the network status information, the detection method realizes the real-time perception and adaptive recognition of the current network environment. This solves the problem that neither the edge model nor the cloud model in the related technology can dynamically adapt to the optimal inference path according to the network conditions, and enables the detection process to flexibly switch processing strategies according to the network level, laying the decision-making foundation for realizing adaptive network detection.
[0026] (2) When the network level is good or poor, the smartphone terminal encrypts the original image and uploads it to the cloud server. The cloud server preprocesses the original image and calls the trained cloud visual recognition model to perform inference to obtain the online classification result of each grain. Under network connectivity, the detection process can run a visual recognition model with larger parameter scale and stronger feature extraction capability with the help of the abundant computing resources of the cloud server. This solves the problem that the lightweight model on the mid-end side of the related technology has insufficient ability to recognize fine features such as fine spots and early mold on the surface of the grain due to limited computing resources, and the detection accuracy is difficult to reach the professional inspection level. This invention achieves high-precision, fine-grained identification of imperfect grain categories. Simultaneously, when the network level is offline, the smartphone terminal stores the original image in a local cache and calls a locally deployed lightweight model for inference to obtain offline classification results for each grain. This allows the detection process to independently complete inference and output usable detection results in field environments without network coverage, relying on the edge-side lightweight model. This solves the problem in related technologies where cloud-based inference solutions that rely entirely on continuous network connections cannot return any usable results and the detection operation is forced to be interrupted at grassroots acquisition points with unstable or no signal coverage. It achieves continuous availability of detection services in offline environments.
[0027] (3) By using a cloud-based visual recognition model to obtain the online classification results of each grain when the network is connected, and using a lightweight end-side model to obtain the offline classification results of each grain when there is no network, the total number of grains and the number of various imperfect grains are counted based on the online or offline classification results, the percentage content of various imperfect grains is calculated, and a test report is generated in combination with the preset wheat quality grade judgment standard. This ensures that the test process can obtain classification results and complete the output from the original image to the standardized test report under any network conditions using a model inference strategy that is compatible with it.
[0028] In summary, this application, by organically combining real-time network status perception, adaptive path switching based on network level, high-precision inference in the cloud, and offline inference on the edge, ensures service availability in network-free environments while guaranteeing detection accuracy. It effectively balances the two mutually restrictive requirements of high-precision recognition and adaptability to complex field environments, and solves the dilemma of insufficient accuracy of edge models and the inability of cloud models to be used offline in field detection scenarios such as field acquisition.
[0029] Furthermore, in step 102, the smartphone terminal determines the network level of the current stage based on the current network status information, specifically including: The smartphone terminal detects the network bandwidth, latency, and packet loss rate at preset time intervals.
[0030] The network is considered to be in good condition when the bandwidth of the current stage is greater than or equal to the preset first bandwidth threshold, the latency of the current stage is less than or equal to the preset first latency threshold, and the packet loss rate of the current stage is less than or equal to the preset first packet loss rate threshold.
[0031] When the network bandwidth at the current stage is less than the first bandwidth threshold but greater than or equal to the second bandwidth threshold, the network latency at the current stage is greater than the first latency threshold but less than or equal to the second latency threshold, and the network packet loss rate at the current stage is greater than the first packet loss rate threshold but less than or equal to the second packet loss rate threshold, the network is judged to be in a poor state.
[0032] When there is no cellular network or wireless LAN connection, or when the network bandwidth at the current stage is less than the second bandwidth threshold, the system is determined to be in a no-network state.
[0033] Furthermore, in step 103a, when the current network level is either good or poor, the smartphone terminal encrypts the original image and uploads it to the cloud server, specifically including: When the current network level is poor, the smartphone terminal compresses the original image based on a preset first compression ratio to obtain a compressed image, and then uploads the compressed image to the cloud server using a breakpoint resume and chunked upload method.
[0034] When the current network level is in a good state, the smartphone terminal compresses the original image based on a preset second compression ratio to obtain a compressed image, and then uploads the compressed image directly to the cloud server; wherein, the first compression ratio is greater than the second compression ratio.
[0035] Furthermore, in step 103a, the cloud server performs cloud preprocessing on the original image to generate a cloud-standardized image, specifically including: Identify the 24-color card area built into the bottom of the standardized acquisition auxiliary device in the original image, extract the actual red, green and blue channel values of each color block in the 24-color card area, map the actual red, green and blue channel values of each color block to the standard color space, and output the color-corrected image.
[0036] Identify the scale area built into the bottom of the standardized acquisition auxiliary device in the original image, calculate the number of pixels on the side of the scale, calculate the conversion coefficient between the number of pixels and the actual physical length of the scale based on the actual physical length and the number of pixels on the side of the scale, and process the original image based on the conversion coefficient to output the size-corrected image.
[0037] The color-corrected image and the size-corrected image are fused together to generate a standardized image.
[0038] Furthermore, the operation process for cloud-based preprocessing and local preprocessing is the same.
[0039] Further, in step 103a, the cloud-based visual recognition model includes a hybrid backbone network, a detection branch, a segmentation branch, and a classification branch. The hybrid backbone network includes a convolutional neural network branch, a visual transformer branch, and a multi-scale feature pyramid fusion module. The standardized image is input into the trained cloud-based visual recognition model for inference to obtain the online classification result for each seed, specifically including: By using branches of a convolutional neural network to extract local texture features from a standardized image, multiple first feature maps of different scales are obtained.
[0040] The first feature map at at least one scale is divided into blocks to obtain the block-based feature map. The global context features are then extracted from the block-based feature map using a visual transformer branch to generate the second feature map.
[0041] Multiple first and second feature maps at different scales are input into the multi-scale feature pyramid fusion module for fusion processing to generate a multi-scale fused feature map.
[0042] Based on the multi-scale fusion feature map, target detection is performed on each seed in the standardized image through the detection branch, and the target bounding box coordinates of each seed are output.
[0043] Based on the multi-scale fused feature map and the target bounding box coordinates of each seed, pixel-level instance segmentation is performed on each seed through segmentation branches, and the segmentation mask of each seed is output.
[0044] Based on the multi-scale fused feature map and the segmentation mask of each grain, each grain is classified through classification branches, and the online classification result of each grain is output. The online classification result includes perfect grain category and imperfect grain category. Imperfect grain category includes insect-damaged grain category, black embryo grain category, Fusarium head blight grain category, heat-damaged grain category, broken grain category, sprouted grain category and moldy grain category.
[0045] Further, in step 103b, the smartphone terminal stores the original image in a local cache, performs local preprocessing on the original image to generate a locally standardized image, calls the locally deployed lightweight model to perform inference on the locally standardized image, and obtains the offline classification result for each seed. This step also includes: When the smartphone detects that the network level has recovered from no network to good network or poor network, the smartphone uploads the locally cached original image and the offline classification results of each seed to the cloud server.
[0046] After receiving the original image, the cloud server preprocesses it to generate a standardized image. The standardized image is then input into the trained cloud-based visual recognition model for inference, resulting in an updated online classification result for each seed.
[0047] The cloud server calculates the total number of seeds and the number of each type of imperfect seed based on the updated online classification results for each seed, and then calculates the update percentage of each type of imperfect seed based on the total number of seeds and the number of each type of imperfect seed.
[0048] The cloud server generates an updated test report based on the updated percentage content of various imperfect grains and the preset wheat quality grade judgment standards, and pushes the updated test report to the smartphone terminal.
[0049] Furthermore, before step 104, in which the cloud server calculates the total number of seeds and the number of each type of defective seed based on the online classification results of each seed or the smartphone terminal calculates the offline classification results of each seed, the following steps are also included: The cloud server determines the confidence level of the online classification result for each seed, or the smartphone terminal determines whether the confidence level of the offline classification result for each seed is greater than or equal to a preset confidence threshold.
[0050] If so, the target seed is not marked; the target seed is any seed.
[0051] If not, the target grains are marked as uncertain samples.
[0052] The cloud server periodically pushes uncertain samples to the expert annotation platform. The expert annotation platform receives the corrected annotation results of the quality inspection experts for the uncertain samples, uses the corrected annotation results to perform incremental training or fine-tuning on the trained cloud visual recognition model, obtains the updated cloud visual recognition model, and deploys the updated cloud visual recognition model to the cloud server.
[0053] Furthermore, methods for detecting imperfect wheat grains also include: After receiving the updated test report, the smartphone terminal responds to the user's manual correction of the test results in the updated test report, generates a manually corrected sample, and uploads the manually corrected sample to the cloud server.
[0054] The cloud server periodically filters samples to be labeled from the detection records; the samples to be labeled include uncertain samples and manually corrected samples.
[0055] The cloud server calculates the uncertainty index for each sample in the unlabeled sample; the uncertainty index includes confidence entropy and marginal confidence.
[0056] The cloud server clusters the feature vectors of all samples in the unlabeled sample set. Based on the uncertainty index from high to low and the cluster diversity from high to low, the samples with a preset percentage before sorting are selected as high-value samples and pushed to the expert annotation platform.
[0057] The expert annotation platform receives the corrected annotation results of high-value samples from quality inspection experts, and uses the corrected annotation results to incrementally train or fine-tune the cloud-based visual recognition model. After the evaluation is passed, the updated cloud-based visual recognition model is deployed to the cloud server, and the updated lightweight model is pushed to the smartphone terminal through OTA technology.
[0058] Example 2 This embodiment provides a specific implementation of a wheat imperfect grain detection system, which includes four main components: a smartphone acquisition terminal, a standardized image acquisition auxiliary device, a cloud-based AI visual recognition platform, and an expert annotation and training platform. These components work together to form a complete cloud-edge integrated intelligent detection system.
[0059] I. System Overall Architecture: like Figure 2 As shown, the system in this application consists of four core units: a smartphone acquisition terminal, a standardized image acquisition auxiliary device, a cloud-based AI visual recognition platform, and an expert annotation and training platform.
[0060] The smartphone acquisition terminal serves as the on-site image acquisition and user interaction unit, utilizing mainstream smartphones and requiring no customized hardware. The smartphone data acquisition terminal has the following functional and performance requirements: In terms of imaging capabilities, the rear main camera must be at least 48 megapixels, supporting autofocus and 4K video recording; in terms of processing performance, the processor must have at least 6 cores, a main frequency of at least 2.4GHz, and at least 6GB of memory, supporting local image processing; in terms of communication capabilities, it must support 4G, 5G, and Wi-Fi communication, with network adaptive capabilities; in terms of positioning and sensing, it must have a built-in global navigation satellite system positioning module, ambient light sensor, and gyroscope for recording detection location and assisting in image quality assessment; in terms of the user interface, it must run a dedicated detection application, providing image acquisition guidance, detection result display, and historical record query functions; in terms of data security, the detection application must have encrypted data transmission, local data protection, and user authentication mechanisms; in terms of offline capabilities, it must have a built-in lightweight artificial intelligence model extracted from a large cloud-based visual recognition model through knowledge distillation, with parameters ranging from 5M to 10M, supporting degraded inference when the network is unavailable; in terms of compatibility, it must support mainstream operating systems such as Android 10.0 and above for robots and iOS 14.0 and above for Apple mobile devices.
[0061] like Figure 3 As shown, the standardized image acquisition auxiliary device serves as a companion device for smartphones, used to standardize the shooting process and improve the consistency of image acquisition quality. This standardized image acquisition auxiliary device is detachably and fixedly connected to the smartphone terminal, specifically including a portable acquisition box, a standard background board located at the bottom of the portable acquisition box, and a 24-color card and scale bar located on the surface of the standard background board. The portable acquisition box is made of lightweight materials. The standard background board is a black standard background board with a frosted anti-reflective treatment. The 24-color card and the scale bar are used for color and size correction of the original image. The top of the portable acquisition box has a clip structure for securing the smartphone, which is fixed to the top of the portable acquisition box via this clip structure, allowing the smartphone's camera to be aimed at the wheat sample to be tested on the standard background board.
[0062] like Figure 4As shown, the cloud-based AI visual recognition platform, serving as the core computing and inference hub, is deployed on a cloud server cluster and adopts a layered pipeline architecture. The cloud-based AI visual recognition platform consists of 10 core units: an intelligent image preprocessing engine, an AI visual recognition hybrid backbone network, a seed instance detection and segmentation module, a fine-grained feature extraction module, a multi-classification inference module, a high-speed inference scheduling engine, a result statistics and reporting module, a data storage and management module, an application programming interface (API) service interface, and a lightweight model generation module. Each module achieves data flow and function calls through internal message queues and expressive state passing APIs.
[0063] The data flow and connection relationships of the cloud-based AI visual recognition platform are as follows: The application programming interface (API) service interface receives the raw images uploaded by the smartphone terminal and forwards them to the intelligent image preprocessing engine; the preprocessing engine outputs standardized images to the AI visual recognition hybrid backbone network; the hybrid backbone network outputs multi-scale feature maps to the seed instance detection and segmentation module; the detection and segmentation module outputs single-seed cropped images and segmentation masks to the fine-grained feature extraction module; the feature extraction module outputs feature vectors to the multi-classification inference module; the multi-classification inference module outputs classification results and confidence scores to the result statistics and reporting module; all intermediate data and final results are synchronously stored in the data storage and management module; the lightweight model generation module extracts knowledge from the hybrid backbone network and the multi-classification inference module to generate a lightweight model on the edge.
[0064] The expert annotation and training platform and the cloud-based AI visual recognition platform are deployed on the same cloud server cluster, achieving high-speed communication via an internal private network with a latency of no more than 10 milliseconds. They interact with each other through the following interfaces: a high-value sample push interface, where the cloud-based AI visual recognition platform periodically pushes uncertain samples, user-corrected samples, and newly added abnormal samples to the expert annotation platform; an annotation result callback interface, where the expert annotation platform sends the annotated sample data back to the cloud data storage module; and a model deployment interface, through which the expert training platform automatically deploys the newly trained model to the inference engine of the cloud-based AI visual recognition platform.
[0065] II. Detailed Functions of Each Module in the Cloud-based AI Visual Recognition Platform: The input data for the application programming interface (API) service interface consists of encrypted raw images, device information, acquisition parameters, and user identity tokens uploaded by the smartphone terminal; the processing methods include Hypertext Transfer Security Protocol (HTTP) decryption, identity authentication, request rate limiting, data format verification, and task queue scheduling; the output data consists of the decrypted raw images, task identifiers, acquisition metadata, and detection results and reports returned to the terminal.
[0066] The intelligent image preprocessing engine takes as input the original image, acquisition metadata, and standardized acquisition device calibration information. Processing methods include: automatic exposure compensation, correcting overexposed or underexposed areas based on image grayscale histogram equalization and Retinex theory; white balance correction, performing color space conversion by identifying standard white blocks on a built-in color chart; super-resolution reconstruction, using an enhanced super-resolution generative adversarial network to upscale low-resolution images to 4K resolution; background semantic segmentation, achieving pixel-level separation of seeds and background based on a U-shaped network model; and low-quality image filtering, automatically filtering substandard images based on image sharpness, contrast, and illumination uniformity scores. Output data includes standardized preprocessed images, background segmentation masks, and image quality scores.
[0067] The input data for the AI visual recognition hybrid backbone network consists of standardized preprocessed images. The processing method employs a hybrid architecture of convolutional neural networks and visual transformers. The convolutional neural network branch uses the backbone structure of a residual network to extract multi-scale local texture features from the input image. The visual transformer branch receives multiple first feature maps at different scales output from the convolutional neural network branch, performs block processing on the feature maps, and extracts global contextual features. The multi-scale feature pyramid fusion module fuses the four feature maps at different scales output from the convolutional neural network branch with the global feature map (i.e., the second feature map) output from the visual transformer branch, introducing a native bidirectional multi-head self-attention mechanism to enhance the capture of minute defect features. The output data is a multi-scale fused feature map.
[0068] The input data for the seed instance detection and segmentation module is a multi-scale fused feature map. The processing methods include: locating the target bounding box of each seed based on the YOLOv8 target detection algorithm; performing pixel-level instance segmentation of each detected seed based on a mask region convolutional neural network; separating overlapping seeds by using a watershed algorithm combined with contour features to separate adhered seeds; and removing invalid regions by filtering out abnormal regions with an area less than one-third or more than three times that of normal seeds. The output data consists of single-seed cropped images (N images in total, where N is the number of seeds), seed segmentation mask, seed coordinate information, and seed contour features.
[0069] The fine-grained feature extraction module takes as input a cropped image of a single grain and a grain segmentation mask. Processing methods include: defect region localization, using heatmap visualization to locate potential defect areas on the grain surface; micro-feature enhancement, employing an attention mechanism to enhance the response of micro-features such as lesions and insect damage; and multi-dimensional feature extraction, extracting grain shape features (including length, width, area, perimeter, and aspect ratio), color features (including statistical values from the red-green-blue color space, hue-saturation-brightness color space, and CIELab color space), texture features (including gray-level co-occurrence matrix and local binary pattern features), and depth features (384-dimensional vector). The output data is a multi-dimensional feature vector of a single grain (416 dimensions).
[0070] The input data for the multi-classification inference module is a multi-dimensional feature vector of a single grain. The processing method uses a fully connected layer and a flexible maximum activation function for classification inference. The confidence threshold is set to 0.85, and samples below this threshold are marked as uncertain. The output data includes grain category labels (a total of 8 categories, including insect-damaged grains, black-embryo grains, Fusarium-bacterial grains, heat-damaged grains, broken grains, sprouted grains, moldy grains, and perfect grains), classification confidence, and uncertain sample labels.
[0071] The high-speed inference scheduling engine takes inference task requests as input and uses the TensorRT inference framework for processing, combined with a graphics processing unit (GPU) accelerator for model quantization and optimization, supporting parallel inference across multiple GPUs and task load balancing. The output consists of inference task scheduling instructions and a summary of inference results. Inference time for a single image does not exceed 100 milliseconds, and it supports 1000 concurrent requests.
[0072] The input data for the results statistics and reporting module includes the classification results and confidence levels of all grains, as well as collected metadata. The processing methods include: counting the total number of grains, the number and proportion of each type of imperfect grain; determining the quality grade according to the national standard "Wheat" (GB1351-2023); generating a visual report containing the testing time, location, equipment information, testing results, and grade determination; and outputting structured test results, portable document format test reports, and JavaScript object simplified spectrum format data interfaces.
[0073] The input data for the data storage and management module includes the original image, preprocessed image, intermediate feature map, detection results, and detection report. The processing method uses the MinIO object storage system to store image files and the PostgreSQL relational database to store structured data. All data is encrypted using the advanced encryption standard AES-256. The output data includes the data storage path and data retrieval results.
[0074] The input data for the lightweight model generation module consists of the weight parameters and training data of a large cloud-based AI visual recognition model. The processing method adopts a teacher-student network knowledge distillation framework, combined with model pruning and INT8 quantization technology. The output data is a lightweight AI model on the edge (parameter scale of 5M to 10M), which can be pushed to smartphone terminals via OTA technology.
[0075] III. Detailed Functions of the Expert Annotation and Training Platform: Annotation tools and interface: Provides professional web-based annotation tools that support image zooming, annotation box drawing, category selection, multi-label annotation, and annotation history review; supports multi-person collaborative annotation and cross-review of annotation results.
[0076] Sample library management: Manages the labeled sample database, supports the classification, retrieval, statistics and export of samples by category, collection time, collection region and labeling quality; realizes automatic division and version management of training set, validation set and test set.
[0077] Model training platform: Based on the PyTorch deep learning framework, it provides a distributed training environment; supports multiple training modes such as model fine-tuning, incremental training, and knowledge distillation; and automatically records the loss function and accuracy metrics during the training process.
[0078] Continuous learning mechanism: monthly automatic collection of actual field test data, screening of high-value samples for expert annotation; quarterly incremental model training, and annual full training.
[0079] Model evaluation and deployment: The trained model is comprehensively evaluated from multiple dimensions, including recognition accuracy, recall, F1 score, inference speed, and robustness; after passing the evaluation, the model is deployed according to the automatic model deployment process.
[0080] IV. Core and Key Technologies: (I) Cloud-based AI visual recognition large-scale model construction technology: The AI visual recognition large-scale model constructed by this technology adopts a hybrid backbone architecture of convolutional neural network for local feature extraction, visual transformer for global feature modeling, and multi-scale feature fusion. The specific network structure and connection method are as follows: The input layer receives a red, green, and blue three-channel image with a size of 1024×1024×3.
[0081] The convolutional neural network feature extraction branch adopts the backbone structure of a residual network, which includes the following layers: the first layer is a convolutional layer (7×7 kernel size, stride of 2, and 64 output channels), followed by a batch normalization layer and a modified linear unit activation function; the second layer is a max pooling layer (pooling window size of 3×3 and stride of 2); the third to sixth layers are the four residual stages of the residual network, each of which adopts a bottleneck structure. Each bottleneck structure consists of a 1×1 convolutional layer, a 3×3 convolutional layer, and a 1×1 convolutional layer connected in sequence. The four residual stages output feature maps with a resolution of 256×256 and 256 channels, a resolution of 128×128 and 512 channels, a resolution of 64×64 and 1024 channels, and a resolution of 32×32 and 2048 channels, respectively.
[0082] The visual transformer feature modeling branch divides the 64×64×256 feature map into 16×16 4×4×256 image blocks; adds learnable positional encoding vectors; processes the data through a 4-layer transformer encoder, each layer of which contains an 8-head multi-head self-attention mechanism and a feedforward neural network; and outputs a 64×64×512 global feature map.
[0083] Multi-scale feature pyramid: The feature maps of three different scales output by the convolutional neural network branch are fused with the feature maps output by the visual transformer branch. The number of channels is unified by 1×1 convolution, and feature fusion is achieved by upsampling and element-wise addition. Finally, a multi-scale fused feature map of 1024×1024×256 is output.
[0084] Detection head and segmentation head: The detection head is implemented based on the YOLOv8 object detection algorithm and outputs the target bounding box coordinates and class confidence; the segmentation head is implemented based on a mask region convolutional neural network and outputs a pixel-level segmentation mask.
[0085] Classification Header: The first fully connected layer maps 416 dimensions to 256 dimensions, followed by a modified linear unit activation function and a Dropout layer with a dropout rate of 0.5; the second fully connected layer maps 256 dimensions to 8 dimensions, followed by a flexible maximum activation function, outputting the classification probability of 8 types of seeds.
[0086] Training process: In the first stage, contrastive learning pre-training is performed on the ImageNet-1K general vision dataset; in the second stage, self-supervised pre-training is performed on an industry-wide general dataset containing 1 million grain images, which are obtained by collecting field photos of various grain crops, standard laboratory images, and images from publicly available datasets; in the third stage, supervised fine-tuning is performed on a specialized dataset of imperfect wheat grains.
[0087] (ii) Expert-driven supervised training techniques: A labeling team consisting of more than 5 professional grain quality inspection experts with over 10 years of experience was formed to formulate labeling standards for imperfect wheat grains and to perform fine-grained labeling on the collected wheat images.
[0088] The active learning high-value sample selection algorithm employs a hybrid active learning strategy based on uncertainty and diversity. The specific steps are as follows: Uncertainty calculation: Calculate the confidence entropy and marginal confidence index for the model's inference results. Use K-means clustering to cluster the feature vectors of all unlabeled samples, ensuring the selected samples cover different feature spaces. Sample ranking: Rank the samples comprehensively according to the principles of high to low uncertainty and high to low diversity. Sample selection: Select the top 10% of samples as high-value samples and submit them to experts for priority labeling. Iterative optimization: After labeling each batch of samples, retrain the model and update the uncertainty calculation for the next round of selection. This algorithm improves model accuracy by more than 3 times compared to random labeling with the same amount of labeling work. A professional training dataset containing no fewer than 12,000 labeled images has been constructed.
[0089] (III) Network Adaptation and Hybrid Inference Strategies: This technology dynamically selects the optimal inference strategy by monitoring network conditions in real time. The specific process corresponds to... Figure 6 .
[0090] Real-time network status monitoring: The smartphone application checks the current network type (including 2G, 3G, 4G, 5G, and Wi-Fi), bandwidth, latency, and packet loss rate every 500 milliseconds. Network status levels are defined as follows: Good status: 4G, 5G, or Wi-Fi, bandwidth not less than 10 Mbps, latency not exceeding 100 milliseconds, and packet loss rate not exceeding 1%; Poor status: 3G or weak 4G, bandwidth 1 to 10 Mbps, latency 100 to 500 milliseconds, and packet loss rate 1% to 5%; No network status: no cellular network or Wi-Fi connection, or 2G or cellular networks with bandwidth less than 1 Mbps, in which case the network bandwidth is insufficient to complete the transmission of the minimum compressed image within the preset timeout period.
[0091] Intelligent inference strategy selection: When the network is good, the cloud-based large model inference strategy is selected. The input is the original image (1024×1024 resolution). The image is processed by compressing it to 80% of the quality parameter in the Joint Image Experts Group format and encrypting it with the Hypertext Transfer Security Protocol before uploading it to the cloud application programming interface. The output is the complete detection results and report returned by the cloud-based large model. When the network is poor, the low bandwidth adaptation strategy is selected. The input is the original image. The image is processed by compressing it to 50% of the quality parameter and uploading it using breakpoint resume and chunked upload methods. The output is the detection results returned by the cloud-based large model. When there is no network, the on-device offline inference strategy is selected. The input is the original image. The processing involves calling the local lightweight AI model for inference. The output is the preliminary detection results. At the same time, the original image and the preliminary detection results are encrypted and cached locally.
[0092] Data synchronization and result update: When the network recovers from a no-network or poor-network state to a good state, the detection application automatically synchronizes the cached original images and preliminary detection results to the cloud; the cloud uses the cloud-based visual recognition large model to re-infer and generate more accurate detection results; the detection application automatically updates the detection results stored locally and prompts the user to view the updated report.
[0093] (iv) Standardized data collection and cloud-based calibration technology: The standardized data acquisition device has a built-in standard 24-color chart and a 1 cm × 1 cm square scale at the bottom. The cloud preprocessing engine automatically identifies the color chart area and scale through the following steps: Automatic color chart region recognition: The input is the original image; the processing involves extracting the color regions in the image based on color threshold segmentation, using a contour detection algorithm to find regions with 24 consecutive rectangular blocks, using a template matching algorithm to compare with a standard 24 color chart template to determine the color chart position, and extracting the average red, green and blue channel values of each color block in the color chart; the output is the coordinates of the color chart region and the red, green and blue channel values of each color block.
[0094] Automatic scale recognition: The input is the original image and color chart area coordinates; the processing involves finding the square outline in the area near the color chart, calculating the side length and number of pixels of the square outline, and calculating the conversion ratio between pixels and actual length based on the known actual side length (1 cm); the output is the scale area coordinates and pixel-cm conversion coefficient.
[0095] Image correction: The input consists of the original image, the red, green and blue channel values of the color chart, and the pixel-to-cm conversion coefficient; the processing consists of color correction (mapping the red, green and blue channel values of the original image to the color space of the standard color chart) and size correction (calculating the actual size of the seeds based on the conversion coefficient), and a device feature library is established to record the imaging parameters of different mobile phone models to eliminate differences between devices; the output is the corrected standardized image.
[0096] V. Intelligent detection method for imperfect particles throughout the entire process: like Figure 5 As shown, this method corresponds to the five major stages of wheat quality testing: sample preparation, image acquisition, cloud recognition, result statistics, and expert optimization, forming a complete business and optimization closed loop.
[0097] Sample preparation stage: In accordance with the requirements of the national standard "Sampling and Segmentation Method for Grain and Oil Inspection" (GB / T 5491), wheat samples were sampled and segmented. The segmented test samples were then evenly spread in a single layer or near-single layer on the standard background plate of the standardized image acquisition auxiliary device.
[0098] Image Acquisition Stage: The smartphone is secured to the clip of the standardized image acquisition auxiliary device, with the smartphone's camera aimed at the wheat sample to be tested on the standard background board. Standardized image acquisition is performed using a dedicated detection application. The application automatically detects network conditions, compresses and encrypts the image, and then selects to upload it to the cloud server or perform local offline processing based on network policy. Specifically, the smartphone acquires the original image of the wheat sample to be tested and obtains the current network status information, determining the current network level (including good network, poor network, and no network). When the network level is good or poor, the smartphone uploads the encrypted original image to the cloud server; when the network level is no network, the smartphone stores the original image in a local cache, performs local preprocessing to generate a local standardized image, and calls a locally deployed lightweight model to infer the local standardized image, obtaining the offline classification result for each grain.
[0099] Cloud-based recognition and classification stage: After receiving the image, the cloud application programming interface first performs decryption and intelligent image enhancement preprocessing. Then, it calls the cloud-based AI visual recognition model to perform object detection and fine-grained classification, outputting the category label and confidence score for each seed. Seeds with a confidence score below the threshold (0.85) are marked as uncertain samples. Specifically, the cloud server preprocesses the original image to generate a standardized image, and inputs the standardized image into the trained cloud-based visual recognition model for inference, obtaining the online classification result for each seed.
[0100] Results Statistics and Report Generation Stage: Statistical analysis is performed on the cloud-based identification results to calculate the percentage of various imperfect grains. The quality grade is determined according to the national standard "Wheat" (GB 1351-2023), and a visual inspection report is automatically generated. Specifically, the cloud server or smartphone terminal counts the total number of grains and the number of various imperfect grains based on the online or offline classification results for each grain. The percentage content of each imperfect grain is calculated based on the total number of grains and the number of imperfect grains, and an inspection report is generated based on the percentage content of each imperfect grain and the preset wheat quality grade determination standards.
[0101] Expert optimization and model iteration stage: such as Figure 7 As shown, the cloud server periodically collects actual detection data, especially samples marked as uncertain and samples manually corrected by users. These samples are then finely annotated by professional quality control experts through an annotation platform. The newly annotated samples are used for incremental training or fine-tuning of the existing cloud-based visual recognition model. After evaluation, the new model is automatically deployed online, and an updated lightweight model is pushed to the client side via OTA technology. Specifically, the cloud server periodically pushes uncertain samples to the expert annotation platform. The expert annotation platform receives the corrected annotation results from quality control experts for the uncertain samples, uses the corrected annotation results to perform incremental training or fine-tuning of the trained cloud-based visual recognition model, obtains an updated cloud-based visual recognition model, and deploys the updated cloud-based visual recognition model to the cloud server. When the smartphone terminal detects that the network level has recovered from no network to good network or poor network, the smartphone terminal uploads the locally cached original image and offline classification results to the cloud server. The cloud server re-performs inference to generate an updated detection report and pushes the updated detection report to the smartphone terminal. After receiving the updated detection report, the smartphone terminal, in response to the user's manual correction operation on the detection results in the updated detection report, generates manually corrected samples and uploads the manually corrected samples to the cloud server. The cloud server periodically filters samples to be labeled (including uncertain samples and manually corrected samples) from the detection records, calculates the uncertainty index of each sample (including confidence entropy and marginal confidence), clusters the feature vectors of all samples in the samples to be labeled, and sorts them from high to low uncertainty index and from high to low cluster diversity. The samples selected before sorting are a preset percentage (preferably 10%) and pushed to the expert labeling platform as high-value samples. After being labeled by experts, they are used for incremental training of the model.
[0102] Example 3 This embodiment provides an application of a method and system for detecting imperfect wheat grains in a field purchasing scenario. This embodiment is applied to rapid on-site testing during the wheat purchasing season, where wheat samples submitted by farmers need to be inspected and priced within a short period. This scenario faces challenges such as inconsistent network conditions, limited professional skills of grassroots purchasing personnel, and a lack of standard lighting conditions.
[0103] Hardware selection and parameters: The smartphone data acquisition terminal uses a mainstream commercial smartphone equipped with a multi-core processor with a main frequency of no less than 2.4GHz, no less than 6GB of RAM, a rear main camera with no less than 48 megapixels, supporting autofocus and 4K video recording, and supporting 4G or 5G mobile communication technology. Preferably, the smartphone is equipped with an octa-core processor with a main frequency of 2.4GHz, 8GB of RAM, and a 50-megapixel rear main camera.
[0104] The standardized image acquisition auxiliary device uses a portable acquisition box. The bottom of the box is equipped with a black standard background board with a frosted anti-reflective finish. The bottom also contains a 24-color card and a scale (1 cm x 1 cm square scale). Specifically, the standardized image acquisition auxiliary device is detachably and fixedly connected to the smartphone terminal, which is secured to the top of the standardized image acquisition auxiliary device via a snap-fit structure.
[0105] The cloud server is deployed on a public cloud platform and is equipped with a graphics processing unit (GPU) cluster. Preferably, the GPU cluster includes multiple GPU accelerator cards. The expert annotation and training platform is deployed on the same cloud platform and is equipped with annotation workstations and a training cluster.
[0106] The specific processing logic of the image preprocessing engine: After receiving the original image, the image preprocessing engine identifies the 24-color card region built into the bottom of the standardized acquisition auxiliary device in the original image. It extracts the actual red, green, and blue channel values of each color block in the 24-color card region, maps these values to a standard color space, and outputs the color-corrected image. Specifically, during color correction, firstly, color regions in the original image are extracted based on color threshold segmentation. A contour detection algorithm is used to find regions with 24 consecutive rectangular blocks. A template matching algorithm is used to compare these regions with a standard 24-color card template to determine the color card's location. The average red, green, and blue channel values of each color block in the color card are extracted, and these extracted average red, green, and blue channel values are mapped to a standard color space to obtain the color-corrected image.
[0107] Simultaneously, the image preprocessing engine identifies the scale bar region built into the bottom of the standardized acquisition auxiliary device in the original image, calculates the number of pixels per side of the scale bar, and calculates a conversion coefficient between the number of pixels and the actual physical length based on the actual physical length of the scale bar. Based on this conversion coefficient, the original image is processed to output a size-corrected image. Specifically, during the size correction process, a square outline is first located in the vicinity of the 24-color chart, and the number of pixels per side of this square outline is calculated. Based on the actual side length (1 cm) of this square outline, the conversion ratio between pixels and actual length is calculated to obtain a pixel-to-centimeter conversion coefficient. Based on this conversion coefficient, the pixel size of the seeds in the original image is converted to their actual physical size, resulting in the size-corrected image.
[0108] Finally, the color-corrected image and the size-corrected image are fused to generate a standardized image. Optionally, both color correction and size correction are preprocessing operations on the original image, and they can be performed in parallel or sequentially, without limitation.
[0109] The specific reasoning process of the cloud-based visual recognition model: The cloud-based visual recognition model includes a hybrid backbone network, detection branch, segmentation branch, and classification branch. The hybrid backbone network includes a convolutional neural network branch, a visual transformer branch, and a multi-scale feature pyramid fusion module.
[0110] Standardized images are input into a cloud-based visual recognition model for inference, resulting in online classification results for each seed. Specifically, a convolutional neural network (CNN) branch is used to extract local texture features from the standardized images, yielding multiple first feature maps at different scales. This CNN branch employs a residual network structure. Specifically, the CNN branch includes a first convolutional layer, a max-pooling layer, and multiple residual block groups connected sequentially. For example, the first convolutional layer is a 7×7 kernel with a stride of 2 and 64 output channels, followed by a batch normalization layer and a modified linear unit activation function; the max-pooling layer is a 3×3 max-pooling layer with a stride of 2; and the multiple residual block groups output first feature maps at different scales.
[0111] The first feature map at at least one scale is divided into blocks to obtain block-based feature maps. Global context features are then extracted from the block-based feature maps using a visual transformer branch to generate a second feature map. Specifically, the first feature map at a certain scale output by the convolutional neural network branch is divided into multiple image blocks. A learnable positional encoding vector is added to each image block, and then the blocks are processed by a multi-layer transformer encoder. Each layer of the transformer encoder includes a multi-head self-attention mechanism and a feedforward neural network.
[0112] Multiple first and second feature maps at different scales are input into a multi-scale feature pyramid fusion module for fusion processing to generate a multi-scale fused feature map. Specifically, the number of channels in each feature map is unified through 1×1 convolution, and feature fusion is achieved through upsampling and element-wise addition.
[0113] Based on the multi-scale fused feature map, target detection is performed on each seed in the standardized image through a detection branch, outputting the target bounding box coordinates for each seed. Optionally, the detection branch is implemented based on the YOLOv8 target detection algorithm, outputting the bounding box coordinates and class confidence score for each seed.
[0114] Based on the multi-scale fused feature map and the target bounding box coordinates of each seed, pixel-level instance segmentation is performed on each seed through a segmentation branch, outputting a segmentation mask for each seed. Optionally, the segmentation branch is implemented based on Mask R-CNN.
[0115] Based on the multi-scale fused feature map and the segmentation mask for each grain, each grain is classified through classification branches, and the online classification result for each grain is output. The online classification result includes perfect grains and imperfect grains. Imperfect grains include insect-damaged grains, black-embryo grains, Fusarium head blight grains, heat-damaged grains, broken grains, sprouted grains, and moldy grains.
[0116] Complete implementation process: Sample Preparation: Following the requirements of the national standard "Sampling and Segmentation Methods for Grain and Oil Inspection" (GB / T 5491), wheat samples were sampled and segmented. Farmers submitted approximately 500 grams of wheat sample, and the purchasing agent took approximately 50 grams for testing. The segmented sample was then evenly spread in a single or near-single layer on the standard background plate of the standardized image acquisition auxiliary device. The purchasing agent inspected and removed any obvious inorganic impurities.
[0117] Image Acquisition: Secure the smartphone to the acquisition device's clip, and point the smartphone's camera at the wheat sample on the standard background board. The buyer opens the testing application on the smartphone, such as... Figure 8 The diagram illustrates the user interface of a smartphone testing application, including an image acquisition guidance interface. The application automatically detects ambient lighting conditions and uses a 24-color chart and scale bar built into the standardized image acquisition auxiliary device to assist in acquiring standardized images. It should be noted that during the image acquisition stage, the sample carried in the standardized image acquisition auxiliary device is a single or near-single layer of the wheat sample to be tested, laid flat on a standard background board. The 24-color chart and scale bar are positioned on the surface of the standard background board, outside the sample area, and do not obstruct the sample area. The smartphone terminal acquires the original image of the wheat sample to be tested through the image acquisition module.
[0118] Network Detection and Image Upload: Simultaneously with or after image acquisition, the smartphone terminal obtains the network status information for the current stage and determines the network level based on this information. In this embodiment, the smartphone terminal detects a good network, indicating a good network level. Specifically, the smartphone terminal detects the bandwidth, latency, and packet loss rate of the network at preset time intervals. When the bandwidth is greater than or equal to a preset first bandwidth threshold, the latency is less than or equal to a preset first latency threshold, and the packet loss rate is less than or equal to a preset first packet loss rate threshold, the network is determined to be in a good state.
[0119] When the network is in a good condition, the smartphone uploads the encrypted original image to the cloud server. Specifically, when the network is in a good condition, the smartphone compresses the original image based on a preset second compression ratio to obtain a compressed image, and then uploads the compressed image directly to the cloud server. Preferably, the second compression ratio corresponds to an image quality parameter of 80%, meaning the image is compressed using the Joint Photographic Experts Group (JPEG) format with a quality parameter of 80%.
[0120] The image is encrypted using Hypertext Transfer Protocol Secure (HTTPS) and uploaded to the cloud server via an Application Programming Interface (API) service interface. After receiving the encrypted original image from the smartphone terminal, the API service interface performs HTTPS decryption, authentication, request rate limiting, data format validation, and task queue scheduling, outputting the decrypted original image, task identifier, and acquired metadata.
[0121] Cloud-based recognition: The image preprocessing engine on the cloud server receives the original image and preprocesses it to generate a standardized image. The cloud-based visual recognition model inference engine inputs the standardized image into the trained cloud-based visual recognition model for inference, obtaining the online classification result for each seed.
[0122] The cloud-based visual recognition model is pre-built and trained in the following ways: A hybrid backbone network is constructed, comprising a convolutional neural network branch, a visual transformer branch, and a multi-scale feature pyramid fusion module. The convolutional neural network branch extracts local texture features from the input image and outputs multiple first feature maps at different scales. The visual transformer branch divides the first feature maps at at least one scale output by the convolutional neural network branch into blocks and extracts global contextual features to generate second feature maps. The multi-scale feature pyramid fusion module fuses the multiple first feature maps at different scales with the second feature maps to generate a multi-scale fused feature map.
[0123] Construct detection, segmentation, and classification branches. The detection branch outputs the target bounding box coordinates and class confidence of each seed based on the multi-scale fused feature map. The segmentation branch outputs the segmentation mask of each seed based on the multi-scale fused feature map. The classification branch outputs the class probability of each seed based on the multi-scale fused feature map.
[0124] During the training phase, contrastive learning pre-training was first performed on a general visual dataset (such as the ImageNet-1K dataset), followed by self-supervised pre-training on a grain image dataset, and finally supervised fine-tuning on a wheat imperfect grain annotation dataset. The images in this wheat imperfect grain annotation dataset were pixel-level categorized by quality inspection experts according to pre-defined annotation specifications. Specifically, the wheat imperfect grain annotation dataset contains no fewer than 12,000 annotated images.
[0125] Results Statistics and Report Generation: The statistics and report generation module on the cloud server counts the total number of grains and the number of each type of imperfect grain based on the online classification results for each grain. It then calculates the percentage content of each type of imperfect grain based on the total number of grains and the number of each type of imperfect grain. The statistics and report generation module determines the wheat quality grade according to the national standard "Wheat" (GB 1351-2023). Specifically, based on the statistical results and the limits for imperfect grain content in each grade of wheat in the national standard (Grade 1 ≤ 6.0%, Grade 2 ≤ 6.0%, Grade 3 ≤ 8.0%, Grade 4 ≤ 8.0%, Grade 5 ≤ 10.0%), the module automatically determines the quality grade of the tested sample.
[0126] Example 4 The statistics and report generation module generates a visualized test report that includes the test time, test location, equipment information, the quantity and proportion of various imperfect particles, and the quality grade determination results. The generated test report is available in Portable Document Format (PDF) and JavaScript Object Notation (JSON) format. The cloud server returns the test results and report to the test application on the smartphone terminal via an API service interface.
[0127] Real-time pricing: The testing application on the smartphone displays the test report, including the percentage content of various defective grains and the determined wheat quality grade. Based on the quality grade and referring to the current purchase price, the testing application automatically calculates the purchase price and generates an electronic order.
[0128] Data synchronization and traceability: The testing application encrypts and uploads test reports, order information, and original images to the cloud server, links them to sample batch information, and generates a unique traceability QR code. Purchasing personnel can print or display this traceability QR code for subsequent traceability purposes.
[0129] Offline caching: The detection application automatically caches the original image, detection results, and detection report of this detection to the local storage of the smartphone terminal.
[0130] Furthermore, before statistical analysis, the confidence level assessment module of the cloud server determines whether the confidence level of the online classification result for each seed is greater than or equal to a preset confidence level threshold. If yes, the seed is not marked; otherwise, it is marked as an uncertain sample. Preferably, the confidence level threshold is preset to 0.85. That is, seeds with a confidence level lower than 0.85 are marked as "uncertain" and are not included in the statistical calculation of the percentage content of various imperfect seeds.
[0131] The main technical effects of this embodiment are: This embodiment obtains the current network status information and determines the network level through a smartphone terminal. When the network level is good, the original image is uploaded to the cloud server. The cloud server preprocesses the original image and calls the trained cloud-based visual recognition model to perform inference to obtain the online classification result of each grain. This fully leverages the abundant computing resources of the cloud server, enabling the visual recognition model to effectively capture and accurately classify fine visual features such as minor lesions, early moldy areas, and tiny insect-eaten holes on the grain surface, significantly improving the identification accuracy of imperfect grains. Simultaneously, the statistics and report generation module automatically completes the total grain count, the number of various imperfect grains, percentage content calculation, quality level determination, and the generation of a standardized test report based on the online classification results of each grain. This achieves a complete process from raw data processing to data collection and analysis. The entire process from image acquisition to test report output is automated, significantly reducing the time for a single test. This effectively solves the problem of slow pace in manual sensory inspection, which involves observing, classifying, and counting grain by grain. It can meet the rapid circulation needs of large batches of samples during peak purchasing seasons. In addition, the original images are color and size corrected using a 24-color card and scale bar in a standardized image acquisition auxiliary device. Combined with automatic exposure compensation, white balance correction, and low-quality image filtering by the cloud-based image preprocessing engine, standardized images can be obtained without relying on a professional testing environment. Stable detection accuracy can still be maintained under complex and variable lighting conditions in the field. The visual recognition model deployed in the cloud can be continuously optimized and updated through an expert annotation platform. The model's recognition capability can be continuously improved over time, overcoming the shortcomings of iterative optimization after deployment of edge models.
[0132] Example 5 This embodiment provides a method and system for detecting imperfect wheat grains, applied to the quality inspection of incoming wheat in grain depots. This embodiment is used for the quality inspection of wheat rotation entering and leaving central grain reserves, enabling rapid quality inspection of large quantities of incoming wheat. The grain depot has good network conditions and controllable lighting, but high requirements are placed on detection accuracy and batch processing efficiency.
[0133] Hardware selection and parameters: The smartphone data acquisition terminals are smartphones procured uniformly by the grain depot. Standardized image acquisition auxiliary devices are desktop acquisition boxes. The cloud server is deployed on the grain depot's private cloud server, equipped with a graphics processor cluster. The expert annotation and training platform is deployed on the same private cloud. The system interfaces with the grain depot's grain condition monitoring system and warehouse management system.
[0134] System Integration: The cloud server provides an application programming interface (API) to connect with the grain depot's grain condition monitoring system and storage management system to achieve automatic data entry and correlation of monitoring data.
[0135] Complete implementation process: Sample preparation: In accordance with the requirements of the national standard "Sampling and Segmentation Method for Grain and Oil Inspection" (GB / T 5491), multiple samples (e.g., 25 samples) are taken from the batch of goods entering the warehouse and then segmented for later use.
[0136] Batch Image Acquisition: The inspector opens the testing application on their smartphone and selects "Batch Acquisition" mode. For each sample, multiple images (e.g., 6 images) are acquired using a standardized image acquisition aid and the smartphone. The smartphone terminal acquires the raw images of the wheat samples to be tested and obtains the current network status information. In this embodiment, the grain depot network conditions are good, and the smartphone terminal determines the network level to be good. The smartphone terminal encrypts the raw images and uploads them to the cloud server.
[0137] Cloud-based batch recognition: The image preprocessing engine on the cloud server receives each original image and preprocesses each image to generate a corresponding standardized image. The cloud-based visual recognition model inference engine inputs each standardized image in parallel into the trained cloud-based visual recognition model for inference, obtaining the online classification result for each seed.
[0138] The cloud server's statistics and report generation module calculates the total number of grains and the number of various types of imperfect grains for each sample based on the online classification results of each grain corresponding to each image. It then calculates the percentage content of each type of imperfect grain for each sample based on these data. The module also automatically determines the quality grade of each sample based on the national standard "Wheat" (GB 1351-2023) and the bulk density index provided by the existing grain depot system.
[0139] Manual review and correction: Inspectors view the test reports for each sample through a testing application on their smartphones. For grains marked "uncertain" in the test reports, inspectors can perform manual review and correction. Specifically, in response to the inspector's manual correction of the test results in the test reports, the testing application generates a manually corrected sample and uploads the manually corrected sample to the cloud server.
[0140] Report generation and data entry: The testing application generates separate test reports for each sample. Test data is automatically entered into the grain depot storage management system and linked to the receiving documents.
[0141] Batch aggregation: The cloud server automatically aggregates the test data of multiple samples, generates a batch quality report, and submits it to the regulatory platform. For example, the cloud server aggregates the test data of 25 samples to generate a quality report for the entire batch of wheat.
[0142] Expert optimization and model iteration: The cloud server periodically filters samples to be labeled from the detection records. These samples include uncertain samples and manually corrected samples. The cloud server calculates the uncertainty index for each sample in the unlabeled sample set. The uncertainty index includes confidence entropy and marginal confidence.
[0143] The cloud server clusters the feature vectors of all samples in the unlabeled sample set (e.g., using the K-means clustering algorithm). Based on the uncertainty index from high to low and the cluster diversity from high to low, a preset percentage of samples are selected as high-value samples, and these high-value samples are pushed to the expert annotation platform. Preferably, the preset percentage is 10%.
[0144] The expert annotation platform receives corrected annotations from quality control experts for high-value samples and uses these corrected annotations to incrementally train or fine-tune the cloud-based visual recognition model. Specifically, the platform provides professional web-based annotation tools, supporting image zooming, bounding box drawing, category selection, multi-label annotation, and annotation history review; it also supports collaborative annotation by multiple users and cross-review of annotation results. The platform manages a database of annotated samples, supporting classification, retrieval, statistics, and export of samples by category, collection time, collection region, and annotation quality; it also enables automatic partitioning and version management of training, validation, and test sets. Based on a deep learning framework, the platform provides a distributed training environment, supporting various training modes including model fine-tuning, incremental training, and knowledge distillation, and automatically records the loss function and accuracy metrics during training. The platform employs a continuous learning mechanism: it automatically collects actual field detection data monthly, selects high-value samples for expert annotation, performs incremental model training quarterly, and conducts full training annually.
[0145] The expert annotation platform comprehensively evaluates the trained model across multiple dimensions, including accuracy, recall, F1 score, inference speed, and robustness. After passing the evaluation, the updated cloud-based visual recognition model is deployed to the cloud server via an automated deployment process: first, the new model is deployed to a subset of nodes in the cloud inference cluster for small-scale A / B testing; the system compares the accuracy, recall, and inference speed of the new model with the old model in real time; once the new model outperforms the old model in all metrics and has run stably for a preset period (e.g., 24 hours), it is automatically deployed to all inference nodes; if the new model experiences performance degradation or anomalies, the system automatically rolls back to the previous stable version. Simultaneously, the updated lightweight model is pushed to the offline inference module of the smartphone terminal via OTA (Over-The-Air) technology.
[0146] Comparative Example: This comparative example uses traditional manual sensory inspection methods. Multiple professional inspectors conducted the inspection in accordance with the national standard "Inspection of Impurities and Imperfect Grains in Grains and Oils" (GB / T 5494-2019) under standard light conditions on approximately 500 grams of wheat samples identical to those in Example 1.
[0147] Inspectors used magnifying glasses to observe, classify, count, and weigh each grain of wheat in the sample, ultimately calculating the percentage of defective grains. The test results are as follows: Table 1 Comparison of test results between the proposed method and traditional manual inspection methods
[0148] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0149] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting imperfect grains in wheat, characterized in that, The method includes: The smartphone terminal acquires the original image of the wheat sample to be tested and obtains the network status information at the current stage; Smartphones determine the current network level based on the current network status information; the network level includes good network status, poor network status, and no network status. When the current network level is either good or poor, the smartphone will encrypt the original image and upload it to the cloud server. The cloud server will perform cloud preprocessing on the original image to generate a cloud-standardized image, and then input the cloud-standardized image into the trained cloud visual recognition model for inference to obtain the online classification result of each seed. When the current network level is no network, the smartphone terminal stores the original image in the local cache, performs local preprocessing on the original image, generates a local standardized image, calls the locally deployed lightweight model to infer the local standardized image, and obtains the offline classification result of each seed. The cloud server counts the total number of seeds and the number of each type of imperfect seed based on the online classification results of each seed or the smartphone terminal counts the offline classification results of each seed. Based on the total number of seeds and the number of each type of imperfect seed, the percentage content of each type of imperfect seed is calculated. The cloud server or smartphone terminal generates a test report based on the percentage content of various imperfect grains and the preset wheat quality grade judgment standards.
2. The method for detecting imperfect grains in wheat according to claim 1, characterized in that, Smartphone terminals determine the current network level based on the current network status information, specifically including: The smartphone terminal detects the network bandwidth, latency, and packet loss rate at preset time intervals. When the bandwidth of the network in the current stage is greater than or equal to the preset first bandwidth threshold, the latency of the network in the current stage is less than or equal to the preset first latency threshold, and the packet loss rate of the network in the current stage is less than or equal to the preset first packet loss rate threshold, the network is judged to be in good condition. When the network bandwidth at the current stage is less than the first bandwidth threshold but greater than or equal to the second bandwidth threshold, the network latency at the current stage is greater than the first latency threshold but less than or equal to the second latency threshold, and the network packet loss rate at the current stage is greater than the first packet loss rate threshold but less than or equal to the second packet loss rate threshold, the network is judged to be in a poor state. When there is no cellular network or wireless LAN connection, or when the network bandwidth at the current stage is less than the second bandwidth threshold, the system is determined to be in a no-network state.
3. The method for detecting imperfect wheat grains according to claim 1, characterized in that, When the current network status is either good or poor, the smartphone will encrypt the original image and upload it to the cloud server, specifically including: When the current network level is poor, the smartphone terminal compresses the original image based on a preset first compression ratio to obtain a compressed image, and then uploads the compressed image to the cloud server using the breakpoint resume and block upload methods. When the current network level is in a good state, the smartphone terminal compresses the original image based on a preset second compression ratio to obtain a compressed image, and then uploads the compressed image directly to the cloud server; wherein, the first compression ratio is greater than the second compression ratio.
4. The method for detecting imperfect grains in wheat according to claim 1, characterized in that, The cloud server performs cloud-based preprocessing on the original image to generate a cloud-standardized image, specifically including: Identify the 24-color card area built into the bottom of the standardized acquisition auxiliary device in the original image, extract the actual red, green and blue channel values of each color block in the 24-color card area, map the actual red, green and blue channel values of each color block to the standard color space, and output the color-corrected image. Identify the scale area built into the bottom of the standardized acquisition auxiliary device in the original image, calculate the number of pixels on the side of the scale, calculate the conversion coefficient between the number of pixels and the actual physical length of the scale based on the actual physical length and the number of pixels on the side of the scale, and process the original image based on the conversion coefficient to output the size-corrected image. The color-corrected image and the size-corrected image are fused together to generate a standardized image in the cloud.
5. The method for detecting imperfect wheat grains according to claim 1, characterized in that, The cloud-based visual recognition model includes a hybrid backbone network, detection branch, segmentation branch, and classification branch. The hybrid backbone network includes a convolutional neural network branch, a visual transformer branch, and a multi-scale feature pyramid fusion module. The standardized images are input into a trained cloud-based visual recognition model for inference, resulting in an online classification of each seed, specifically including: Local texture features are extracted from a standardized image using branches of a convolutional neural network to obtain multiple first feature maps at different scales. The first feature map at at least one scale is divided into blocks to obtain the block-based feature map. The global context features are then extracted from the block-based feature map using a visual transformer branch to generate the second feature map. Multiple first and second feature maps of different scales are input into the multi-scale feature pyramid fusion module for fusion processing to generate a multi-scale fused feature map. Based on the multi-scale fusion feature map, target detection is performed on each seed in the standardized image through the detection branch, and the target bounding box coordinates of each seed are output. Based on the multi-scale fused feature map and the target bounding box coordinates of each seed, pixel-level instance segmentation is performed on each seed through segmentation branches, and the segmentation mask of each seed is output. Based on the multi-scale fused feature map and the segmentation mask of each grain, each grain is classified through classification branches, and the online classification result of each grain is output. The online classification result includes perfect grain category and imperfect grain category. Imperfect grain category includes insect-damaged grain category, black embryo grain category, Fusarium head blight grain category, heat-damaged grain category, broken grain category, sprouted grain category and moldy grain category.
6. The method for detecting imperfect wheat grains according to claim 1, characterized in that, Before the cloud server calculates the total number of seeds and the number of each type of defective seed based on the online classification results of each seed or the smartphone terminal calculates the offline classification results of each seed, the process also includes: The cloud server determines whether the confidence level of the online classification result of each seed or the smartphone terminal determines whether the confidence level of the offline classification result of each seed is greater than or equal to a preset confidence threshold. If so, the target seed is not marked; the target seed is any single seed. If not, then mark the target grains as uncertain samples; The cloud server periodically pushes uncertain samples to the expert annotation platform. The expert annotation platform receives the corrected annotation results of the quality inspection experts for the uncertain samples, uses the corrected annotation results to perform incremental training or fine-tuning on the trained cloud visual recognition model, obtains the updated cloud visual recognition model, and deploys the updated cloud visual recognition model to the cloud server.
7. The method for detecting imperfect grains in wheat according to claim 1, characterized in that, The smartphone terminal stores the original image in a local cache, performs local preprocessing on the original image to generate a locally standardized image, calls a locally deployed lightweight model to perform inference on the locally standardized image, and obtains the offline classification result for each seed. This also includes: When the smartphone detects that the network level has recovered from no network to good network or poor network, the smartphone will upload the locally cached original image and the offline classification results of each seed to the cloud server. After receiving the original image, the cloud server preprocesses the original image to generate a standardized image. The standardized image is then input into the trained cloud visual recognition model for inference to obtain the updated online classification result for each seed. The cloud server calculates the total number of seeds and the number of each type of imperfect seed based on the updated online classification results for each seed, and calculates the update percentage of each type of imperfect seed based on the total number of seeds and the number of each type of imperfect seed. The cloud server generates an updated test report based on the updated percentage content of various imperfect grains and the preset wheat quality grade judgment standards, and pushes the updated test report to the smartphone terminal.
8. The method for detecting imperfect grains in wheat according to claim 1, characterized in that, Also includes: After receiving the updated test report, the smartphone terminal responds to the user's manual correction operation on the test results in the updated test report, generates a manually corrected sample, and uploads the manually corrected sample to the cloud server; The cloud server periodically selects samples to be labeled from the detection records; The samples to be labeled include uncertain samples and manually corrected samples; The cloud server calculates the uncertainty index for each sample in the unlabeled samples; the uncertainty index includes confidence entropy and marginal confidence. The cloud server clusters the feature vectors of all samples in the unannotated samples, sorts them from high to low based on uncertainty index and cluster diversity, selects the samples with a preset percentage before sorting as high-value samples, and pushes the high-value samples to the expert annotation platform. The expert annotation platform receives the corrected annotation results of high-value samples from quality inspection experts, and uses the corrected annotation results to incrementally train or fine-tune the cloud-based visual recognition model. After the evaluation is passed, the updated cloud-based visual recognition model is deployed to the cloud server, and the updated lightweight model is pushed to the smartphone terminal through OTA technology.
9. A wheat imperfect grain detection system, characterized in that, include: A standardized image acquisition auxiliary device is detachably and fixedly connected to a smartphone terminal. The standardized image acquisition auxiliary device includes a portable acquisition box, a standard background plate set at the bottom of the portable acquisition box, a 24-color card and a scale set on the surface of the standard background plate; the standard background plate is used to hold the wheat sample to be tested, the 24-color card is used to perform color correction on the original image, and the scale is used to correct the size of the original image. The smartphone terminal is equipped with an image acquisition module, a network status detection module, a caching module, and an offline inference module. The image acquisition module is used to acquire the original image of the wheat sample to be tested; The network status detection module is used to obtain network status information at the current stage and determine the network level at the current stage based on the network status information at the current stage; the network level includes good network status, poor network status, and no network status; The offline inference module is used to perform local preprocessing on the original image when the network level is in a no-network state at the current stage, generate a local standardized image, call the locally deployed lightweight model to perform inference on the local standardized image, and obtain the offline classification result of each seed. The caching module is used to store the original image and the offline classification results of each seed when the current network level is in a no-network state. The cloud server communicates with the smartphone terminal and is equipped with an image preprocessing engine and a cloud-based visual recognition model inference engine. The image preprocessing engine is used to receive the original image uploaded by the smartphone terminal after encryption, and to perform cloud preprocessing on the original image to generate a cloud-standardized image; The cloud-based visual recognition model inference engine is used to input standardized images from the cloud into the trained cloud-based visual recognition model for inference, and obtain the online classification result for each seed. The statistics and report generation module, located on a cloud server or smartphone terminal, is used to count the total number of grains and the number of various types of imperfect grains based on the online or offline classification results of each grain. It calculates the percentage content of each type of imperfect grain based on the total number of grains and the number of each type of imperfect grain, and generates a test report based on the percentage content of each type of imperfect grain and the preset wheat quality grade judgment standard.
10. The wheat imperfect grain detection system according to claim 9, characterized in that: The smartphone terminal also includes a network adaptive transmission module. When the network level is poor, the network adaptive transmission module compresses the original image based on a preset first compression ratio to obtain the compressed image, and uploads the compressed image to the cloud server using the breakpoint resume method and the block upload method. When the network is in a good network condition, the original image is compressed based on a preset second compression ratio to obtain a compressed image, and the compressed image is directly uploaded to the cloud server; wherein, the first compression ratio is greater than the second compression ratio; The cloud server also includes an expert annotation and training platform interface. The expert annotation and training platform interface is used to receive the corrected annotation results pushed by the expert annotation platform, and to use the corrected annotation results to perform incremental training or fine-tuning of the cloud visual recognition model. After the evaluation is passed, the updated cloud visual recognition model is deployed to the cloud visual recognition model inference engine, and the updated lightweight model is pushed to the offline inference module of the smartphone terminal through OTA technology.
