Detection and monitoring method for carcass stacking of animals died of illness based on Shiwu chip

By using Cambrian chip-based detection and monitoring methods in the process of harmless animal treatment, combined with the yolov5s network framework and the Cambrian CNStream framework, intelligent detection and monitoring of animal carcasses are realized, solving the problem of low data storage and retrieval efficiency in traditional monitoring methods, and improving monitoring efficiency and storage resource utilization.

CN119851313APending Publication Date: 2025-04-18JIANGSU HONGXIN SYST INTEGRATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411959790.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the process of harmless processing of animal corpses, the monitoring video data storage volume is large and cannot be effectively classified and stored, resulting in untimely abnormal behavior detection, video retrieval takes a long time, and storage resources occupy a lot.

Method used

Using detection and monitoring methods based on Cambrian chips, video streams are obtained through vertex cameras, frames are drawn and pre-trained animal carcasses stacking detection model is input for analysis. This model is based on the yolov5s network framework and is deployed on the Cambrian 220-som chip module. It uses the Cambrian CNStream framework for video stream processing and object detection, and performs customized hybrid precision quantization.

Benefits of technology

Intelligent detection and monitoring of animal carcasses is realized, the use of storage resources is reduced, the rapid discovery of abnormal behaviors and video retrieval efficiency is improved, and the effective monitoring of animal harmless processing is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119851313A_ABST
    Figure CN119851313A_ABST
Patent Text Reader

Abstract

The invention discloses a detection and monitoring method for carcass stacking of animals died of illness based on a Shiwu chip. The method comprises the steps that 1, video streams of a feeding port and a peripheral range are obtained through a vertex camera, and video stream frame extraction is carried out once at intervals; 2, inputting the extracted video frame pictures into a pre-trained animal carcass stacking detection model to detect animal carcass stacking; and step 3, if the animal carcasses are detected in all the video frames extracted within continuous 24 hours, generating a video from the corresponding video frames, uploading the video to the cloud and displaying the video at the front end of the AI, otherwise, returning to the step 2. According to the invention, rapid detection and analysis of animal carcass stacking in the video frame are realized based on the domestic Shiwujian edge calculation accelerator card, so that supervisors can perform efficient retrieval and processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision technology, and in particular relates to a method for detecting and monitoring the stacking of dead animal carcasses based on a Cambrian chip. Background Art

[0002] The harmless disposal of dead animals is related to the healthy development of animal husbandry. The widespread spread of animal diseases is also directly related to the health of humans and animals. If dead animals are not properly handled, they will expand the spread of pathogenic microorganisms and pollute the soil, pastures, surface water sources and air. After being transported to the animal harmless disposal site, due to non-standard harmless disposal operations, animal diseases may be secondary spread.

[0003] At present, there are some irregularities in the process of harmless disposal of animal carcasses, such as untimely disposal of dead animal carcasses and failure to immediately store animal carcasses in cold storage. In view of these irregularities, the traditional monitoring method has a large data storage volume, and the video data cannot be effectively classified and stored. After the massive video images saved by the camera are transmitted to the monitoring center, the on-duty personnel cannot see some abnormal situations in time. There are shortcomings such as untimely discovery of irregular behaviors, long time-consuming retrieval of irregular operation videos, and excessive storage of invalid videos, which leads to high storage resource usage. Summary of the invention

[0004] The problem to be solved by the present invention is to provide a detection and monitoring method for the stacking of dead animal carcasses based on the Cambrian chip in view of the deficiencies of the above-mentioned prior art.

[0005] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:

[0006] A method for detecting and monitoring the stacking of dead animal carcasses based on the Cambrian chip comprises the following steps:

[0007] Step 1: Obtain the video stream of the feeding port and the surrounding area through the vertex camera, and extract frames of the video stream at intervals;

[0008] Step 2: Input the extracted video frame images into the pre-trained animal carcass stacking detection model for inference analysis;

[0009] Among them, the animal carcass stacking detection model is trained based on the yolov5s network framework. The reasoning environment of the yolov5s network model is deployed on the edge computing device Cambrian 220-som chip module. The module processes the video stream based on the Cambrian CNStream framework and realizes target detection. During the deployment and adaptation process of the Cambrian edge computing card, the model is customized and quantized based on the network characteristics and the mixed precision characteristics of the Cambrian edge computing card.

[0010] Step 3: If animal carcasses are detected in all video frames extracted within 24 consecutive hours, the corresponding video frames will generate videos and upload them to the cloud and display them on the front end of the AI ​​platform for relevant supervisory personnel to search and collect evidence. Otherwise, return to step 2.

[0011] In step 2 above, the training, deployment, and inference analysis process of the animal carcass stacking detection model includes:

[0012] (1) Obtain animal carcass stacking training set, test set and validation set through the collection, frame extraction, screening, annotation, format conversion and division of actual scene video data;

[0013] (2) Use the animal carcass stacking training set to train the yolov5s network model, and adjust the model training parameters to achieve model tuning to obtain a trained model;

[0014] (3) The yolov5s network model inference environment is deployed in the Cambrian 220-som chip module of the edge computing device. During the deployment and adaptation process of the Cambrian edge computing card, the model is customized and quantized based on the network characteristics and the mixed precision characteristics of the Cambrian edge computing card;

[0015] (4) Use the test set and validation set to test and validate the deployed model and determine the confidence threshold for target detection;

[0016] (5) Use the Cambrian CNStream framework on the Cambrian 220-som chip module to process the video stream and implement target detection.

[0017] The above (1) specifically includes:

[0018] (1.1) Obtain original videos of different scenes and time periods through screen recording or cloud storage to collect actual scene videos;

[0019] (1.2) Decomposing the obtained original video of the animal carcass stacking into video frames, and screening out image data with different animal carcass stacking shapes, different animal carcass types, different time periods and different lighting conditions;

[0020] (1.3) After acquiring the image data, use the labeling tool LabelImg to label the animal carcass category information and the animal carcass stacking target detection frame, and create an animal carcass target detection image dataset;

[0021] (1.4) The image dataset is converted into the YOLO dataset format through a script, and the dataset is divided into a training set, a test set, and a validation set in a ratio of 7:2:1.

[0022] The above (3) deploys the yolov5s network model inference environment in the edge computing device Cambrian 220-som chip module, including:

[0023] (3.1) Load the trained yolov5s network model in pytorch format and convert the model to onnx format;

[0024] (3.2) Use the Cambrian MagicMind framework for model conversion and customized mixed precision quantization. Considering the network characteristics of yolov5s and the mixed precision characteristics of the Cambrian edge computing card, the animal carcass stacking detection model is customized and quantized, which greatly improves the model reasoning efficiency while ensuring limited performance degradation;

[0025] (3.3) Write the inference code, use MagicMind's API to deploy the quantized model to the Cambrian 220-som chip module, and perform inference analysis.

[0026] In the above (3.2), the input module and output head modules of different scales of the yolov5s network model are not quantized, and the float32 precision is retained; for the middle layer of the yolov5s network model, a custom mixed precision orchestration is built based on MagicMind, and the quantization precision of the network is set by layer.

[0027] In (3.2) above, the quantization technology uses static offline quantization, and the trained floating-point model is used to count the input and constant data ranges of the quantized nodes through the calibration data set. The statistical method of the data range uses Cambrian's self-developed EQNM enhanced quantization noise minimization algorithm;

[0028] In (3.2) above, the entire network is set to a channel-wise quantization method to improve network accuracy. The channel-wise quantization method calculates the corresponding maximum value absmax for each channel of the entire convolution kernel filter, and then determines the scaling factor scale.

[0029] In (3.2) above, the quantization methods include symmetric quantization and asymmetric quantization. When the weights and input ranges of most nodes in the network are not symmetric about the zero point, the asymmetric quantization method is used. The quantization formula is as follows:

[0030]

[0031] The formula for dequantization is as follows: dq =(x q -offset)*scale

[0032] in

[0033] qmin=-2 k-1 , qmax=2 k-1 -1;

[0034] Among them, x, x q and x dq are the value of the input or weight before quantization, the value after quantization, and the value after dequantization respectively;

[0035] fmin and fmax are the lower and upper limits of the numerical range before quantization, qmin and qmax are the lower and upper limits of the numerical range after quantization, k is the number of quantization bits; the round function is used for rounding operations, clip is used for data clipping, scale is the scaling factor before and after quantization, and offset is the asymmetric offset; when offset is 0 and fmax+fmin=0, the above formula indicates symmetric quantization.

[0036] In (3.2) above, the entire customized mixed precision quantization process is:

[0037] First, create a network and select different quantization precisions for different layers based on the characteristics of the Cambrian MagicMind mixed precision framework and yolov5s;

[0038] Then configure the quantization statistical algorithm to obtain a reasonable data distribution, configure the quantization granularity of the channel-by-channel quantization method to improve the accuracy, and configure the asymmetric quantization method to adapt to the data distribution;

[0039] Finally, after calibration by the calibrator, a model with statistical values ​​is generated, and a model with quantitative parameters is obtained through model generation.

[0040] The above (5) video stream processing and target detection based on the Cambrian CNStream framework specifically includes: the Cambrian 220-som chip module implements video stream processing based on the CNStream framework, which configures the upstream and downstream relationships of each module in the pipeline through configuration, and implements the call of the executable file through the json file that configures the parameters of each module. The call and configuration of each module are completed by modifying the corresponding configuration file, including obtaining and decoding the rtsp video stream of the monitoring feeding port, configuring the frame extraction interval of the video stream, and the reasoning based on the animal carcass stacking detection model and the flexible setting of the core parameters.

[0041] The present invention has the following beneficial effects:

[0042] The present invention detects animal carcasses existing at a feeding port and its surroundings and saves corresponding video frames to generate a video. By storing such targeted irregular behavior videos, relevant personnel can quickly retrieve them and the use of storage resources can be reduced.

[0043] The present invention realizes effective monitoring of the behavior of failing to timely process the transported dead animal carcasses within the prescribed time during the harmless processing of the animal carcasses through the intelligent detection model of the animal carcasses stacking.

[0044] Based on network characteristics and the Cambrian edge computing accelerator card, the present invention customizes the mixed precision quantization process of the model, effectively improving the reasoning speed of the model while ensuring the performance of the algorithm.

[0045] The present invention can be deployed on-site through the Cambrian edge computing platform, and has the advantages of convenient and flexible deployment and fast response speed, realizing the rapid processing and analysis of video frames in the animal harmless treatment process.

[0046] The present invention uploads the preserved video of the animal carcasses to the cloud, which can be uniformly displayed by the AI ​​center management platform. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 This is the structure diagram of the Yolov5s network model;

[0048] Figure 2 Deployment example diagram for the animal carcass stacking algorithm;

[0049] Figure 3 Video stream analysis flow chart for animal carcass stacking;

[0050] Figure 4 It is the quantization process of a node in the network;

[0051] Figure 5 This is a schematic diagram of the detection results of animal carcasses piled up at night; DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0053] Although the steps in the present invention are arranged with numbers, they are not used to limit the order of the steps. Unless the order of the steps is clearly stated or the execution of a certain step requires other steps as a basis, the relative order of the steps can be adjusted. It is understood that the term "and / or" used in this article involves and covers any and all possible combinations of one or more of the associated listed items.

[0054] The present invention is a detection and monitoring method for the stacking of dead animal carcasses based on the Cambrian chip. The schematic diagram of the present invention is as follows Figure 2As shown, the present invention combines the currently rapidly developing computer vision technology and uses target detection means to improve the response speed of animal harmless treatment violations, reduce the amount of useless data, and realize active monitoring of animal harmless treatment. The method specifically includes the following steps:

[0055] Step 1: Obtain the video stream of the feeding port and the surrounding area through the vertex camera, and extract frames of the video stream at intervals;

[0056] Step 2: Input the extracted video frame images into the pre-trained animal carcass stacking detection model for inference analysis;

[0057] Among them, the animal carcass stacking detection model is trained based on the yolov5s network framework. The reasoning environment of the yolov5s network model is deployed on the edge computing device Cambrian 220-som chip module. The module processes the video stream based on the Cambrian CNStream framework and realizes target detection. During the deployment and adaptation process of the Cambrian edge computing card, the model is customized and quantized based on the network characteristics and the mixed precision characteristics of the Cambrian edge computing card.

[0058] The training, deployment, and inference analysis process of the animal carcass pile detection model includes:

[0059] (1) Obtaining animal carcass stacking training set, test set and validation set through the collection, frame extraction, screening, labeling, format conversion and division of actual scene video data; specifically including:

[0060] (1.1) Obtain original videos of different scenes and time periods through screen recording or cloud storage to collect actual scene videos;

[0061] (1.2) Decomposing the obtained original video of the animal carcass stacking into video frames, and screening out image data with different animal carcass stacking shapes, different animal carcass types, different time periods and different lighting conditions;

[0062] (1.3) After acquiring the image data, use the labeling tool LabelImg to label the animal carcass category information and the animal carcass stacking target detection frame, and create an animal carcass target detection image dataset;

[0063] (1.4) The image dataset is converted into the YOLO dataset format through a script, and the dataset is divided into a training set, a test set, and a validation set in a ratio of 7:2:1.

[0064] (2) Use the animal carcass stacking training set to train the yolov5s network model, and adjust the model training parameters to achieve model tuning to obtain a trained model;

[0065] (3) The yolov5s network model inference environment is deployed in the Cambrian 220-som chip module of the edge computing device. During the deployment and adaptation process of the Cambrian edge computing card, the model is customized and quantized based on the network characteristics and the mixed precision characteristics of the Cambrian edge computing card;

[0066] The yolov5s network model inference environment is deployed in the edge computing device Cambrian 220-som chip module, including:

[0067] (3.1) Load the trained yolov5s network model in pytorch format and convert the model to onnx format;

[0068] (3.2) Use the Cambrian MagicMind framework for model conversion and customized mixed precision quantization. Considering the network characteristics of yolov5s and the mixed precision characteristics of the Cambrian edge computing card, the animal carcass stacking detection model is customized and quantized, which greatly improves the model reasoning efficiency while ensuring limited performance degradation;

[0069] The construction process of using the Cambrian MagicMind framework for model conversion and customized mixed precision quantization as described in (3.2) is as follows:

[0070] 1) The input module and output head modules of different scales of the yolov5s network model are not quantized, and float32 precision is retained. Figure 1 The input module is the CBS module at the front end of the entire network, including Conv convolution, BN2d batch normalization and SiLU activation modules; the output head includes 3 scale convolution layers, which directly generate category and bounding box regression detection results and are very sensitive to quantization errors.

[0071] 2) For the middle layer of the yolov5s network model, a custom mixed precision orchestration is built based on MagicMind, and the quantization precision of the network is set by layer. The Backbone layer of yolov5s, except for the input layer, is set to int8 precision. The Backbone layer extracts low-level features and is insensitive to quantization errors. The Neck feature fusion layer of yolov5s, including SPPF, FPN, PANet, etc., is responsible for feature fusion, involves multi-scale information transmission, is more sensitive to quantization errors, and is set to int16 precision.

[0072] 3) The quantization technology uses static offline quantization (Post-Training Quantization Static, abbreviated as sPTQ). The trained floating-point model is used to count the input and constant data range of the quantized nodes through the calibration data set. The statistical method of the data range uses Cambrian's self-developed EQNM enhanced minimization quantization noise algorithm, which is more effective than the relative (LINEAR) linear statistical method.

[0073] 4) The entire network is set to channel quantization to improve network accuracy. Normal quantization calculates the maximum value absmax for the entire convolution kernel filter and then determines a scaling factor scale. Channel quantization calculates the corresponding maximum value absmax for each channel of the entire convolution kernel filter and then determines the scaling factor scale, that is, the number of scaling factors scale calculated will be the same as the number of channels in the convolution filter. Channel quantization has finer granularity and higher accuracy.

[0074] 5) Quantization methods mainly include symmetric quantization (s'ymmetric) and asymmetric quantization (a'symmetric). When the weights and input ranges of most nodes in the network are not symmetric about the zero point, the asymmetric quantization method is used.

[0075] The quantified formula is as follows:

[0076] The formula for dequantization is as follows: dq =(x q -offset)*scale

[0077] in

[0078] qmin=-2 k-1 , qmax=2 k-1 -1;

[0079] Among them, x, x q and x dq are the value of the input or weight before quantization, the value after quantization, and the value after dequantization respectively;

[0080] fmin and fmax are the lower and upper limits of the value range before quantization, qmin and qmax are the lower and upper limits of the value range after quantization, k is the number of quantization bits, generally 8 or 16; the round function is used for rounding operations, the clip method is used for data clipping, scale is the scaling factor before and after quantization, and offset is the asymmetric offset. When offset is 0 and fmax+fmin=0, the formula indicates symmetric quantization.

[0081] 6) The entire customized mixed precision quantization process is described below.

[0082] First, create a network and select different quantization precisions for different layers based on the characteristics of the Cambrian MagicMind mixed precision framework and yolov5s;

[0083] Then configure the quantization statistical algorithm to obtain a reasonable data distribution, configure the channel-optimized quantization granularity to improve accuracy, and configure the asymmetric quantization method to adapt to the data distribution;

[0084] Finally, after calibration by the calibrator, a model with statistical values ​​is generated, and a model with quantitative parameters is obtained through model generation.

[0085] (3.3) Write the inference code, use MagicMind's API to deploy the quantized model to the Cambrian 220-som chip module, and perform inference analysis.

[0086] (4) Use the test set and validation set to test and validate the deployed model and determine the confidence threshold for target detection;

[0087] (5) Use the Cambrian CNStream framework on the Cambrian 220-som chip module to process the video stream and implement target detection. Specifically, the Cambrian 220-som chip module implements video stream processing based on the CNStream framework, which configures the upstream and downstream relationships of each module in the pipeline through configuration, and implements the call of the executable file through the json file that configures the parameters of each module. The call and configuration of each module are completed by modifying the corresponding configuration file, including obtaining and decoding the rtsp video stream of the monitoring feed port, configuring the frame extraction interval of the video stream, reasoning based on the animal carcass stacking detection model, and flexible setting of core parameters.

[0088] Step 3: If animal carcasses are detected in all video frames extracted within 24 consecutive hours, the corresponding video frames will generate videos and upload them to the cloud and display them on the front end of the AI ​​platform for relevant supervisory personnel to search and collect evidence. Otherwise, return to step 2.

[0089] In the embodiment, with the rapid iteration of target detection methods in the field of artificial intelligence, single-stage target detection methods based on the YOLO series have been widely used. The present invention preferentially uses the network framework of YOLOv5 as a method for detecting animal carcasses. This method has the characteristics of rich ecology and flexible modification, and is also widely used in the industry. Among them, YOLOv5s is a parameter-reduced version of YOLOv5 and is a specific network model for implementing the invention. Its network structure is as follows Figure 1 shown.

[0090] Specifically, the present invention uses the network model of yolov5s as the basic detection model to detect animal carcass pile targets. In the model training phase, it is necessary to carry out preparation work such as training data collection, data cleaning, data expansion, and data format conversion. The model training tuning work is achieved by adjusting model training parameters such as batch-size and learnin-rate parameters. For the final generated model, a video clip of an actual scene is used to perform model testing. This phase mainly confirms the threshold C of the confidence parameter. T .

[0091] With the advantages of real-time data processing and analysis of edge computing, the present invention deploys the above yolov5 model reasoning environment on the Cambrian 220-som chip module, which has the advantages of low power consumption and strong computing power. At the same time, the chip module is also widely used in edge computing scenarios such as smart power, smart manufacturing, and smart rail transit. Since Cambrian provides CNStream video stream processing SDK, it is used to quickly build deep learning applications based on the Cambrian hardware platform. Based on this SDK as a framework for software deployment, the present invention realizes the construction of video decoding, target detection, and result processing workflows.

[0092] Specifically, the tested model is transplanted to the Cambrian SOM-220 platform. In view of the characteristics of the Cambrian SOM-220 component, the model conversion and model deployment work depends on the Cambrian MLU270 development environment. The transplantation of the animal carcass pile target detection model is achieved by building the model conversion environment and test environment on the MLU270 server. With the help of the Cambrian video stream processing CNStream SDK, the frame extraction detection of animal carcass detection is realized.

[0093] The present invention saves the image of the first detection of animal carcasses and starts timing. After that, it performs frame sampling detection on the video stream at intervals. If the target of animal carcasses being piled up is detected at the feeding port for 24 consecutive hours, the present invention generates a video based on the video frames saved within 24 hours. The video is then uploaded to the cloud through the network for front-end display on the AI ​​middle station, so that relevant supervisors can search and collect evidence.

[0094] Specifically, the image frames where animal carcasses are detected are saved and timing is started. Frame sampling detection is performed at intervals thereafter. When animal carcasses are detected at the feeding port and its surroundings for 24 consecutive hours, a video of the animal carcass stacking is generated and uploaded to the cloud via the http protocol for display by the AI ​​middle station. The specific process is as follows: Figure 3 shown.

[0095] In the early stage of animal carcass stacking model training, the model is trained by collecting data sets. Actual scene videos are collected by recording and acquiring original videos of different scenes at different times in the cloud. The original video of animal carcass stacking recorded at this stage is decomposed into video frames to obtain images with different animal carcass stacking shapes, different times and different lighting conditions. Since the shape changes of animal carcasses in the recorded real-time video are not obvious, the data sample has the characteristic of high repeatability. The above data samples also need to be manually deleted to further select the changes in the shape of animal carcasses, lighting changes and video frames with different animal carcasses (pigs, cattle, ducks and geese).

[0096] After obtaining the corresponding image data of animal carcasses, the animal carcass category ID and the animal carcass pile target detection frame were manually annotated with the labelImg target detection and annotation software to create an animal carcass target detection image dataset. The preparation for model training was completed by converting the annotation format generated by the labelImg tool into the voc dataset format and dividing the dataset into a training set, a test set, and a validation set in a ratio of 7:2:1.

[0097] The yolov5s version of the yolo target detection network is selected as the target network for the present invention to realize the detection of animal carcasses. The network belongs to a single-stage target detection network. It has the advantages of simple network structure, low computing resource occupation and convenient deployment. The training is performed by setting the batch_size to 64, the learning_rate to 0.01, the img-size to 640 and other hyperparameters. The trained model is verified by the real-time animal carcass stacking video collected in the second stage to determine the threshold parameter (C T =0.5), Figure 5 The following figure shows the test results.

[0098] Next, we will start to convert, customize mixed precision quantization, and transplant and deploy the trained animal carcass stacking detection model based on the Cambrian MagicMind framework. Load the trained pytorch model and convert the model to onnx format. Use MagicMind for model conversion and customized mixed precision quantization. Considering the network characteristics of yolov5s and the mixed precision characteristics of the Cambrian edge computing card, the animal carcass stacking detection model is customized and quantized, which greatly improves the model reasoning efficiency while ensuring limited performance degradation. Write the reasoning code, use MagicMind's API to deploy the quantized model to the Cambrian 220-som chip module, and perform reasoning analysis.

[0099] In the present invention, the quantization process of the model is optimized based on the network characteristics and the Cambrian edge card customization. The process is as follows:

[0100] First, based on the mixed precision quantization module supported by the Cambrian MagicMind framework, the quantization strategy of the entire network was improved. Different network layers correspond to different quantization precisions. The input layer and output head are very sensitive to quantization errors. No quantization is performed to maintain float32 precision. The input module is the CBS module at the front end of the entire network, including Conv convolution, BN2d batch normalization and SiLU activation modules; the output head includes 3 scale convolution layers. The Backbone skeleton layer of yolov5s extracts low-level features, is insensitive to quantization errors, and is set to int8 precision. The Neck feature fusion layer of yolov5s is responsible for feature fusion, involving multi-scale information transmission, is more sensitive to quantization errors, and is set to int16 precision. MagicMind provides two ways to set the operator precision, including setting by network granularity and setting by operator granularity. The algorithm granularity has a high priority. The quantization precision setting of the entire network can be achieved by setting the general network granularity plus the operator granularity setting of the specified node.

[0101] When using a quantization calibrator, it is necessary to configure the quantization granularity. The present invention sets the entire network to a channelized quantization mode to improve network accuracy. Normal quantization calculates the maximum value absmax for the entire convolution kernel filter, and then determines a scaling factor scale. Channelized quantization calculates the corresponding maximum value absmax for each channel of the entire convolution kernel filter, and then determines the scaling factor scale, that is, the number of scaling factors scale calculated will be the same as the number of channels of the convolution filter. Channelized quantization has finer granularity and higher accuracy.

[0102] When using the quantization calibrator, you need to configure the quantization statistics algorithm to count the input and constant data range of the quantized nodes through the calibration data set. Here, Cambrian's self-developed EQNM algorithm is used to enhance the minimization of quantization noise, which is better than the linear statistics method (LINEAR).

[0103] Quantization methods mainly include symmetric quantization (s'ymmetric) and asymmetric quantization (a'symmetric). When the weights and input ranges of most nodes in the network are not symmetric about the zero point, the asymmetric quantization method is used.

[0104] The following takes float to int8 quantization as an example to explain the process of generating a quantization model. The quantization model is the process of mapping float values ​​to int values. To map floating-point inputs to fixed-point, you need to first count the numerical range of the input or weight to get the maximum absolute value, recorded as absmax; then map absmax to 127 (the maximum value under int8), and get the mapping scale scale as scale = 127 / absmax. This scale is the scaling scale of the floating-point input mapped to fixed-point. Save the scaling scale of the input and weight of the operator to be quantized in the model parameters, call torch.save to store it as a pth file, and use it to run fixed-point calculations on the MLU later.

[0105] Run the quantization model process. Taking the convolution operator as an example, first quantize the floating-point input or weight of the convolution operator. Use the scale in the quantization model and follow the quantization formula Calculate the integer input and unify the data into the specified range. Then perform the integer convolution operation to output the integer convolution result. According to the dequantization formula x dq =(x q -offset)*scale, and finally get the floating point convolution output. The process of running the quantization model is as follows Figure 4 shown.

[0106] Finally, after calibration by the calibrator, a model with statistical values ​​is generated, and a model with quantitative parameters is obtained through model generation.

[0107] The converted animal carcass stacking model is tested using a video of an actual scene with animal carcasses collected in the second stage, so as to adapt the animal carcass stacking model to the confidence threshold C of the hardware platform of the present invention. T =0.5.

[0108] CNStream is a data stream processing SDK for the Cambrian development platform. Based on the ideas of modularization and pipeline, it provides a set of classes and interfaces to support the pipeline pipeline framework for multi-channel concurrent stream processing. Based on CNStream, the present invention implements the call of executable files by configuring a json file for declaring the upstream and downstream relationships of each module in the pipeline pipeline and the configuration parameters of each module. The model of animal carcasses stacking, the rtsp video stream address of the feed port and the frame extraction interval time T=0.5h of the video stream are monitored, and the model call and parameter setting are completed by modifying the corresponding configuration file. The animal carcasses detected around the feed port are saved and the timing is started. The animal carcasses are detected for 24 consecutive hours, and the 48 saved images are used for video generation. The generated video is uploaded to the cloud through the http protocol for display by the AI ​​middle station front end. It is convenient for the corresponding supervisory units to quickly query and collect evidence of violations that occur during the harmless treatment of animals.

[0109] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

[0110] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.

Claims

1. A method for detecting and monitoring the pile-up of dead animal carcasses based on the Cambrian chip, characterized in that: The following steps are involved: Step 1: Obtain the video stream of the feeding port and the surrounding area through the vertex camera, and extract frames of the video stream at intervals; Step 2: Input the extracted video frame images into the pre-trained animal carcass stacking detection model for inference analysis; Among them, the animal carcass stacking detection model is trained based on the yolov5s network framework. The reasoning environment of the yolov5s network model is deployed on the edge computing device Cambrian 220-som chip module. The module processes the video stream based on the Cambrian CNStream framework and realizes target detection. During the deployment and adaptation process of the Cambrian edge computing card, the model is customized and quantized based on the network characteristics and the mixed precision characteristics of the Cambrian edge computing card. Step 3: If animal carcasses are detected in all video frames extracted within 24 consecutive hours, the corresponding video frames will generate videos and upload them to the cloud and display them on the front end of the AI ​​platform for relevant supervisory personnel to search and collect evidence. Otherwise, return to step 2.

2. The method for detecting and monitoring the stacking of dead animal carcasses based on the Cambrian chip according to claim 1 is characterized in that: In step 2, the training, deployment and reasoning analysis process of the animal carcass stacking detection model includes: (1) Obtain animal carcass stacking training set, test set and validation set through the collection, frame extraction, screening, annotation, format conversion and division of actual scene video data; (2) Use the animal carcass stacking training set to train the yolov5s network model, and adjust the model training parameters to achieve model tuning to obtain a trained model; (3) The yolov5s network model inference environment is deployed in the Cambrian 220-som chip module of the edge computing device. During the deployment and adaptation process of the Cambrian edge computing card, the model is customized and quantized based on the network characteristics and the mixed precision characteristics of the Cambrian edge computing card; (4) Use the test set and validation set to test and validate the deployed model and determine the confidence threshold for target detection; (5) Use the Cambrian CNStream framework on the Cambrian 220-som chip module to process the video stream and implement target detection.

3. The method for detecting and monitoring the stacking of dead animal carcasses based on the Cambrian chip according to claim 2 is characterized in that: The above (1) specifically includes: (1.1) Obtain original videos of different scenes and time periods through screen recording or cloud storage to collect actual scene videos; (1.2) Decomposing the obtained original video of the animal carcass stacking into video frames, and screening out image data with different animal carcass stacking shapes, different animal carcass types, different time periods and different lighting conditions; (1.3) After acquiring the image data, use the labeling tool LabelImg to label the animal carcass category information and the animal carcass stacking target detection frame, and create an animal carcass target detection image dataset; (1.4) The image dataset is converted into the YOLO dataset format through a script, and the dataset is divided into a training set, a test set, and a validation set in a ratio of 7:2:

1.

4. The method for detecting and monitoring the stacking of dead animal carcasses based on the Cambrian chip according to claim 2 is characterized in that: (3) The deployment of the yolov5s network model inference environment in the edge computing device Cambrian 220-som chip module includes: (3.1) Load the trained yolov5s network model in pytorch format and convert the model to onnx format; (3.2) Use the Cambrian MagicMind framework for model conversion and customized mixed precision quantization. Considering the network characteristics of yolov5s and the mixed precision characteristics of the Cambrian edge computing card, the animal carcass stacking detection model is customized and quantized, which greatly improves the model reasoning efficiency while ensuring limited performance degradation; (3.3) Write the inference code, use MagicMind's API to deploy the quantized model to the Cambrian 220-som chip module, and perform inference analysis.

5. The method for detecting and monitoring the stacking of dead animal carcasses based on the Cambrian chip according to claim 4 is characterized in that: In (3.2), the input module and output head modules of different scales of the yolov5s network model are not quantized, and the float32 precision is retained; for the middle layer of the yolov5s network model, a custom mixed precision orchestration is built based on MagicMind, and the quantization precision of the network is set by layer.

6. The method for detecting and monitoring the accumulation of dead animal carcasses based on the Cambrian chip according to claim 4 is characterized in that: In (3.2), the quantization technology uses static offline quantization, and the trained floating-point model is used to count the input and constant data ranges of the quantized nodes through the calibration data set. The statistical method of the data range uses Cambrian's self-developed EQNM enhanced quantization noise minimization algorithm.

7. The method for detecting and monitoring the accumulation of dead animal carcasses based on the Cambrian chip according to claim 4 is characterized in that: In (3.2), the entire network is set to a channel-wise quantization method to improve network accuracy. The channel-wise quantization method calculates the corresponding maximum value absmax for each channel of the entire convolution kernel filter, and then determines the scaling factor scale.

8. The method for detecting and monitoring the accumulation of dead animal carcasses based on the Cambrian chip according to claim 4 is characterized in that: In (3.2), the quantization methods include symmetric quantization and asymmetric quantization. When the weights and input ranges of most nodes in the network are not symmetric about the zero point, the asymmetric quantization method is used. The quantization formula is as follows: The formula for dequantization is as follows: dq =(x q -offset)*scale in qmin=-2 k-1 ,qmax=2 k-1 -1; Among them, x, x q and x dq are the value of the input or weight before quantization, the value after quantization, and the value after dequantization respectively; fmin and fmax are the lower and upper limits of the numerical range before quantization, qmin and qmax are the lower and upper limits of the numerical range after quantization, k is the number of quantization bits; the round function is used for rounding operations, clip is used for data clipping, scale is the scaling factor before and after quantization, and offset is the asymmetric offset; when offset is 0 and fmax+fmin=0, the above formula indicates symmetric quantization.

9. The method for detecting and monitoring the accumulation of dead animal carcasses based on the Cambrian chip according to claim 4, characterized in that: In (3.2), the entire customized mixed precision quantization process is: First, create a network and select different quantization precisions for different layers based on the characteristics of the Cambrian MagicMind mixed precision framework and yolov5s; Then configure the quantization statistical algorithm to obtain a reasonable data distribution, configure the quantization granularity of the channel-by-channel quantization method to improve the accuracy, and configure the asymmetric quantization method to adapt to the data distribution; Finally, after calibration by the calibrator, a model with statistical values ​​is generated, and a model with quantitative parameters is obtained through model generation.

10. The method for detecting and monitoring the accumulation of dead animal carcasses based on the Cambrian chip according to claim 2, characterized in that: The (5) video stream processing and target detection based on the Cambrian CNStream framework specifically includes: the Cambrian 220-som chip module implements video stream processing based on the CNStream framework, which configures the upstream and downstream relationships of each module in the pipeline through configuration, and implements the call of the executable file through the json file that configures the parameters of each module. The call and configuration of each module are completed by modifying the corresponding configuration file, including obtaining and decoding the rtsp video stream of the monitoring feeding port, configuring the frame extraction interval time of the video stream, and the reasoning based on the animal carcass stacking detection model and the flexible setting of the core parameters.