Quantitative diagnosis method for freshwater fish diseases based on openCV weak supervision and resnet50-adca double branch

CN122551037APending Publication Date: 2026-08-11JIANGSU OCEAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-15
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0005]本发明所要解决的技术问题是针对现有技术的不足,提供一种兼顾标注效率、诊断精度与量化分级能力的基于OpenCV弱监督与ResNet50-ADCA双分支的淡水鱼病害量化诊断方法,能够有效解决现有技术中存在的标注成本高、复杂环境适配性差、量化评价功能缺失以及精度与速度失衡的问题

Benefits of technology

1、低成本:本发明通过OpenCV实现病害图像自动化伪标注,解决传统人工标注痛点;单张标注耗时从人工45秒降至0.08秒,效率提升约570倍,无需专业标注人员,规避标注误差,大幅降低人力与时间成本,提升技术方案的工程可行性与经济性;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122551037A_ABST
    Figure CN122551037A_ABST
Patent Text Reader

Abstract

A quantitative diagnosis method for freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual-branch model is proposed. The method consists of the following steps: (1) Image acquisition and preprocessing: Based on the publicly available freshwater fish disease dataset, a balanced Salmon++ dataset is constructed by combining samples collected from aquaculture sites; (2) Weakly supervised lesion segmentation and labeling: (2.1) HSV color space targeted segmentation; (2.2) Iterative optimization mechanism; (2.3) Disease grading standard; (3) ResNet50-ADCA dual-branch model construction: (3.1) Backbone network and transfer learning; (3.2) SEA channel attention embedding; (3.3) Dual-branch multi-task output layer design; (3.4) Classification branch; (3.5) Grading branch; (3.6) Loss function design; (4) Model training and optimization. This invention balances labeling efficiency, diagnostic accuracy, and quantitative grading capability, and can effectively solve the problems of high labeling cost, poor adaptability to complex environments, lack of quantitative evaluation function, and imbalance between accuracy and speed in the existing technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the interdisciplinary fields of computer vision, deep learning, and smart aquaculture, and in particular to a quantitative diagnostic method for freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branches. Background Technology

[0002] In intensive aquaculture, diseases have become a bottleneck restricting the high-quality development of aquaculture. Data shows that global fish farming suffers annual losses of 15%-20% due to diseases, resulting in economic losses exceeding US$20 billion. This high-frequency fluctuation risk not only threatens the stability of the industry chain but also directly weakens the economic benefits for fish farmers.

[0003] Traditional diagnostic methods rely heavily on human experience, which is not only time-consuming and labor-intensive but also susceptible to subjective differences, leading to frequent misdiagnosis and missed diagnosis. In large-scale, high-density aquaculture settings, this inefficient and unstable diagnostic model cannot meet the immediate needs of precise prevention and control, and cannot support the development of modern facility-based fisheries.

[0004] Existing intelligent fish disease detection models face multiple technical shortcomings in practical applications: First, the models are highly dependent on manually supervised annotation data, but professional pathological annotation is extremely expensive (approximately 45.6 seconds per image), resulting in a scarcity of high-quality samples and poor model generalization; second, most models can only perform simple classifications and lack the ability to quantify and grade the extent and severity of lesion infection; finally, due to interference from complex underwater environments such as uneven lighting and turbid water, the recognition accuracy and scene adaptability of existing models are severely insufficient, failing to meet the requirements of precision management in facility-based fisheries. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a quantitative diagnosis method for freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch, which takes into account the shortcomings of the existing technology, balances annotation efficiency, diagnostic accuracy and quantitative grading capability. It can effectively solve the problems of high annotation cost, poor adaptability to complex environment, lack of quantitative evaluation function and imbalance between accuracy and speed in the existing technology.

[0006] The technical problem to be solved by this invention is achieved through the following technical solution. This invention is a quantitative diagnosis method for freshwater fish diseases based on OpenCV weak supervision and a ResNet50-ADCA dual-branch approach. The steps of this method are as follows: (1) Image acquisition and preprocessing Based on publicly available freshwater fish disease datasets, and expanded by combining samples collected from aquaculture sites, a balanced Salmon++ dataset was constructed. (2) Weakly supervised lesion segmentation and labeling (2.1) HSV color space targeted segmentation Based on the differences in pathological phenotypes of different types of freshwater fish diseases, and combined with the OpenCV open-source library, the diseases are divided into three categories according to their visual characteristics: red lesions, white lesions, and weak color difference / gill lesions. Differentiated targeted segmentation rules are formulated using the HSV color space. (2.2) Iterative optimization mechanism A closed-loop optimization system of "model prediction - manual review - data update - model fine-tuning" was constructed. Unlabeled images were predicted by the ResNet50-ADCA model, and high-risk samples with confidence scores <0.9 were screened. Labeling errors were corrected after review. The corrected samples were added to the CSV dataset, and the top-level parameters of the model were fine-tuned until the pseudo-labeling pass rate was ≥95% and the model performance was stable. (2.3) Disease classification standards The severity of the disease is divided into 6 levels: Grade 0 corresponds to healthy individuals without lesions and serves as a negative control for model training; Grades 1 to 5 are divided according to the increasing percentage of lesions, specifically: <5% is Grade 1, mild infection; 5%-25% is Grade 2, mild infection; 25%-50% is Grade 3, moderate infection; 50%-75% is Grade 4, severe infection; >75% is Grade 5, extremely severe infection. The proportion of lesions is automatically calculated using the OpenCV algorithm, which is the ratio of the number of pixels in the lesion area to the total number of pixels in the fish body, with the calculation precision retained to three decimal places. (3) Construction of ResNet50-ADCA dual-branch model (3.1) Backbone Networks and Transfer Learning ResNet50 was selected as the backbone network of the model. This network adopts a residual connection structure. At the same time, the model adopts a transfer learning strategy, loads pre-trained weights from the ImageNet ultra-large-scale dataset, fully reuses general visual features, freezes the bottom 4 convolutional modules during the training phase, and only fine-tunes the parameters of the top convolutional layer and attention module. (3.2) SEA channel attention embedding A lightweight SEA channel attention module is embedded at the top-level convolutional feature output of ResNet50 to accurately focus on small lesions and weak texture lesions. Its core process consists of three steps: squeezing, activation, and feature recalibration. By aggregating features, removing redundancy, learning channel weights, and enhancing lesion features, the accuracy of the model's disease classification and severity grading is improved. (3.3) Design of dual-branch multi-task output layer The core architecture of "shared backbone network and dual-branch independent output" is adopted to achieve collaborative learning of two tasks: freshwater fish disease type identification and severity classification. (3.4) Classification branches: To address the identification needs of nine types of freshwater fish diseases and healthy samples, a global average pooling layer, a fully connected layer, a Dropout anti-overfitting layer, and a Softmax activation layer were constructed sequentially. The fully connected layer adopted a 1024→10 neuron structure, and the probability of the Dropout layer was set to 0.5, which can accurately output the disease category while effectively suppressing model overfitting and ensuring classification accuracy. (3.5) Hierarchical branching: To meet the needs of disease severity grading from 0 to 5, a network structure parallel to the classification branch is adopted, and the lesion proportion auxiliary feature calculated by the OpenCV algorithm in step (2) is incorporated to strengthen the feature support for grading and quantification. The fully connected layer of this branch has 6 neurons, which correspond to 6 disease severity levels respectively, and are used to accurately output the degree of disease infection, providing a reliable basis for farmers to formulate targeted prevention and control measures. (3.6) Loss function design: A weighted cross-entropy loss function is used as the training weight to balance the two tasks of disease classification and severity grading. The specific calculation formula is as follows: ; In this model, the weight coefficients for both classification and grading tasks are set to 0.5; L is the total loss function value of the model; L cls The cross-entropy loss is the loss of the disease classification branch, used to measure the accuracy of the model in identifying disease categories; L sev The cross-entropy loss of the disease grading branch is used to measure the accuracy of the model in grading the severity of the disease. (4) Model training and optimization A high-performance data processing pipeline for tf.data was built based on the TensorFlow 2.10 framework. It accurately adapts to the image features of freshwater fish diseases and realizes parallel reading and efficient calling of structured CSV pseudo-labeled data. The batch size was set to 16 in the experiment to balance the stability of model training and the efficient use of computing power. The transfer learning strategy was adopted, loading the pre-trained weights of the ImageNet public dataset, freezing the bottom 4 convolutional modules of ResNet, and only fine-tuning the top parameters. After the model is trained, INT8 quantization is used to optimize the model, reducing the number of model parameters and inference time. During the inference stage, the disease type, severity and corresponding confidence level are output simultaneously. When the confidence level is ≥0.9, the detection result is output directly, and when it is <0.9, manual review is prompted. Batch inference and real-time diagnosis are supported.

[0007] The technical problem to be solved by the present invention can also be further realized through the following technical solutions. For the freshwater fish disease quantitative diagnosis method based on OpenCV weak supervision and ResNet50-ADCA dual branch as described above, in step (1), the Salmon++ balanced dataset includes 3150 high-resolution images, covering 9 types of disease / health samples, 350 images for each type, and the collection covers different lighting, water quality and shooting angles.

[0008] The technical problem to be solved by the present invention can also be further achieved through the following technical solutions. For the freshwater fish disease quantitative diagnosis method based on OpenCV weak supervision and ResNet50-ADCA dual branch described above, in step (1), the dataset images are standardized and preprocessed: a. Size is normalized to 256×256 pixels to balance feature preservation and computational efficiency; b. Use 5×5 Gaussian filtering for noise reduction to improve image clarity; c. Data augmentation is performed by horizontal flipping and ±15° rotation to alleviate overfitting; d. Divide the data into training, validation, and test sets in a 7:1.5:1.5 ratio to ensure balanced distribution, and use them for model training, parameter fine-tuning, and performance evaluation, respectively.

[0009] The technical problem to be solved by the present invention can also be further achieved through the following technical solutions. For the quantitative diagnosis method of freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch described above, in step (2.1), red lesions, i.e. hemorrhage / congestion, are extracted using the dual-interval thresholds [0,100,100]—[10,255,255] and [170,100,100]—[180,255,255]; white lesions, i.e. water mold / white tail, are extracted using the thresholds [0,0,200]—[180,30,255]; weak color difference / gill lesions are subject to spatial prior constraints. After delineating the gill region, narrow-band threshold filtering of [0,50,150]—[10,100,255] is used to avoid missegmentation. A 5×5 standard convolution kernel is used to address the issues of burrs, holes, and artifacts at the edges of lesions after HSV segmentation. Closing and opening operations are performed sequentially. Closing operations fill small holes in the lesions, while opening operations remove redundant artifacts at the edges, resulting in regular lesion contours and clear boundaries, providing high-quality feature support for subsequent pseudo-annotation and model training.

[0010] The technical problem to be solved by this invention can also be further achieved through the following technical solution. For the freshwater fish disease quantitative diagnosis method based on OpenCV weak supervision and ResNet50-ADCA dual branch described above, the specific detection process of this method is as follows: (1) Detection preparation: After completing the training and quantization optimization of the ResNet50-ADCA dual-branch model, it is deployed to the edge device at the breeding site to build a complete detection environment; (2) Image acquisition: High-definition industrial cameras are used to acquire images of fish in the aquaculture site. The acquisition is combined with timed acquisition and manual trigger acquisition modes to cover all aquaculture areas and different time periods. The acquired images are transmitted to the edge terminal in JPG format, and auxiliary information such as acquisition time, aquaculture area and water quality are recorded synchronously. (3) Image preprocessing: The edge terminal calls the preprocessing module to normalize the size of the acquired image, perform Gaussian filtering to remove noise, remove water bodies and shooting interference, and ensure that the image quality meets the model input requirements; images with blurriness or severe distortion are marked as invalid and prompted to be reacquired; (4) Lesion segmentation and feature extraction: HSV targeted segmentation and morphological optimization algorithms are called to segment lesions in the preprocessed image, accurately extract red, white and weak color difference lesion features, remove redundant background information, and automatically calculate the proportion of lesions as a graded auxiliary feature. (5) Model inference and result output: Call the deployed ResNet50-ADCA dual-branch model, input the preprocessed image features and lesion proportion auxiliary information, identify the disease type through the classification branch, output the severity through the grading branch, output the confidence level synchronously, display the inference results in real time, and generate a detection report containing the collected information, disease information, and grading results, which can be viewed, exported and printed. (6) Results feedback and model optimization: Detection results with confidence level ≥ 0.9 are directly used for prevention and control decisions; samples with confidence level < 0.9 are reviewed and corrected by professionals, and the corrected samples are added to the pseudo-labeled dataset to fine-tune the model. Detection data are summarized regularly to analyze the occurrence pattern of diseases and form a closed-loop management of "detection-feedback-optimization" to continuously improve the accuracy of the model.

[0011] The technical problem to be solved by the present invention can also be further realized through the following technical solutions. For the above-mentioned freshwater fish disease quantitative diagnosis method based on OpenCV weak supervision and ResNet50-ADCA dual branch, in step (1), the hardware is equipped with a high-definition industrial camera, an image acquisition bracket and an edge computing terminal; the software is equipped with image acquisition, preprocessing, lesion segmentation, model inference and result display modules, and the camera angle, focal length and illumination parameters are adjusted to ensure that the image is clear and distortion-free.

[0012] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. Low cost: This invention achieves automated pseudo-annotation of disease images through OpenCV, solving the pain points of traditional manual annotation; the annotation time per image is reduced from 45 seconds to 0.08 seconds, improving efficiency by about 570 times, eliminating the need for professional annotators, avoiding annotation errors, significantly reducing labor and time costs, and improving the engineering feasibility and economy of the technical solution; 2. Significant performance advantages: The overall recognition accuracy of the ResNet50-ADCA dual-branch model reaches 93.87%, which is 8.47 percentage points higher than the traditional ResNet50 benchmark model, effectively solving the problem of diagnostic bias in complex underwater scenarios; the secondary weighted Kappa coefficient for disease grading reaches 0.97, which is close to the level of professional human diagnosis, enabling accurate grading and reducing the risk of missed diagnosis and misdiagnosis. 3. Optimization of weakly supervised annotation quality: This invention adopts an optimization mechanism of "confidence screening + manual review" to achieve a pseudo-annotation segmentation accuracy of 98.2%, providing reliable support for model training. Compared with unoptimized pseudo-annotations, the model diagnostic accuracy is improved by an additional 1.70 percentage points, consolidating the technical advantages in small sample and weakly supervised scenarios. 4. High practicality: After quantization optimization, the number of parameters of the model is controlled at 24.4M, and the inference time of a single image is 48.3ms, which meets the needs of real-time diagnosis on site; it can be directly deployed on edge terminals without the need for high-performance computing support, which solves the contradiction between accuracy and lightweight in traditional models, and balances accuracy and practicality. 5. Enhanced Functionality: This invention constructs a dual-task collaborative architecture of "classification + grading," simultaneously realizing disease type identification and severity grading, filling a gap in the industry; improving feature utilization, achieving full-dimensional disease diagnosis, providing support for the formulation of prevention and control measures, and promoting the upgrading of aquaculture towards intelligence and precision. Attached Figure Description

[0013] Figure 1 This is an example diagram of a freshwater fish disease sample from the present invention; Figure 2 This is a flowchart of the fish disease lesion segmentation and grading labeling process of the present invention; Figure 3 This is a model diagram of the freshwater fish disease diagnosis system of the present invention; Figure 4 This is a comparison of the confusion matrices of different models of the present invention under the disease classification (9 categories) task; Figure 5 This is a comparison chart of the confusion matrices of different models of the present invention under a graded (5-level) task; Figure 6 This is an example diagram illustrating the segmentation and grading of fish disease lesions according to the present invention. Detailed Implementation

[0014] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0015] Reference Figure 1-6 A quantitative diagnosis method for freshwater fish diseases based on OpenCV weak supervision and a dual-branch ResNet50-ADCA model is proposed, with the core being the "ResNet50-ADCA model". The specific steps are as follows: 1. Image acquisition and preprocessing Based on publicly available freshwater fish disease datasets and expanded with samples collected from aquaculture sites, a balanced Salmon++ dataset was constructed to address the issues of insufficient samples, limited scene representation, and class imbalance in existing datasets. This dataset contains 3150 high-resolution images (≥1024×768 pixels), covering 9 categories of disease / health samples (including bacterial, fungal, and viral diseases, as well as healthy fish), with 350 images per category. The data collection covered various lighting conditions, water quality, and shooting angles, providing representative data for model training and improving generalization ability.

[0016] To eliminate interference and ensure model input normalization, the dataset images undergo standardization preprocessing: (1) The size is normalized to 256×256 pixels to balance feature preservation and computational efficiency; (2) Use 5×5 Gaussian filtering to reduce noise and improve image clarity. (3) Data augmentation was performed by horizontal flipping and ±15° rotation to alleviate overfitting; (4) Divide the data into training set, validation set and test set in a 7:1.5:1.5 ratio to ensure balanced distribution, and use them for model training, parameter fine-tuning and performance evaluation respectively.

[0017] 2. Lesion segmentation and labeling under weak supervision (1) HSV color space targeted segmentation: To address the differences in pathological phenotypes of different types of freshwater fish diseases, and in conjunction with the OpenCV open-source library, the diseases are divided into three categories based on their visual characteristics. Differentiated targeted segmentation rules are formulated using the HSV color space (which is superior to the RGB space, resists light interference, and has high segmentation accuracy).

[0018] Red lesions (hemorrhagic / congestive types) were extracted using a dual-interval threshold extraction method with ranges of [0,100,100]—[10,255,255] and [170,100,100]—[180,255,255]. White lesions (water mold / white tail type) were extracted using a threshold extraction method with ranges of [0,0,200]—[180,30,255]. For lesions with weak color difference / gill area, spatial prior constraints were introduced, and after delineating the gill area, a narrow-band threshold filtering method with ranges of [0,50,150]—[10,100,255] was used to avoid missegmentation.

[0019] To address the issues of burrs, holes, and artifacts at the edges of lesions after HSV segmentation, a 5×5 standard convolutional kernel is used, followed by sequential closing and opening operations. The closing operation fills in small holes in the lesions, while the opening operation removes redundant artifacts at the edges, resulting in regular lesion contours and clear boundaries, providing high-quality feature support for subsequent pseudo-annotation and model training.

[0020] (2) Iterative optimization mechanism: A closed-loop optimization system was constructed, consisting of "model prediction - manual review - data update - model fine-tuning". Unlabeled images were predicted by the ResNet50-ADCA model, and high-risk samples with a confidence level <0.9 were screened and corrected by professionals. The corrected samples were then added to the CSV dataset, and the top-level parameters of the model were fine-tuned until the pseudo-labeling pass rate was ≥95% and the model performance was stable.

[0021] (3) Disease grading standards: To standardize and quantify the severity of fish diseases and provide a unified grading basis for pseudo-labeling, the severity of diseases is divided into six levels based on clinical diagnostic practices and on-site aquaculture operations. Level 0 corresponds to healthy individuals without lesions and serves as a negative control for model training. Levels 1 to 5 are divided according to the increasing percentage of lesions: <5% is Level 1 (mild infection), 5%-25% is Level 2 (mild infection), 25%-50% is Level 3 (moderate infection), 50%-75% is Level 4 (severe infection), and >75% is Level 5 (extremely severe infection). The percentage of lesions is automatically calculated using the OpenCV algorithm, which is the ratio of the number of pixels in the lesion area to the total number of pixels in the fish body. The calculation accuracy is retained to three decimal places to ensure accurate and consistent grading.

[0022] 3. Construction of ResNet50-ADCA dual-branch model (1) Backbone network and transfer learning: To address the core issues of low image contrast and concealed lesion features in freshwater aquaculture scenarios, ResNet50 was selected as the backbone network of the model. This network, through its residual connection structure, effectively alleviates the gradient vanishing problem during deep network training and is suitable for learning from small sample sizes of diseased samples. Simultaneously, its parameter count is moderate, meeting the lightweight deployment requirements of edge devices in aquaculture. The model employs a transfer learning strategy, loading pre-trained weights from the massive ImageNet dataset to fully reuse general visual features. During training, the bottom four convolutional layers are frozen, and only the parameters of the top convolutional layers and attention modules are fine-tuned. This approach ensures the model's generalization performance while significantly shortening the training cycle and reducing computational consumption.

[0023] (2) SEA channel attention embedding: To address the issue of lesion feature obscuring caused by uneven lighting and turbid water in underwater aquaculture scenarios, a lightweight SEA channel attention module is embedded in the top-level convolutional feature output of ResNet50, replacing the traditional SE module. This module optimizes the channel weight allocation logic, with a parameter increase of less than 1%, enabling precise focusing on minute and weakly textured lesions. Its core process consists of three steps: squeezing, activation, and feature recalibration. By aggregating features, removing redundancy, learning channel weights, and enhancing lesion features, it significantly improves the accuracy of disease classification and severity grading of the model.

[0024] (3) Dual-branch multi-task output layer design: Employing a core architecture of "shared backbone network and independent output of two branches," this system enables collaborative learning for two tasks: freshwater fish disease type identification and severity classification. The two branches share deep features extracted by the ResNet50-ADCA backbone network, effectively avoiding feature redundancy and computational waste caused by separate training for multiple tasks. This addresses the industry shortcoming of existing models having limited functionality, achieving synergistic empowerment of both tasks and a two-way improvement in accuracy.

[0025] (4) Classification branches: To address the identification needs of nine types of freshwater fish diseases and healthy samples, a global average pooling layer, a fully connected layer, a Dropout anti-overfitting layer, and a Softmax activation layer were constructed sequentially. The fully connected layer adopted a 1024→10 neuron structure, and the Dropout layer probability was set to 0.5, which accurately outputs the disease category while effectively suppressing model overfitting and ensuring classification accuracy.

[0026] (5) Hierarchical branching: To address the need for disease severity grading from 0 to 5, a network structure parallel to the classification branch is adopted, incorporating auxiliary features of lesion proportion calculated by the OpenCV algorithm in step 2 to strengthen the feature support for grading quantification. This branch's fully connected layer has 6 neurons, corresponding to the 6 disease severity levels, which can accurately output the degree of disease infection, providing a reliable basis for farmers to formulate targeted prevention and control measures.

[0027] (6) Loss function design: To balance the training weights of disease classification and severity grading, and to avoid a single task dominating the model training process, a weighted cross-entropy loss function is used. The specific calculation formula is as follows: In this model, the weight coefficients for both classification and grading tasks are set to 0.5; L is the total loss function value of the model; L cls The cross-entropy loss is the loss of the disease classification branch, used to measure the accuracy of the model in identifying disease categories; L sev The cross-entropy loss of the disease grading branch is used to measure the accuracy of the model in grading the severity of the disease; to ensure that the two tasks converge in a coordinated manner, to ensure that the model achieves a balanced improvement in classification accuracy and grading accuracy, and to optimize the overall diagnostic performance of the model.

[0028] 4. Model Training and Optimization A high-performance data processing pipeline for tf.data was built based on the TensorFlow 2.10 framework, accurately adapting to the image features of freshwater fish diseases. It enables parallel reading and efficient retrieval of structured CSV pseudo-annotated data, significantly improving CPU and GPU resource utilization and avoiding computational waste. The experiment used a batch size of 16 to balance model training stability and efficient computational utilization. A transfer learning strategy was employed, loading pre-trained weights from the ImageNet public dataset, freezing the bottom four convolutional layers of ResNet, and fine-tuning only the top-level parameters. This significantly shortened the training cycle and reduced computational consumption while ensuring model generalization performance.

[0029] After model training, INT8 quantization optimization is employed to effectively reduce the number of model parameters and inference time, adapting to the edge deployment requirements of aquaculture sites. During the inference phase, the disease type, severity, and corresponding confidence level can be output simultaneously. When the confidence level is ≥0.9, the detection result is output directly; when it is <0.9, manual review is prompted to ensure diagnostic accuracy. Batch inference and real-time diagnosis are also supported, meeting the rapid detection needs in intensive aquaculture scenarios and improving disease control efficiency.

[0030] 5. Testing Process (1) Detection preparation: After completing the training and quantization optimization of the ResNet50-ADCA dual-branch model, it was deployed to the edge device at the breeding site to build a complete detection environment. The hardware was equipped with a high-definition industrial camera (≥1024×768 resolution), an image acquisition bracket and an edge computing terminal; the software was installed with modules for image acquisition, preprocessing, lesion segmentation, model inference and result display, etc. The camera angle, focal length and lighting parameters were adjusted to ensure that the images were clear and distortion-free, laying the foundation for the detection work.

[0031] (2) Image acquisition: High-definition industrial cameras are used to acquire images of fish at the aquaculture site. The acquisition is combined with timed acquisition (once every 10 minutes) and manual trigger acquisition modes to cover all aquaculture areas and different time periods to avoid missed detections. The acquired images are transmitted to the edge terminal in JPG format, and auxiliary information such as acquisition time, aquaculture area, and water quality are recorded simultaneously to facilitate subsequent traceability and analysis.

[0032] (3) Image preprocessing: The edge terminal calls the preprocessing module and performs size normalization (256×256 pixels), Gaussian filtering and noise reduction on the acquired image according to the standardized process in step 1, and removes interference such as water bodies and shooting to ensure that the image quality meets the model input requirements; images that are blurry or severely distorted are marked as invalid and prompted to be re-acquired.

[0033] (4) Lesion segmentation and feature extraction: The HSV targeted segmentation and morphological optimization algorithm in step 2 is called to segment the lesions in the preprocessed image, accurately extract the features of red, white and weak color difference lesions, remove redundant background information, and automatically calculate the proportion of lesions as a graded auxiliary feature.

[0034] (5) Model Inference and Result Output: The deployed ResNet50-ADCA dual-branch model is invoked, and the preprocessed image features and lesion proportion auxiliary information are input. The disease type is identified through the classification branch, and the severity is output through the grading branch, with confidence scores output simultaneously. The inference results are displayed in real time, generating a detection report containing the collected information, disease information, and grading results, which can be viewed, exported, and printed.

[0035] (6) Results feedback and model optimization: Detection results with a confidence level ≥ 0.9 are directly used for prevention and control decisions; samples with a confidence level < 0.9 are reviewed and corrected by professionals, and the corrected samples are added to the pseudo-labeled dataset to fine-tune the model. Detection data are regularly summarized to analyze the disease occurrence patterns, forming a closed-loop management of "detection-feedback-optimization" to continuously improve model accuracy.

[0036] To verify the superiority of the present invention, four mainstream models (EfficientNet-B0, ResNet50-CBAM, etc.) were selected for comparative experiments. The participating models covered multiple types of networks to ensure representativeness. The dataset, training parameters and evaluation metrics were unified to ensure the fairness of the experiment. For detailed performance comparison, please refer to Table 1.

[0037] Table 1 Performance Comparison of Different Models EfficientNet-B0 78.11 79.3 0.87 82.17 38.6 5.3 ResGANet 85.02 86.2 0.88 83.77 43.7 19.8 ResNet50-CBAM 89.87 89.7 0.92 90.27 45.1 24.1 ResNet50-ADCA 93.87 94.8 0.97 94.05 48.3 24.4 Note: 1) Acc and F1 are the accuracy rate of identification of 9 types of diseases and the macro average F1 score; 2) QWK is the consistency index of severity grading from 0 to 5. Experiments show that the ResNet50-ADCA dual-branch model of this invention has the best overall performance and significant core advantages: (1) Compared with ResNet50-CBAM, the classification accuracy is improved by 4.0 percentage points, the weighted Kappa coefficient reaches 0.97, the F1 score is 94.8%, and the SEA module can accurately focus on lesions and reduce the risk of missed diagnosis; (2) Compared with ResGANet, the classification and grading accuracy improved by 8.85 and 10.28 percentage points respectively, and the inference time was 48.3ms (≤50ms), which is suitable for on-site requirements; EfficientNet-B0 had the fastest inference (38.6ms), but the classification accuracy was only 78.11%, which could not meet the requirements for accurate diagnosis.

[0038] In summary, the model of this invention achieves a balance between diagnostic accuracy and engineering practicality, and its advantages stem from the synergistic effect of three key technologies: (1) Weakly supervised automated labeling and optimization method: Differentiated HSV segmentation rules and 0-5 grade standards are established based on fish disease characteristics. High-quality training samples are generated through confidence screening and manual review.

[0039] (2) ResNet50-ADCA dual-branch model architecture: ResNet50 is used as the backbone, and the SEA module is embedded. The dual-branch parallel structure is adopted, and the classification and hierarchical tasks are converged in a coordinated manner through weighted cross-entropy.

[0040] (3) Integrated diagnostic method: Based on weakly supervised sample training, it realizes the identification of 9 types of diseases and the quantification of severity levels 0-5 under a single image input, thereby improving diagnostic efficiency, such as Figure 4 , 5 As shown.

Claims

1. A quantitative diagnostic method for freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual-branch architecture, characterized in that: The steps of this method are as follows: (1) Image acquisition and preprocessing Based on publicly available freshwater fish disease datasets, and expanded by combining samples collected from aquaculture sites, a balanced Salmon++ dataset was constructed. (2) Weakly supervised lesion segmentation and labeling (2.1) HSV color space targeted segmentation Based on the differences in pathological phenotypes of different types of freshwater fish diseases, and combined with the OpenCV open-source library, the diseases are divided into three categories according to their visual characteristics: red lesions, white lesions, and weak color difference / gill lesions. Differentiated targeted segmentation rules are formulated using the HSV color space. (2.2) Iterative optimization mechanism A closed-loop optimization system of "model prediction - manual review - data update - model fine-tuning" was constructed. Unlabeled images were predicted by the ResNet50-ADCA model, high-risk samples with confidence <0.9 were screened, and labeling errors were corrected after review. The corrected samples were added to the CSV dataset, and the top-level parameters of the model were fine-tuned until the pseudo-labeling pass rate was ≥95% and the model performance was stable. (2.3) Disease classification standards The severity of the disease is divided into 6 levels: Grade 0 corresponds to healthy individuals without lesions and serves as a negative control for model training; Grades 1 to 5 are divided according to the increasing percentage of lesions, specifically: <5% is Grade 1, mild infection; 5%-25% is Grade 2, mild infection; 25%-50% is Grade 3, moderate infection; 50%-75% is Grade 4, severe infection; >75% is Grade 5, extremely severe infection. The proportion of lesions is automatically calculated using the OpenCV algorithm, which is the ratio of the number of pixels in the lesion area to the total number of pixels in the fish body, with the calculation precision retained to three decimal places. (3) Construction of ResNet50-ADCA dual-branch model (3.1) Backbone Networks and Transfer Learning ResNet50 was selected as the backbone network of the model. This network adopts a residual connection structure. At the same time, the model adopts a transfer learning strategy, loads pre-trained weights from the ImageNet ultra-large-scale dataset, fully reuses general visual features, freezes the bottom 4 convolutional modules during the training phase, and only fine-tunes the parameters of the top convolutional layer and attention module. (3.2) SEA channel attention embedding A lightweight SEA channel attention module is embedded at the top-level convolutional feature output of ResNet50 to accurately focus on small lesions and weak texture lesions. Its core process consists of three steps: squeezing, activation, and feature recalibration. By aggregating features, removing redundancy, learning channel weights, and enhancing lesion features, the accuracy of the model's disease classification and severity grading is improved. (3.3) Design of dual-branch multi-task output layer The core architecture of "shared backbone network and dual-branch independent output" is adopted to realize the collaborative learning of two tasks: freshwater fish disease type identification and severity classification. (3.4) Classification branches: To address the identification needs of nine types of freshwater fish diseases and healthy samples, a global average pooling layer, a fully connected layer, a Dropout anti-overfitting layer, and a Softmax activation layer were constructed sequentially. The fully connected layer adopted a 1024→10 neuron structure, and the probability of the Dropout layer was set to 0.

5. This accurately outputs the disease category while effectively suppressing model overfitting and ensuring classification accuracy. (3.5) Hierarchical branching: To meet the needs of disease severity grading from 0 to 5, a network structure parallel to the classification branch is adopted, and the lesion proportion auxiliary feature calculated by the OpenCV algorithm in step (2) is incorporated to strengthen the feature support for grading and quantification. The fully connected layer of this branch has 6 neurons, which correspond to 6 disease severity levels respectively, and are used to accurately output the degree of disease infection, providing a reliable basis for farmers to formulate targeted prevention and control measures. (3.6) Loss function design: A weighted cross-entropy loss function is used as the training weight to balance the two tasks of disease classification and severity grading. The specific calculation formula is as follows: ; In this model, the weight coefficients for both classification and grading tasks are set to 0.5; L is the total loss function value of the model; L cls The cross-entropy loss is the loss of the disease classification branch, used to measure the accuracy of the model in identifying disease categories; L sev The cross-entropy loss of the disease grading branch is used to measure the accuracy of the model in grading the severity of the disease. (4) Model training and optimization A high-performance data processing pipeline for tf.data was built based on the TensorFlow 2.10 framework. It accurately adapts to the image features of freshwater fish diseases and realizes parallel reading and efficient calling of structured CSV pseudo-labeled data. The batch size was set to 16 in the experiment to balance the stability of model training and the efficient use of computing power. The transfer learning strategy was adopted, loading the pre-trained weights of the ImageNet public dataset, freezing the bottom 4 convolutional modules of ResNet, and only fine-tuning the top parameters. After the model is trained, INT8 quantization is used to optimize the model, reducing the number of model parameters and inference time. During the inference stage, the disease type, severity and corresponding confidence level are output simultaneously. When the confidence level is ≥0.9, the detection result is output directly, and when it is <0.9, manual review is prompted. Batch inference and real-time diagnosis are supported.

2. The method for quantitative diagnosis of freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch as described in claim 1, characterized in that: In step (1), the Salmon++ balanced dataset includes 3150 high-resolution images covering 9 types of disease / health samples, with 350 images for each type, and the collection covers different lighting, water quality, and shooting angles.

3. The method for quantitative diagnosis of freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch as described in claim 1 or 2, characterized in that: In step (1), the dataset images undergo normalization preprocessing: a. Size is normalized to 256×256 pixels to balance feature preservation and computational efficiency; b. Use 5×5 Gaussian filtering for noise reduction to improve image clarity; c. Data augmentation is performed by horizontal flipping and ±15° rotation to alleviate overfitting; d. Divide the data into training, validation, and test sets in a 7:1.5:1.5 ratio to ensure balanced distribution, and use them for model training, parameter fine-tuning, and performance evaluation, respectively.

4. The method for quantitative diagnosis of freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch as described in claim 1, characterized in that: In step (2.1), red lesions, i.e., hemorrhage / congestion, are extracted using a dual-interval threshold of [0,100,100]—[10,255,255] and [170,100,100]—[180,255,255]; white lesions, i.e., water mold / white tail, are extracted using a threshold of [0,0,200]—[180,30,255]; weak color difference / gill lesions are subject to spatial prior constraints, and after the gill region is defined, a narrow-band threshold of [0,50,150]—[10,100,255] is used for filtering to avoid missegmentation; A 5×5 standard convolution kernel is used to address the issues of burrs, holes, and artifacts at the edges of lesions after HSV segmentation. Closing and opening operations are performed sequentially. Closing operations fill small holes in the lesions, while opening operations remove redundant artifacts at the edges, resulting in regular lesion contours and clear boundaries, providing high-quality feature support for subsequent pseudo-annotation and model training.

5. The method for quantitative diagnosis of freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch as described in claim 1, characterized in that: The specific detection process of this method is as follows: (1) Detection preparation: After completing the training and quantization optimization of the ResNet50-ADCA dual-branch model, it is deployed to the edge device at the breeding site to build a complete detection environment; (2) Image acquisition: High-definition industrial cameras are used to acquire images of fish in the aquaculture site. The acquisition is combined with timed acquisition and manual trigger acquisition modes to cover all aquaculture areas and different time periods. The acquired images are transmitted to the edge terminal in JPG format, and auxiliary information such as acquisition time, aquaculture area and water quality are recorded synchronously. (3) Image preprocessing: The edge terminal calls the preprocessing module to normalize the size of the acquired image, perform Gaussian filtering to remove noise, remove water bodies and shooting interference, and ensure that the image quality meets the model input requirements; images with blurriness or severe distortion are marked as invalid and prompted to be reacquired; (4) Lesion segmentation and feature extraction: HSV targeted segmentation and morphological optimization algorithms are called to segment lesions in the preprocessed image, accurately extract red, white and weak color difference lesion features, remove redundant background information, and automatically calculate the proportion of lesions as a graded auxiliary feature. (5) Model inference and result output: Call the deployed ResNet50-ADCA dual-branch model, input the preprocessed image features and lesion proportion auxiliary information, identify the disease type through the classification branch, output the severity through the grading branch, output the confidence level synchronously, display the inference results in real time, and generate a detection report containing the collected information, disease information, and grading results, which can be viewed, exported and printed. (6) Results feedback and model optimization: Detection results with a confidence level ≥ 0.9 are directly used for prevention and control decisions; Samples with a confidence level <0.9 are reviewed and corrected by professionals. The corrected samples are then added to the pseudo-labeled dataset to fine-tune the model. Detection data is regularly summarized to analyze the occurrence patterns of diseases, forming a closed-loop management of "detection-feedback-optimization" to continuously improve the model's accuracy.

6. The method for quantitative diagnosis of freshwater fish diseases based on OpenCV weak supervision and ResNet50-ADCA dual branch as described in claim 5, characterized in that: In step (1), the hardware is equipped with a high-definition industrial camera, an image acquisition bracket and an edge computing terminal; the software is equipped with image acquisition, preprocessing, lesion segmentation, model inference and result display modules, and the camera angle, focal length and illumination parameters are adjusted to ensure that the image is clear and distortion-free.