Spectral Analysis Methods for a Class of Randomly Occluded Imaging Multimode Fiber Spectrometers
By using a deep convolutional neural network to classify and train occluded speckle patterns, the problem of insufficient resolution in traditional multimode fiber spectrometers under occluded environments is solved, enabling low-cost, high-resolution spectral analysis and simplifying the operation process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- YANSHAN UNIV
- Filing Date
- 2023-08-28
- Publication Date
- 2026-05-26
AI Technical Summary
Traditional multimode fiber optic spectrometers struggle to achieve high-resolution spectral analysis in obstructed environments, and existing reconstruction algorithms require optical path calibration, increasing operational complexity and cost.
A deep convolutional neural network was used to classify and train occluded speckle patterns. By simulating occlusion processing of speckle patterns, a convolutional neural network and a ResNet18 model were built, and the model was optimized to adapt to different occlusion ranges to achieve spectral analysis.
Under low-cost conditions, high-resolution spectral analysis of a multimode fiber optic spectrometer in obstructed environments was achieved, reducing the need for optical path calibration and improving the portability and resolution of the spectrometer.
Smart Images

Figure CN117113187B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of spectral analysis technology of optical instruments and spectrometers, and in particular to a spectral analysis method for a type of randomly occluded imaging multimode fiber optic spectrometer. Background Technology
[0002] Spectrometers have a wide range of applications, such as in metallurgy, medicine, and food processing, where they are frequently used for analysis. Traditional spectrometers can perform one-to-one spatial mapping, but this mapping is only one-dimensional. Multimode fiber spectrometers, however, perform a more complex mapping, corresponding to a two-dimensional mapping from wavelength to speckle pattern, using a transfer matrix to store the spatial intensity distribution generated by different wavelengths. For multimode fiber spectrometers, reconstruction algorithms can be used to recover the corresponding wavelength information. Traditional reconstruction algorithms are mainly phase retrieval algorithms; this invention directly utilizes the powerful learning capabilities of deep convolutional neural networks to identify wavelengths. Compared to traditional spectrometers, where the dispersive elements such as gratings or prisms require pre-calibration of the optical path, multimode fiber spectrometers incorporating deep learning eliminate this step.
[0003] Traditional spectrometers use gratings / prisms to disperse light, and their spectral resolution varies with the optical path length from the grating to the detector, requiring a trade-off between device size and resolution. In recent years, the development of miniature spectrometers has enabled many new applications due to their reduced cost and portability. However, these miniature spectrometers still utilize gratings for dispersion, which means they cannot achieve the high resolution of large benchtop spectrometers while maintaining a small footprint.
[0004] In practical applications of spectrometers, occlusion is inevitable. Therefore, spectral speckle remnants are simulated without actually setting up a spectrometer experiment. Convolutional neural networks have powerful learning capabilities and can be used to classify the wavelengths of the speckle remnants. Considering the advantages of neural networks, we attempted to train them to classify occluded speckle. This demonstrates, under low-cost conditions, that a multimode fiber optic spectrometer can achieve spectral dispersion even in occluded environments. Summary of the Invention
[0005] To address the issue of incomplete speckle patterns acquired by multimode fiber optic spectrometers under occlusion conditions, this invention provides a spectral analysis method for multimode fiber optic spectrometers with random occlusion imaging. A Python program is used to simulate the speckle patterns generated by this type of spectrometer under occlusion conditions during acquisition. A classification network is built based on the characteristics of the speckle pattern. The network is used to train speckle classification and compared with existing ResNet18 training classification to derive suitable models for different occlusion ranges.
[0006] To achieve the above objectives, the technical solution proposed in this application is as follows:
[0007] A spectral analysis method for a class of randomly occluded imaging multimode fiber optic spectrometers includes the following steps:
[0008] Step S1: Processing the speckle pattern, dividing the speckle pattern data collected at different sampling intervals into training set, test set and validation set according to the corresponding proportions;
[0009] Step S2: Crop the speckle data. Find the center position of the speckle with the center of the speckle image as the reference. Cut out a square containing all the speckle information with the speckle circle as the side length. Set the gap between the square with the speckle image and the circle containing only speckle information to a blank without interference and without pixel information.
[0010] Step S3: Simulate occlusion on the dataset processed in step S2; use a random erasure function to perform rectangular occlusion processing on the training dataset to obtain a rectangular occluded dataset; define an elliptical occlusion function and use the idea of randomly selecting the occlusion area within the occlusion range to process the test set and validation set to obtain an elliptical occlusion dataset.
[0011] Step S4: Perform data augmentation on the rectangular occlusion dataset processed in step S3 to increase the number of datasets;
[0012] Step S5: Construct a convolutional neural network based on the wavelength characteristics of the speckle pattern; input the rectangular occlusion dataset after data enhancement in Step S4 into the constructed convolutional neural network according to different occlusion ranges, i.e., the occlusion ranges increase sequentially, for training to obtain the optimized model A; realize the classification and matching of occluded light spot data and light source frequency;
[0013] Step S6: Input the rectangular occlusion dataset after data augmentation in step S4 into the ResNet18 network in order of increasing occlusion range to obtain optimized model B with different sampling intervals and different occlusion ranges.
[0014] Step S8: Compare and analyze the optimized model A and the optimized model B to obtain a suitable network model with different sampling intervals and different occlusion ranges, so as to achieve the beam splitting effect.
[0015] A further improvement to this method is that step S5 includes the following specific steps:
[0016] Step S5-1: Initialize the model training parameters for the convolutional neural network;
[0017] Step S5-2: Input the rectangular occlusion dataset after data augmentation in step S4 into the convolutional neural network, and obtain the output value by passing through the convolutional layer, activation layer, pooling layer and fully connected layer of the convolutional neural network;
[0018] Step S5-3: Calculate the error between the output value and the target value of the convolutional neural network;
[0019] Step S5-4: When the error is greater than the target value, the error is propagated back into the network, and the errors of the fully connected layer, downsampling layer, and convolutional layer are calculated in sequence, which is the backpropagation process; training ends when the error is equal to or less than our expected value, and the weights are output at this time.
[0020] Step S5-5: Train the convolutional neural network model sequentially using the rectangular occlusion datasets with several different occlusion ranges after data enhancement, following the steps above.
[0021] A further improvement to this method is that in step S2, a custom function in Python is used to extract a circular speckle pattern containing only wavelength information.
[0022] A further improvement to this method is that, in step S3, a random erasure function is applied to simulate rectangular occlusion on the training dataset; a custom elliptical occlusion function is used, with parameters including occlusion probability, minimum occlusion area ratio, maximum occlusion area ratio, aspect ratio of the occlusion ellipse, and input image size. The occlusion area size is selected using a random function, where the occlusion area ratio refers to the percentage of the entire rectangular area. The elliptical occlusion function is applied to the elliptical datasets of the training and validation sets to obtain a speckle dataset with occlusion shapes different from those of the training set.
[0023] A further improvement to this method is that in step S1, the dataset is divided into a training dataset, a test dataset, and a validation dataset in an 8:1:1 ratio.
[0024] A further improvement to this method is that step S4 includes data augmentation by changing the attributes of the speckle map in the rectangular occlusion dataset, such as brightness, contrast, saturation, and hue, through horizontal and vertical flipping.
[0025] A further improvement to this method is that, in step S5, building a convolutional neural network requires analyzing the wavelength characteristics of the occluded speckle pattern. Since the speckle pattern is incomplete, it is considered to build a convolutional neural network with an appropriate number of layers, which saves training time while meeting the accuracy requirements.
[0026] The beneficial effects of this invention are as follows:
[0027] 1. This invention utilizes a Python program to simulate occlusion of complete speckle patterns, achieving the experimental objective at a low cost without the need for actual experimental setup;
[0028] 2. This invention constructs a CNN network based on speckle characteristics to analyze occluded speckle, eliminating the influence of light intensity on speckle recognition. Within a certain occlusion range, it effectively and accurately classifies lasers of different frequencies, achieving the spectrometer's spectral dispersion effect under occlusion conditions.
[0029] 3. This invention illustrates that when the occlusion range is large, even with deep learning methods, it is still impossible to accurately identify the wavelength corresponding to the speckle pattern within the occlusion range.
[0030] 4. This invention utilizes deep learning methods to perform spectral identification of occluded speckle patterns, and compares with existing excellent network frameworks such as ResNet18 to select a suitable network training model. Attached Figure Description
[0031] Figure 1 This is a schematic diagram of speckle occlusion after the random rectangular occlusion processing of the present invention.
[0032] Figure 2 This is a schematic diagram of speckle occlusion after the random elliptical occlusion processing of the present invention.
[0033] Figure 3 This is a schematic diagram of the convolutional neural network structure built and used in this invention;
[0034] Figure 4 This is a diagram of the Resnet18 network structure used in this invention;
[0035] Figure 5 The training effect of the constructed neural network used in this invention to train speckle maps with occlusion (10nm interval);
[0036] Figure 6 The training effect of the neural network constructed in this invention is shown in the training of speckle maps with occlusion (1nm interval);
[0037] Figure 7 The training effect of the neural network constructed in this invention is shown in the training of speckle patterns with occlusion (0.01nm interval).
[0038] Figure 8 The training effect of training a speckle map with occlusion using a ResNet18 network (10nm with intervals) is shown in this invention.
[0039] Figure 9 The training effect of training a speckle map with occlusion using a ResNet18 network (1nm interval) is shown in this invention.
[0040] Figure 10 The training effect of training a speckle map with occlusion using a ResNet18 network in this invention (0.01nm interval);
[0041] Figure 11 This is an unmasked speckle pattern;
[0042] Figure 12 To simulate a speckle pattern with random occlusion. Detailed Implementation
[0043] The following is with reference to the appendix. Figure 1-10 Embodiments of the present invention will be described. Figure 5-7 (in, Figure 5 In the image, a represents the area with an occlusion range of 20%-40%, b represents the area with an occlusion range of 40%-60%, c represents the area with an occlusion range of 60%-80%, and d represents the area with an occlusion range of 80%-90%.
[0044] Figure 6 In the image, a represents the area with an occlusion range of 20%-40%, b represents the area with an occlusion range of 40%-60%, c represents the area with an occlusion range of 60%-80%, and d represents the area with an occlusion range of 80%-90%.
[0045] Figure 7 In the image, a represents an occlusion area of 20%-40%, b represents an occlusion area of 40%-60%, c represents an occlusion area of 60%-80%, and d represents an occlusion area of 80%-90%. Figure 8-10 (in, Figure 8 In the image, a represents the area with an occlusion range of 20%-40%, b represents the area with an occlusion range of 40%-60%, c represents the area with an occlusion range of 60%-80%, and d represents the area with an occlusion range of 80%-90%. Figure 9 In the image, a represents the area with an occlusion range of 20%-40%, b represents the area with an occlusion range of 40%-60%, c represents the area with an occlusion range of 60%-80%, and d represents the area with an occlusion range of 80%-90%. Figure 10 The graph (a) shows images with 20%-40% occlusion, b with 40%-60% occlusion, c with 60%-80% occlusion, and d with 80%-90% occlusion. The curves and the axes are explained as follows: train loss (training loss), train acc (training accuracy), val acc (validation accuracy), and max acc (maximum accuracy). When viewing the accuracy curve, the ordinate represents the training accuracy; for example, an accuracy value of 1 represents 100% accuracy. When viewing the loss function, the ordinate represents the value of the loss function. The x-axis represents the number of training iterations. Figure 4 Solid lines indicate that the number of channels in the residual block remains unchanged, while dashed lines indicate that the number of channels changes, for example, from 64 to 128.
[0046] The speckle dataset, acquired at different sampling intervals across the entire wavelength range of 1440-1590nm, was stored according to these intervals. The 10nm dataset covers the wavelength range of 1440nm-1590nm, with one dataset for every 10nm; the 1nm dataset covers the wavelength ranges of 1440nm-1449nm, 1510nm-1519nm, and 1580nm-1590nm, with one dataset for every 1nm; and the 0.01nm dataset covers the wavelength range of 1500nm-1500.09nm, with one dataset for every 0.01nm. 1000 speckle patterns were collected for each frequency. These datasets were divided into training, testing, and validation sets in an 8:1:1 ratio, stored in folders named train, test, and val, respectively. 800 images were selected from each frequency to form the training set for model training; 100 images were used as the validation set for evaluating model performance during training; and 100 images were used as the testing set for final model evaluation.
[0047] The pre-processed speckle pattern is preprocessed. To avoid interference from irrelevant information, a custom `circle()` function is used to set the parameters of the captured speckle pattern according to the speckle size, separating the speckle from the acquisition background. At this point, the speckle pattern contains only wavelength information, as shown below. Figure 11 The image shown is a speckle pattern after removing the black background. The `resize()` function is then used to resize the image into a 224x224 square image; finally, the `convert()` function is used to convert the grayscale image into a three-channel RGB color image.
[0048] To better simulate Figure 12 Similar speckle data plots use the random-erasing() function to simulate rectangular occlusion on the training set within the divided dataset, resulting in a graphical representation as shown below. Figure 1 (Image a shows an image with 20%-40% occlusion, image b shows an image with 40%-60% occlusion, image c shows an image with 60%-80% occlusion, and image d shows an image with 80%-90% occlusion). The validation and test sets in the dataset use a custom elliptical occlusion function `re()` to simulate elliptical occlusion processing. Parameters include occlusion probability, minimum occlusion area ratio, maximum occlusion area ratio, aspect ratio of the occlusion ellipse, and input image size. The `random.uniform()` function is used to select the occlusion area size. The resulting illustration is shown below. Figure 2(Image a shows an occlusion range of 20%-40%, image b shows an occlusion range of 40%-60%, image c shows an occlusion range of 60%-80%, and image d shows an occlusion range of 80%-90%). To illustrate the impact of occlusion range on the model, several speckle occlusion processing images with different occlusion sizes were presented. These ranges are 20%-40%, 40%-60%, 60%-80%, and 80%-90%, respectively.
[0049] By analyzing the similarity of light spots, a convolutional neural network structure is constructed to obtain a suitable training model for each occlusion range.
[0050] Configuring a Convolutional Neural Network: The network was built using the PyTorch framework and consisted of a 6-layer CNN structure. For analysis and comparison, a ResNet18 network was also used.
[0051] Convolutional neural network structure as follows Figure 3 As shown, the neural network consists of an input layer, hidden layers, and an output layer. The first layer is a convolutional layer followed by a max-pooling layer. The second layer is a convolutional layer followed by a max-pooling layer for dimensionality reduction. The third, fourth, fifth, and sixth layers all use residual structures. These layers are discarded when the network is trained to accurately classify the corresponding data. The final layer is a fully connected layer that classifies the output.
[0052] The model training steps involve using the original model framework, changing the output of the fully connected layer, and retraining the model. The number of output neurons in the fully connected layer corresponds to the number of wavelength categories in the training samples. The data-augmented training set is then used to train the model.
[0053] In deep learning, a sufficient number of samples is generally required. The more samples, the better the trained model performs, the stronger its generalization ability, and the better its robustness. Data augmentation aims to make limited data produce the equivalent effect of more data when more data is unavailable. The data augmentation methods used in this application are as follows: random horizontal flipping, random vertical flipping, adjusting image contrast, and adjusting image brightness.
[0054] During model training, backpropagation of the training set error is used to optimize the network parameters; forward propagation is used to train the optimized model, and the resulting image classification model is used to classify the occluded speckle map test set.
[0055] Training specifically includes two processes. The first process is the propagation of data from lower to higher levels, i.e., forward propagation. The other process is the propagation of the error from higher to lower levels for training when the result obtained from forward propagation is completely different from the expectation, i.e., backpropagation.
[0056] To prevent overfitting, the Adam optimizer is applied to the network.
[0057] The test and validation data were classified using the method described above, and the neural network connection weights were optimized using a neural network algorithm. First, the model was trained and constructed using images from a rectangular occlusion training set, where the input layer consisted of speckle images with different occlusion ratios, and the output layer represented the probabilities corresponding to different classifications. Then, the trained model was tested using images from an elliptical occlusion test set. After optimizing the neural network connection weights using a neural network algorithm, the final classification network was obtained, which was used to classify speckle images of different frequencies captured by the camera. Experimental results show that the speckle spectral dispersion method under simulated occlusion conditions can accurately classify speckle images within a certain occlusion range (20-80%), indicating that this spectral analysis method can achieve a dispersion effect for occluded speckle. Considering both accuracy and runtime, in a comparison of multiple models, when the single-frequency light sampling interval is 0.01nm and the occlusion range is 20-40%, the ResNet18 network achieves 100% classification accuracy on both the validation and test sets. However, considering runtime, the 6-layer convolutional neural network that achieves 100% validation set accuracy is more suitable for this purpose. When the occlusion range is 40%-60%, the ResNet18 network achieves 99.9% accuracy, but our 6-layer CNN network achieves 100% accuracy in a relatively short time, and the test set accuracy is also better. The accuracy can reach 100%, so a 6-layer CNN network is chosen. For 60-80% occlusion, the ResNet18 accuracy of 92.7% is lower than the 6-layer CNN accuracy of 95.5%, so a 6-layer CNN is chosen. For 80-90% occlusion, the training effect of shallow neural networks is poor due to the large occlusion area. Therefore, ResNet18 is chosen for datasets with 10nm and 1nm sampling intervals. However, for datasets with 0.01nm intervals, the sampling interval is small, and the speckle similarity of adjacent wavelengths is too high, making it difficult to achieve accurate classification using either a 6-layer CNN or ResNet18. When the single-frequency light sampling interval is 1nm and 10nm, the speckle features are more obvious than at 0.01nm. Considering both training time and classification accuracy, a 6-layer CNN network is chosen for datasets with 20-80% occlusion. For 80-90% occlusion, a deep neural network is needed to ensure accuracy, but both ResNet18 and 6-layer CNN used in this invention are difficult to classify accurately.
[0058] Specifically, this invention discloses a spectroscopic analysis method for a spectrometer under simulated occlusion conditions, which combines deep learning to classify spectral remnants of occlusion. This method has a relatively shallow number of network layers, enabling it to accurately classify speckles with small occlusion areas and obtain the frequencies of the occluded speckles. The spectrometer resolution under occlusion conditions reaches 0.01 nm. The specific implementation scheme is as follows:
[0059] 1. Theoretical Basis: When single-frequency light propagates through a multimode fiber, speckle patterns are generated at the fiber's end. Due to the large number of modes within the multimode fiber, the time it takes for light to reach the fiber's end varies, resulting in speckle patterns with different characteristics, providing a fingerprint of the input wavelength. For speckle patterns acquired by the spectrometer under obstructed conditions, Python was used to simulate obstruction in unobstructed speckle patterns. The processing results are as follows: Figure 1 and Figure 2 As shown, the speckle pattern after occlusion still retains some speckle information, which also contains some wavelength information. Based on this theory and combined with deep learning methods, the corresponding light source wavelength can be retrieved by occluding speckle patterns of different ranges.
[0060] 2. Dataset Preparation: Based on the speckle dataset acquired by the multimode fiber optic spectrometer, some speckles were processed with random rectangular occlusion sizes, and others with random elliptical occlusion sizes.
[0061] The collected speckle images, originally 320*256 pixels, were uploaded to the data processing platform and divided into training, validation, and test sets. First, they needed to be cropped. A square image was cropped based on the speckle size; this involved using a custom `circle()` function to extract only the speckle information, removing the black background, and then using the `resize()` function in Python to resize the image into a 224*224 square. Finally, the `convert()` function was used to convert it to an RGB image.
[0062] For speckle maps with a 10nm sampling interval, the dataset is divided into training, validation, and test sets in an 8:1:1 ratio. The 10nm sampling dataset contains 16,000 images with wavelengths ranging from 1440nm to 1590nm, with one corresponding wavelength for every 10nm. The training set consists of 12,800 rectangular occluded speckle images, the validation set consists of 1,600 elliptical occluded images, and the test set consists of 1,600 elliptical occluded images. The occlusion ranges from 20-40%, 40-60%, 60-80%, and finally 80-90%. Simulated occluded speckle is shown below. Figure 1 and Figure 2 As shown.
[0063] The Color-Jitter(), RandomVerticalFlip(), and RandomHorizontalFlip() functions were applied to adjust the contrast, brightness, and perform random vertical and horizontal flipping on the training set. The preprocessed and augmented speckle dataset was then input into the CNN network for model optimization.
[0064] 3. CNN setup and configuration: In order to obtain the matching selection of speckle data and light source wavelength under different occlusion ratios, a suitable network model needs to be trained.
[0065] First, we build a CNN network using the PyTorch framework. The CNN structure is as follows. Figure 3 As shown, the neural network consists of an input layer, convolutional layers, pooling layers, and fully connected layers. The image enters the convolutional layers from the input layer and propagates forward sequentially until it reaches the output layer. The network built in this experiment consists of 6 convolutional layers. The explanation is as follows:
[0066] The first layer consists of a convolutional layer followed by a max pooling layer. The convolutional kernel size is 7×7, the stride is 2, and the padding is 3. After the first convolutional layer, the output size is 112×112×64. Batch Normalization is then applied to batch the data elements of the same channel across all batches. The activation function is ReLU. The pooling layer has a 3×3 convolutional kernel size, a stride of 2, and an output size of 55×55×64.
[0067] The second layer consists of a convolutional layer and a max pooling layer. The convolutional kernel size is 5×5, the stride is 2, the padding is 1, and the output size is 27×27×128. The activation function is ReLU. The pooling layer has a 3×3 kernel, a stride of 2, and an output size of 13×13×128. Like the first convolutional layer, BatchNormalization is also included.
[0068] The third layer employs a residual structure, which uses a shortcut connection method to add the feature matrices every other layer. The convolutional layer has 128 input and 128 output channels, a kernel size of 3, a stride of 1, and padding of 1. After the convolutional layer, an attention mechanism is used to boost the channels with speckle map features. The original result is then added to the attention-based output before being fed into the ReLU layer. The final output is maintained at 13×13×128. A batch normalization layer is added after the convolutional layers.
[0069] The fourth layer also uses a residual structure. The convolutional layer has 128 input channels and 256 output channels, with a 3×3 kernel size, a stride of 2, and padding of 1. After the convolutional layer, an attention mechanism boosts the channels with speckle map features. The current output is added to the output after this convolutional layer before being fed into the ReLU layer. The final output is maintained at 7×7×256. Batch Normalization is applied after the convolutional layers.
[0070] The fifth residual structure convolutional part has 256 input and output channels, a kernel size of 3×3, a stride of 1, and padding of 1. The output is enhanced by attention after passing through a bn layer. The enhanced result is added to the original result and fed into a ReLU layer. The final output is 7×7×256.
[0071] The sixth residual structure convolutional part has 256 input channels, 512 output channels, a kernel size of 3, a stride of 2, and padding of 1. The output is enhanced by attention after passing through a bn layer. The enhanced result is added to the result of the current convolutional layer and then fed into a ReLU layer. The final output is 4×4×256.
[0072] The seventh layer is a fully connected layer that classifies the model output.
[0073] The ResNet 18-layer convolutional neural network consists of the following layers: The first convolutional layer has 64 kernels, a 7×7 window size, and a stride of 2. Following this is a pooling layer with a 3×3 window size and a stride of 2. Next are four blocks: the first block has 64 kernels with a 3×3 window size and a stride of 2; the second block has 128 kernels with a 3×3 window size and a stride of 2; the third block has 256 kernels with a 3×3 window size and a stride of 2; and the fourth block has 512 kernels with a 3×3 window size and a stride of 2. Finally, there is a fully connected output layer followed by Dropout to prevent overfitting. The output shows the classification result for the corresponding number of groups in the experiment, using the Softmax activation function.
[0074] 4. Network Model Training and Testing: The CNN training employed includes two processes: forward propagation and backpropagation. Forward propagation uses the output of the previous layer as the input to the next layer and calculates the output of the next layer, continuing until the output layer is reached. Backpropagation calculates the error of each layer, progressing from the last layer forward (i.e., the error is propagated backward); it also calculates the gradient of the connection weights of each neuron; and updates the parameters according to the gradient descent rule (the goal is to minimize the error). These steps are iterated until a stopping criterion is met (e.g., the difference in error between two adjacent iterations is very small).
[0075] 5. Train the model using the occlusion-processed training dataset, optimizing the neural network connection weights through the training process in step 4. Save the optimal network model parameters obtained after multiple optimizations as a pth file. The training results are as follows. Figure 5-7 and Figure 8-10 As shown. Then, the test set is fed into the optimized network model for model classification validation.
[0076] Training datasets with different occlusion ranges at 10nm intervals were sequentially fed into a 6-layer CNN network to train the model. The same operation was performed on the other two datasets with different sampling intervals. The results are as follows. Figure 5-7 As shown, it can be seen that as the resolution increases, the image features gradually become similar, and the model needs more epochs to learn different features.
[0077] The above training dataset was then fed into the ResNet18 network according to the occlusion ratio to train the model. The results are as follows. Figure 8-10 As shown.
[0078] The trained model was then used on the test set to evaluate its performance. The accuracy results are shown in Table 1 below.
[0079] Table 1 shows a comparison of the training results for occlusion speckle in this invention, as follows: (a) Comparison of 10nm classification results
[0080]
[0081] (b) Comparison of 1nm classification results
[0082]
[0083] (c) Comparison of classification results at 0.01nm
[0084]
[0085] 6. Figure 5-7 and Figure 8-10 The test results were compared with those of the test set, and the comparison results are shown in Table 1.
[0086] From the perspective of the validation set, the comparison results in Table 1 show that for the three types of sampling intervals, for the speckle dataset with 20-40% occlusion, both the 6-layer CNN and ResNet18 can achieve accurate classification, but the time consumption differs significantly. Considering both accuracy and model training time, the 6-layer CNN network model is selected. For the speckle dataset with 40-60% occlusion, except for the 1nm sampling interval where the 6-layer CNN validation set accuracy is 99.9% and the 0.01nm sampling interval where the ResNet18 validation set accuracy is 99.9%, all other validation set classification accuracy is 100%. Therefore, considering training time, the 6-layer CNN network is selected for all datasets. For 60-80% occlusion, a 10nm sampling interval can achieve 99.9% validation set accuracy with a 6-layer CNN, and a 1nm sampling interval can achieve 99.5% validation set accuracy with ResNet18 training. However, this high accuracy comes at the cost of training time. Neither 10nm nor 0.01nm achieves 99% validation set accuracy, especially at 0.01nm, where the differences between datasets are smaller compared to 10nm and 1nm, making classification more difficult. Even deep convolutional neural networks struggle to achieve high accuracy. Therefore, considering training time, a 6-layer CNN is still the preferred choice. For 80-90% occlusion, the larger occlusion area results in less retained wavelength-related information, making it difficult to achieve high classification accuracy using shallow CNNs.
[0087] From the perspective of the test sets, for datasets with 20-40% and 40-60% occlusion, both ResNet18 and the 6-layer CNN can achieve classification accuracy of over 99%. Considering both time and accuracy, as well as model parameters, the model trained with the 6-layer CNN was chosen. For datasets with 60-80% occlusion, the 6-layer CNN achieves 99.8% classification accuracy on the 10nm dataset, 97% on the 1nm dataset, and 95.6% on the 0.01nm dataset; ResNet18 only achieves 98.5% accuracy on the 10nm dataset, 98.9% on the 1nm dataset, and only 90.4% on the 0.01nm dataset. Considering all factors, the model trained with the 6-layer CNN was chosen. For 80-90% occlusion, due to the large occlusion area, less wavelength-related information is retained, making it difficult to achieve high classification accuracy using shallow CNNs. Therefore, a 6-layer CNN is insufficient to accurately classify the corresponding wavelengths. However, an 18-layer ResNet can achieve over 95% classification accuracy on datasets with 10nm and 1nm sampling intervals. Therefore, ResNet18 is used to classify this part of the dataset. For datasets with 0.01nm sampling intervals, a 6-layer CNN can achieve a classification accuracy of 70%, while ResNet18 only achieves about 12%. Therefore, neither network can accurately classify the 0.01nm dataset under such occlusion.
[0088] 7. Experimental Summary: The experimental results above show that speckle patterns with simulated occlusion can be accurately classified into corresponding light source wavelengths using deep learning methods. As long as the occlusion range does not exceed 60%, the classification accuracy can reach 99%-100%. However, the classification difficulty increases and the accuracy decreases when the occlusion range exceeds 80%. For occlusion datasets with 10nm and 1nm sampling intervals, the classification accuracy of a shallow 6-layer CNN is 87.7% and 83.4%, respectively, while ResNet18 can achieve a classification accuracy of over 95%, suggesting that a deeper ResNet18 layer can be used for classification. Datasets with a 0.01nm sampling interval are more difficult to classify accurately for corresponding wavelengths. The experiment can achieve spectrometer dispersion effects under simulated occlusion conditions within a certain occlusion range.
[0089] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it; it should be understood that those skilled in the art can make many modifications and variations based on the concept of this application without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of this application and through logical analysis, reasoning or limited experimentation on the basis of the prior art should be within the protection scope defined by this application.
Claims
1. A method of spectral analysis of a stochastic masking imaging multimode fiber optic spectrometer, characterized in that, Includes the following steps: Step S1: Processing the speckle pattern, dividing the speckle pattern data collected at different sampling intervals into training set, test set and validation set according to the corresponding proportions; Step S2: Crop the speckle data. Find the center position of the speckle with the center of the speckle image as the reference. Cut out a square containing all the speckle information with the speckle circle as the side length. Set the gap between the square with the speckle image and the circle containing only speckle information to a blank without interference and without pixel information. Step S3: Simulate occlusion on the dataset processed in step S2; use a random erase function to perform rectangular occlusion processing on the training dataset to obtain a rectangular occluded dataset. An elliptical occlusion function is defined, and the test set and validation set are processed by randomly selecting the occlusion area within the occlusion range to obtain the elliptical occlusion dataset; in step S3, a random erasure function is applied to simulate rectangular occlusion on the training dataset. A custom ellipse occlusion function is defined with parameters including occlusion probability, minimum occlusion area ratio, maximum occlusion area ratio, aspect ratio of the occlusion ellipse, and input image size. The occlusion area is selected using a random function, where the occlusion area ratio refers to the percentage of the entire rectangle's area. The elliptical occlusion function is applied to the elliptical datasets of the training and validation sets in order to obtain a speckle dataset with an occlusion shape that is different from that of the training set. Step S4: Perform data augmentation on the rectangular occlusion dataset processed in step S3 to increase the number of datasets; Step S5: Construct a convolutional neural network based on the wavelength characteristics of the speckle pattern; input the rectangular occlusion dataset after data enhancement in Step S4 into the constructed convolutional neural network according to different occlusion ranges, i.e., the occlusion range increases sequentially, for training to obtain the optimized model A; realize the classification and matching of occlusion speckle data and light source frequency; Step S6: Input the rectangular occlusion dataset after data augmentation in step S4 into the ResNet18 network in order of increasing occlusion range to obtain optimized models B with different sampling intervals and different occlusion ranges. Step S8: Compare and analyze the optimized model A and the optimized model B to obtain a suitable network model for different sampling intervals and different occlusion ranges, so as to achieve the beam splitting effect.
2. The spectral analysis method for a type of randomly occluded imaging multimode fiber optic spectrometer according to claim 1, characterized in that, Step S5 includes the following specific steps: Step S5-1: Initialize the model training parameters for the convolutional neural network; Step S5-2: Input the rectangular occlusion dataset after data augmentation in step S4 into the convolutional neural network, and obtain the output value by passing through the convolutional layer, activation layer, pooling layer and fully connected layer of the convolutional neural network; Step S5-3: Calculate the error between the output value and the target value of the convolutional neural network; Step S5-4: When the error is greater than the target value, the error is propagated back into the network, and the errors of the fully connected layer, downsampling layer and convolutional layer are calculated in sequence, which is the backpropagation process. Training ends when the error is equal to or less than our expected value, at which point the weights are output. Step S5-5: Train the convolutional neural network model sequentially using the rectangular occlusion datasets with several different occlusion ranges after data enhancement, following the steps above.
3. The spectral analysis method for a type of randomly occluded imaging multimode fiber optic spectrometer according to claim 1, characterized in that, In step S2, a custom function in Python is used to extract a circular speckle pattern containing only wavelength information.
4. The spectral analysis method for a type of randomly occluded imaging multimode fiber optic spectrometer according to claim 1, characterized in that, In step S1, the dataset is divided into a training dataset, a test dataset, and a validation dataset in a ratio of 8:1:
1.
5. The spectral analysis method for a type of randomly occluded imaging multimode fiber optic spectrometer according to claim 1, characterized in that, Step S4 includes data augmentation by changing the attributes of the speckle map in the rectangular occlusion dataset, such as brightness, contrast, saturation, and hue, through horizontal and vertical flipping.
6. The spectral analysis method for a type of randomly occluded imaging multimode fiber optic spectrometer according to claim 1, characterized in that, In step S5, building a convolutional neural network requires analyzing the wavelength characteristics of the occluded speckle pattern. Since the speckle pattern is incomplete, it is considered to build a convolutional neural network with an appropriate number of layers to save training time while meeting the accuracy requirements.