Self-adaptive lightweight dense network mineral classification system and method
By using an adaptive lightweight dense network mineral classification system, combined with an improved DenseNet121 and ECA channel attention module, the problems of large model size, poor real-time performance, and data imbalance in mineral image recognition are solved, enabling real-time, fine-grained automated mineral recognition and visualization results on edge devices.
Patent Information
- Application Number
- CN202511110909.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-08
- Publication Date
- 2025-11-18
AI Technical Summary
Existing mineral image recognition technologies suffer from problems such as large model size, poor real-time performance, insufficient fine-grained discrimination ability, and data imbalance, making it difficult to achieve real-time, fine-grained automated mineral recognition on edge devices.
An adaptive lightweight dense network mineral classification system is adopted, which combines an improved DenseNet121 neural network and an ECA channel attention module with a two-layer MLP classification head. The model is optimized through self-distillation and active learning, and model compression and edge deployment are performed to achieve lightweight and real-time inference.
It enables real-time, fine-grained, automated identification of mineral images on resource-constrained hardware, improves the identification performance of long-tail categories, provides interactive visualization results, and meets the application needs of portable field use and museum collections.
Smart Images

Figure CN120976641A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the interdisciplinary field of computer vision and intelligent mineralogy, specifically to a lightweight DenseNet network that fuses adaptive channel attention with a multilayer perceptron for fast automatic classification of mineral images and its edge deployment method. Background Technology
[0002] Traditionally, mineral identification relies on manual microscopic observation, which is time-consuming and highly subjective. With the development of deep learning, convolutional neural networks (CNNs) have been used for mineral image recognition, but existing methods still have shortcomings in three aspects: model size, real-time performance, and fine-grained discrimination ability.
[0003] Model bloat: Commonly used backbones such as ResNet50 require more than 25M parameters, making them difficult to deploy on edge devices.
[0004] Insufficient fine-grained feature extraction: Different mineral crystal forms and spectral differences are slight, and classic CNNs can easily confuse them (e.g., bornite vs. pyrite, muscovite vs. biotite).
[0005] Imbalanced data: The long tail of sample distribution among mineral classes leads to a decrease in generalization ability.
[0006] This shows that existing technologies still have problems such as a wide variety of minerals with subtle differences in crystal form, limited computing power and memory of terminal hardware, long-tailed training data with many noisy labels, and difficulty in deploying existing large models on the edge. Summary of the Invention
[0007] The purpose of this invention is to provide an adaptive lightweight dense network mineral classification system and method, which enables real-time, fine-grained, and automated identification of multiple mineral images in resource-constrained scenarios such as portable field applications or museum collections, and provides interactive visualization results.
[0008] To achieve the above objectives, the present invention provides an adaptive lightweight dense network mineral classification system, comprising:
[0009] The data acquisition module is used to acquire microscopic images of at least seven types of minerals;
[0010] The preprocessing and enhancement module is used to perform data enhancement on the mineral image, such as size normalization, random rotation, color temperature perturbation, CutMix, and random occlusion.
[0011] The feature extraction module is based on an improved DenseNet121 neural network. The network consists of four dense blocks connected sequentially, and an ECA (Efficient Channel Attention) module is embedded between the first three dense blocks and their respective transition layers, and before the batch normalization (BN) layer of the last dense block.
[0012] The classification module is a multilayer perceptron (MLP) classification head with two hidden layers. Its structure is FC1024→512→ReLU→Dropout→FC 512→128→ReLU→Dropout→FC 128→N, where N is the number of mineral categories.
[0013] The training optimization module is used to perform self-distillation based on exponential moving average (EMA) and active learning based on prediction entropy to improve the performance of long-tail category recognition.
[0014] The model compression module is used to perform 25% channel pruning and perceptual quantization training (QAT) on the improved DenseNet121, quantizing the weights to INT8 and the activations to INT8.
[0015] The edge-cloud deployment module is used for model training and updating on the cloud side, and for real-time inference on the edge side based on EdgeTPU or FPGA, and returns the prediction category, confidence level and time consumption through RESTAPI.
[0016] The visualization and interaction module is used to display batch prediction results, confusion matrix and confidence distribution, and supports model selection and status monitoring.
[0017] Preferably, the one-dimensional convolution kernel size k of the ECA channel attention module is calculated using the formula:
[0018]
[0019] Where C is the number of input channels, γ = 2, b = 1, and k is the nearest odd number.
[0020] Preferably, each hidden layer of the multilayer perceptron classification head uses the ReLU activation function and has a Dropout probability of 0.5.
[0021] Preferably, after each training epoch, the training optimization module uses the EMA version of the current model as the teacher model and performs self-distillation using KL divergence loss at temperature T=4.
[0022] Preferably, the active learning calculates the sample prediction probability distribution entropy H(p), and when H(p) > 1.2 bits, the corresponding sample is added to the manual verification pool, and the verification result is incrementally added to the training set every 10 epochs.
[0023] Preferably, the number of network parameters after pruning does not exceed 7.6M and the number of FLOPs does not exceed 2.9G.
[0024] Preferably, the edge is deployed on an Edge TPU device with 1GB RAM, and the average inference time for a single 512×512 pixel image is no more than 40ms, and the frame rate is no less than 25fps.
[0025] Preferably, the data acquisition module acquires no less than 12,000 images, and divides them into training set, validation set and test set in a ratio of 7:1:2.
[0026] This invention also provides an adaptive lightweight dense network mineral classification method, comprising the following steps:
[0027] S1. Acquire mineral microscopic images and perform size normalization and data augmentation;
[0028] S2. Input the image obtained in step A into the improved DenseNet121, where the network embeds an ECA channel attention module at a predetermined position and outputs a feature map;
[0029] S3. A two-layer hidden layer MLP classification head is used to perform non-linear mapping on the feature map, and the mineral category probability is output.
[0030] S4. During training, self-distillation is performed using the EMA-teacher model, and active learning sample selection is performed based on the prediction entropy threshold.
[0031] S5. Perform 25% channel pruning and perceptual quantization on the trained model to obtain the INT8 quantized model;
[0032] S6. Deploy the model obtained in step E to the Edge TPU or FPGA and display the batch prediction results through a visual interactive interface.
[0033] Preferably, the size of the one-dimensional convolution kernel of the ECA module in step S2 is calculated according to formula (1).
[0034] Preferably, in step S4, the self-distillation loss function includes a cross-entropy term and a weighted KL divergence term, with a weighting coefficient λ = 0.7.
[0035] Preferably, the prediction entropy threshold for active learning is set to 1.2 bits, and manual review and data feedback are performed every 10 training epochs.
[0036] Preferably, in step 5, perceptual quantization is per-channel weight quantization and per-tensor activation quantization, both with a quantization bit width of 8 bits.
[0037] Preferably, in step 6, the inference time of the deployed quantization model on a single 512×512 pixel image on the EdgeTPU is ≤40ms.
[0038] Therefore, the adaptive lightweight dense network mineral classification system and method of the present invention, which adopts the above structure, has the following beneficial effects:
[0039] (1) Bidirectional lightweight enhancement: For the first time, ECA attention and two MLP heads are embedded into DenseNet121, which significantly improves fine-grained recognition accuracy at minimal cost.
[0040] (2) Self-distillation-active learning closed loop: Dynamically expand the labels of difficult examples without additional teacher models, and improve the accuracy of long-tail categories (such as bornite) by more than 6%.
[0041] (3) Pruning-Quantization Co-compression: A sparse-low bit joint strategy was developed for Edge TPU to achieve 25fps real-time inference on 1GB RAM devices.
[0042] (4) End-to-cloud visualization linkage: Provides plug-and-play interactive interface and REST service to facilitate rapid deployment for scientific research, teaching and field applications.
[0043] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0044] Figure 1 : Overall model architecture diagram of the present invention;
[0045] Figure 2 The present invention provides an improved classification layer structure for a three-layer MLP.
[0046] Figure 3 : A schematic diagram of the Dropout regularization result of the present invention; (a) is a schematic diagram of a standard neural network; (b) is a schematic diagram of Dropout processing;
[0047] Figure 4 : Schematic diagram of the dense block connection module of the present invention;
[0048] Figure 5 : Schematic diagram of the ECA attention module of the present invention;
[0049] Figure 6 : A diagram showing the style of the top component of this invention;
[0050] Figure 7 : Code for the top interface design of this invention;
[0051] Figure 8 : Initialization interactive interface style diagram of the present invention;
[0052] Figure 9 : Schematic diagram of the recognition result style of the present invention (1);
[0053] Figure 10 Flowchart of the model selection and loading process of this invention;
[0054] Figure 11 : A schematic diagram of the image loading part of this invention;
[0055] Figure 12 : Schematic diagram of the recognition result style of the present invention (2). Detailed Implementation
[0056] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0057] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0058] The following section details the complete implementation steps of the "Adaptive Lightweight Dense Network Mineral Classification System and Method" of this invention, based on the prototype system development and experimental process. Unless otherwise specified, all software runs in a Python 3.10 environment, the deep learning framework is PyTorch 2.5.1, the hardware resources are an AMD Ryzen 5 7500F CPU and an NVIDIA RTX 4060 Ti GPU (training end), and the inference end is an EdgeTPU development board.
[0059] Example
[0060] like Figure 1 As shown, this invention provides an adaptive lightweight dense network mineral classification system, comprising:
[0061] The data acquisition module is used to acquire microscopic images of at least seven types of minerals;
[0062] The preprocessing and enhancement module is used to perform data enhancement on the mineral image, such as size normalization, random rotation, color temperature perturbation, CutMix, and random occlusion.
[0063] The feature extraction module is based on an improved DenseNet121 neural network. The network consists of four dense blocks connected sequentially, and an ECA (Efficient Channel Attention) module is embedded between the first three dense blocks and their respective transition layers, and before the batch normalization (BN) layer of the last dense block.
[0064] The classification module is a multilayer perceptron (MLP) classification head with two hidden layers. Its structure is FC1024→512→ReLU→Dropout→FC 512→128→ReLU→Dropout→FC128→N, where N is the number of mineral categories.
[0065] The training optimization module is used to perform self-distillation based on exponential moving average (EMA) and active learning based on prediction entropy to improve the performance of long-tail category recognition.
[0066] The model compression module is used to perform 25% channel pruning and perceptual quantization training (QAT) on the improved DenseNet121, quantizing the weights to INT8 and the activations to INT8.
[0067] The edge-cloud deployment module is used for model training and updating on the cloud side, and for real-time inference on the edge side based on EdgeTPU or FPGA, and returns the prediction category, confidence level and time consumption through RESTAPI.
[0068] The visualization and interaction module is used to display batch prediction results, confusion matrix and confidence distribution, and supports model selection and status monitoring.
[0069] Its basic network uses DenseNet121 with a four-dense-block structure to improve gradient flow and feature reuse through dense connections.
[0070] This invention transforms the classification layer into a multilayer perceptron classification head (MLP) with two hidden layers. Each hidden layer uses ReLU activation and Dropout regularization.
[0071] In this study of mineral image classification systems, when morphological features such as local texture and spectral density of mineral images are pre-extracted as vectors, a multilayer perceptron can adaptively learn the nonlinear relationship between mineral categories and features through the weights of the hidden layers. Particularly in distinguishing subtle visual patterns such as color gradations and crystal form differences, the multilayer perceptron demonstrates superior classification performance. Improvements to the classification layer include… Figure 2 As shown, while changing the original single-layer classification to a multi-layer classification, we also need to consider the number of parameters and overfitting issues. Therefore, we further avoid overfitting by combining Dropout regularization in the hidden layers to reduce the number of parameters in the structure. Figure 3 As shown.
[0072] The improved classification layer structure with a three-layer MLP has a total parameter increment of 0.65M, which can be ignored in terms of inference latency. Nonlinear remapping is performed on the high-dimensional semantic features output by DenseNet to enhance the discrimination power of crystal details and spectral textures. When MLP is introduced alone, the F1 score reaches 93.97%.
[0073] The backbone network of this invention is a DenseNet121 network composed of four dense blocks. To balance parameter quantity and recognition accuracy, the model's attention module is improved. This invention adds the attention module between the first three dense blocks and the transition layer, and before the last dense block and BN regularization, adding an ECA (Efficient Channel Attention) attention module. Figure 4 As shown.
[0074] ECA attention mechanism is a lightweight channel attention module. After extracting channel features through global average pooling, it uses one-dimensional convolution to adaptively capture the interaction relationships between adjacent channels, thereby generating channel weights to enhance important features, such as... Figure 5 As shown. Compared to traditional attention mechanisms (such as SENet), ECA avoids dimensionality reduction operations in fully connected layers and preserves high-dimensional information relationships between channels while reducing the number of parameters. The ECA module adaptively calculates the kernel size k of the one-dimensional convolution based on the number of channels. The formula for calculating the kernel size is as follows:
[0075]
[0076] Where C is the number of channels in the input feature, and γ and b are hyperparameters. Taking the absolute value and rounding down to the nearest odd number ensures that the kernel size is odd.
[0077] In this invention, the training optimization module adopts a training-optimization closed loop, and the specific steps are as follows:
[0078] Basic training: 200 epochs, Batch=32, AdamW optimizer (LR=3×10) -4 (cosine annealing).
[0079] The iterative self-distillation model first defines the teacher as the model smoothed based on EMA (α = 0.999) from the previous epoch. The loss function expression is as follows:
[0080]
[0081] Where T = 4 and λ = 0.7.
[0082] Then, an active learning algorithm is used to calculate the prediction entropy.
[0083] H(p) = -∑p i logp i (3);
[0084] Set the threshold τ = 1.2 bits; samples with H(p) > τ are entered into the manual verification pool and fed back into the training set to solve the long-tailed difficult examples.
[0085] In this invention, the model compression module employs a pruning-quantization hybrid compression method, and the specific steps are as follows:
[0086] Channel pruning: Calculate the channel L1-norm importance for each dense block and prune by 25%; FLOPs are reduced to 2.898G.
[0087] QAT (Perceptual Quantization): Converted to INT8 (per-tensor for activation, per-channel for weight), model size 29MB, EdgeTPU inference frame rate ≈ 26fps.
[0088] The end-to-cloud deployment module in this invention specifically includes:
[0089] Training setup: RTX4060Ti + PyTorch2.5.1; Model and logs are securely pushed to the cloud via MQTT.
[0090] Inference end: EdgeTPU / FPGA module + Flask microservice; RESTAPI supports JSON / image upload, and the response returns the category, confidence level, and execution time.
[0091] Visualization: Tkinter front-end synchronization obfuscation matrix and confidence bar chart.
[0092] The performance indicators and comparisons are shown in Table 1:
[0093] Table 1 Performance Indicator Comparison Table
[0094]
[0095] The present invention provides an adaptive lightweight dense network mineral classification method, as detailed below:
[0096] S101, Data Preparation
[0097] (1) Sample collection and standardization: A total of 12,000 microscopic images (1024×1024px) of 7 typical minerals were collected and evenly distributed with three polarization angles (0° / 45° / 90°). The training, validation and test sets were divided into training, validation and test sets in a ratio of 7:1:2 to maintain class balance.
[0098] (2) Labeling quality control: Three petrographic experts independently labeled the samples, and the gold label was generated by majority voting; samples with low consistency were entered into the "difficult pool" for secondary review.
[0099] (3) Data augmentation: Random rotation (±15°), color temperature perturbation, CutMix and random occlusion during the training phase to improve robustness to crystal form and spectral details.
[0100] S201, Network Construction
[0101] (1) DenseNet121 backbone: It adopts a four-dense block + transition layer structure. The input of each layer is concatenated with all the features of the previous layer to achieve feature reuse and smooth gradient propagation.
[0102] (2) ECA channel attention embedding: ECA modules are inserted at the connection points between the first three dense blocks and their transition layers, and before the BN of the last dense block. Figure 5 The kernel size k is determined according to formula (1). It is adaptively determined to ensure that only extremely low parameter overhead is introduced for 1D convolution.
[0103] (3) MLP classification head: The original single-layer fully connected structure is replaced with a "two-layer hidden layer MLP" structure: FC1024→512→ReLU→Dropout0.5→FC512→128→ReLU→Dropout0.5→FC128→7, which significantly improves the nonlinear discrimination power.
[0104] (4) Total parameters and computational cost: The improved model has 7.612M parameters and FLOPs≈2.898G, which is only slightly increased by 0.002G compared to the baseline, in exchange for F1↑1.17% and ACC↑0.53% (Table 2).
[0105] Table 2 Comparison of parameter size, computational cost, and performance between the improved model and the baseline model
[0106]
[0107] S301, Training and Optimization
[0108] Iterative self-distillation: The main model generates pseudo-labels from high-confidence predictions, dynamically expanding hard examples and improving small-sample class performance.
[0109] Active learning: Boundary samples are selected based on entropy values and manually labeled iteratively to alleviate long-tail distribution.
[0110] Hybrid pruning-quantization: Channel pruning + QAT (Quantization-Aware Training) is used to compress parameters to 7.6M and FLOPs≈2.9G, achieving an inference frame rate of ≥25fps on FPGA / EdgeTPU.
[0111] S401, Model Self-Evolution Mechanism
[0112] Self-distillation: The EMA model from the previous epoch is used as the soft teacher, with temperature T = 4; the overall loss is shown in formula (2). This improves the model's ability to distinguish difficult examples without additional overhead.
[0113] Active learning: Calculate the prediction entropy H(p) and push samples with H>1.2bit into the annotation pool; update the training set incrementally every 10 epochs, which significantly improves the recognition performance of long-tail categories (mica).
[0114] S501, Pruning-Quantization Hybrid Compression
[0115] Channel pruning: Based on L1-norm importance, prune 25% of the channels per dense block, reducing FLOPs to 2.898G.
[0116] QAT quantization: Weights are quantized to INT8 (per-channel) to activate per-tensor; the model size is 29MB and can perform real-time inference at 25fps on Edge TPU.
[0117] S601, End-to-Cloud Deployment Architecture
[0118] Training (cloud): The GPU server is responsible for model iteration and log management, and generates weights in ONNX / EDGETPU format.
[0119] Inference edge: Edge TPU + Flask microservice, providing / predictRESTAPI, which returns category, confidence level, and execution time.
[0120] Communication: The model and configuration are uploaded via an MQTT encrypted channel, and the prediction results are sent via HTTP / WebSocket.
[0121] S701, Visual Interactive System
[0122] This layout uses Tkinter to implement a multi-area layout consisting of a top toolbar, image display, results panel, and bottom controls (see layout details). Figure 6 and Figure 8 , Figure 7 and Figure 11 (This is a partial code example).
[0123] Main functions: model selection and loading, batch image prediction, and real-time refresh of confusion matrix and confidence bar chart.
[0124] The image selection and model state detection process is described in [link to documentation]. Figure 10 , Figure 9 and Figure 12 This is the result of mineral identification.
[0125] S801, Scenario Verification
[0126] Laboratory testing: On the test set (2400 images), the improved model achieved a Top-1 accuracy of 95.56% and an F1 accuracy of 94.15% (as shown in Table 1).
[0127] On-site mining demonstration: Taking the Edge TPU terminal to the mining area, the system identified 300 mineral samples taken on-site online. The average inference time was 42ms per sample, and the overall accuracy rate was 93.2%, meeting the requirements of real-time operation.
[0128] Teaching Application: An interactive system was deployed in the petrology course, allowing students to upload self-made thin section images via a GUI to automatically obtain mineral categories and confidence levels, thereby improving teaching efficiency.
[0129] Through the above steps, this invention forms a complete closed loop from data acquisition → model improvement → training optimization → model compression → edge-cloud deployment → visualization application → scenario verification, realizing high-precision, real-time mineral classification on resource-constrained hardware, and providing an integrated intelligent solution for mineral exploration, cultural relic identification, experimental teaching and other fields.
[0130] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. An adaptive lightweight dense network mineral classification system, comprising: include: The data acquisition module is used to acquire microscopic images of various minerals; The preprocessing and enhancement module performs size normalization and data enhancement operations on the image; The feature extraction module is based on the improved DenseNet121 network. It consists of four dense blocks connected sequentially, and ECA channel attention modules are embedded between the first three dense blocks and the transition layer, and before the batch normalization layer of the last dense block. The classification module uses a multilayer perceptron classification head with two hidden layers. The structure is FC1024→ReLU→Dropout→FC512→ReLU→Dropout→FCN, where N is the number of categories. The training optimization module enhances the model's generalization ability through self-distillation and active learning mechanisms. The model compression module performs channel pruning and perceptual quantization training on the network. The edge-cloud deployment module is responsible for model training and updates on the cloud side, and real-time inference is implemented on the edge side based on EdgeTPU or FPGA. The visualization and interactive module displays prediction results and model performance metrics.
2. The self-adaptive light-weight dense network mineral classification system of claim 1, wherein: The one-dimensional convolution kernel size k of the ECA channel attention module is calculated using the formula: Where C is the number of input channels, γ = 2, b = 1, and k is the nearest odd number.
3. The self-adaptive light-weight dense network mineral classification system of claim 1, wherein: The hidden layers of the multilayer perceptron classification head all use the ReLU activation function, and the Dropout probability is 0.
5.
4. The self-adaptive light-weight dense network mineral classification system of claim 1, wherein: The training optimization module generates a teacher model using an exponential moving average and performs self-distillation using a KL divergence loss at a temperature of T=4.
5. The adaptive light-weight dense network mineral classification system of claim 1, wherein: Samples with prediction entropy H(p) > 1.2 bits are actively selected and added to the manual verification pool. Verification data is fed back to the training set every 10 training cycles.
6. The self-adaptive light-weight dense network mineral classification system of claim 4, wherein: The model compression module performs 25% channel pruning and INT8 quantization to reduce the number of parameters to ≤7.6M and FLOPs to ≤2.9G.
7. The adaptive light-weight dense network mineral classification system of claim 1, wherein: Deployed on an EdgeTPU device with 1GB RAM, it supports an average inference time of ≤40ms and a frame rate of ≥25fps for 512×512 pixel images.
8. An adaptive lightweight dense network mineral classification method applied to an adaptive lightweight dense network mineral classification system according to any one of claims 1-7, characterized in that: Includes the following steps: S1. Acquire mineral images and perform preprocessing and data augmentation; S2. Input the image into an improved DenseNet121 network with an embedded ECA module to extract features; S3. Output class probabilities through a two-layer MLP classification head; S4. During training, combine self-distillation and active learning to optimize the model; S5. Perform 25% channel pruning and INT8 quantization on the model; S6. Deploy the quantization model from step S5 to the edge device and visualize the prediction results.
9. The self-adaptive light-weight dense network mineral classification method of claim 7, wherein: In step S4, the self-distillation loss function includes a cross-entropy term and a weighted KL divergence term.
10. The method of claim 7, wherein: In step S5, perceptual quantization is performed as per-channel weight quantization and per-tensor activation quantization.
Citation Information
Patent Citations
Lightweight ancient Chinese character recognition method and system
CN117456541A
Lightweight target detection model integrating attention mechanism, optimization feature fusion method and self-supervised learning
CN120070858A
Traffic sign recognition method based on lightweight neural network
US20230334872A1