Dark environment flash exposure photo processing method and system

By using a conditional cascade model and a dynamic decision-making mechanism, the problem of the imbalance between efficiency and effect in flash photography technology under dark environments is solved, achieving efficient image quality restoration under complex lighting conditions and adapting to various real-world scenarios.

CN122115883APending Publication Date: 2026-05-29INSPUR TIANYUAN COMM INFORMATION SYST CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INSPUR TIANYUAN COMM INFORMATION SYST CO LTD
Filing Date
2026-02-10
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing dark environment flash photography processing technologies have significant shortcomings in balancing efficiency and processing effect, dynamic adaptability, and generalization ability, making it difficult to achieve global illumination reconstruction and simultaneous restoration of local physical properties under complex lighting conditions.

Method used

A conditional cascaded model is adopted, including a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. Training and validation sets are constructed through data preprocessing, and features are extracted using ResNet50 and ResNet18. Combined with a dynamic decision mechanism and multidimensional degradation enhancement processing, the processing path is dynamically adjusted to achieve the fusion analysis of global and local features.

Benefits of technology

It achieves dynamic allocation of computing resources, improves the image recognition quality of difficult samples, adapts to a variety of complex real-world scenarios, reduces computational redundancy, and improves the balance between processing efficiency and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115883A_ABST
    Figure CN122115883A_ABST
Patent Text Reader

Abstract

The application discloses a dark environment flash light exposure photo processing method and system, and belongs to the technical field of image processing, and aims to solve the technical problem of how to overcome the significant deficiencies of the existing dark environment flash light photo processing technology in the balance between efficiency and processing effect, dynamic adaptability and generalization ability. The method comprises the following steps: labeling with a retouched image and an unretouched image as a label, respectively performing basic standardization processing and multi-dimensional degradation enhancement processing on the original image, constructing a training set based on the preprocessed image and the enhanced image, and constructing a verification set based on the original image; a conditional cascade model is constructed, the conditional cascade model is trained based on the training set, and the trained conditional cascade model is verified based on the verification set, wherein the conditional cascade model comprises a main network branch, an auxiliary network branch, a dynamic decision unit and a fusion unit; and the preprocessed image is taken as an input image, and inference analysis is performed through the trained conditional cascade model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, specifically to a method and system for processing photos taken under flash exposure in dark environments. Background Technology

[0002] When shooting photos with a flash in dark environments, complex illumination degradation poses multiple challenges to image quality: areas directly illuminated by the flash are prone to overexposure and highlight clipping due to the instantaneous strong light, resulting in loss of texture information; while dark areas far from the flash are affected by weak ambient light, often exhibiting underexposure, noise accumulation in dark areas, and loss of detail. Simultaneously, dynamic range compression causes issues such as halo artifacts, non-uniform color casts, and highlight diffusion from reflective surfaces. For example, the conflict between cool-toned flash and warm-toned ambient light creates multi-scale coupled image degradation features. Existing methods have fundamental flaws in handling such complex degradation: solutions based on a single model (such as UNet and ResNet) are limited by the inherent trade-off between the network's receptive field and feature representation capabilities, making it difficult to simultaneously achieve global illumination reconstruction and local physical property restoration. For example, while global exposure correction models can alleviate overall brightness imbalance, they erase the edge sharpness of small objects; and local detail enhancement networks may amplify high-frequency noise and produce unrealistic color shifts in large shadow areas.

[0003] Current parallel multi-model architectures attempt to improve processing performance through feature fusion, but their rigid computational framework exposes two major shortcomings: 1. Insufficient modeling of the flash-related degradation mechanism: Failure to construct the prior correlation between light intensity, object material and spatial distance, resulting in a contradictory phenomenon of excessive edge sharpening and smoothing of details in the diffuse reflection area when processing highly reflective objects; 2. Lack of intelligent decision-making mechanism at the dynamic resource allocation level: When processing low-difficulty samples, the entire multi-model calculation process is still mechanically executed, resulting in a large amount of redundant computation. Although traditional threshold control methods attempt to simplify the processing flow through confidence judgment, static threshold settings cannot adapt to the lighting complexity of dark scenes—for example, the alternation of sudden flashes and continuous low light in surveillance scenes, or the rapid changes in lighting conditions caused by moving shots, will cause the fixed threshold strategy to fail and lead to misjudgments. This technical defect is particularly prominent when deploying edge devices, not only causing fluctuations in processing latency, but also causing heat accumulation and a sharp increase in energy consumption of terminal devices due to computational overload.

[0004] A deeper problem stems from the lack of modeling of the physical characteristics of dark environments in existing methods: the mapping relationship between flash attenuation coefficient and scene depth is not established, and the differentiated reflection characteristics of different materials on the flash lamp are ignored. This leads to contradictory phenomena in the processing results, such as local overcorrection (e.g., specular explosion in the specular reflection area of ​​a metal surface) and undercorrection (e.g., grayscale collapse in the diffuse reflection area of ​​a fabric surface). In addition, existing models often use synthetic data or laboratory-controlled environment data during the training phase, which differs significantly from the complex factors in real-world scenes, such as flash power fluctuations, multi-source interference, and atmospheric transmittance variations. This results in decreased model generalization ability and makes the models prone to abrupt changes in processing effects or color banding in real-world applications.

[0005] Overcoming the significant shortcomings of existing dark environment flash photography processing technologies in balancing efficiency and processing quality, dynamic adaptability, and generalization ability is a technical problem that needs to be solved. Summary of the Invention

[0006] The technical objective of this invention is to address the above-mentioned shortcomings by providing a method and system for processing photos taken with flash in dark environments, thereby overcoming the significant deficiencies in existing dark environment flash photo processing technologies regarding the balance between efficiency and processing effect, dynamic adaptability, and generalization ability.

[0007] In a first aspect, the present invention provides a method for processing photos exposed by flash in dark environments, comprising the following steps: Data preprocessing: Normal exposure images taken with a flash in a dark environment and copied images are used as the original images. The copied images and uncopied images are labeled. Basic standardization and multidimensional degradation enhancement processing are performed on the original images respectively. The basic standardization process is followed by cropping and normalization to obtain the preprocessed image. The multidimensional degradation enhancement process is followed by highlight overexposure simulation, moiré synthesis, color perturbation, noise blurring and geometric transformation to generate the enhanced image. The training set is constructed based on the preprocessed image and the enhanced image, and the validation set is constructed based on the original images. Model Training and Optimization: A conditional cascade model is constructed. The model is trained on the training set and validated on the validation set. The conditional cascade model includes a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. The main network branch is used to extract global features and perform classification analysis on the input image, outputting preliminary classification results and confidence scores. The dynamic decision unit is used to determine the current input image type and processing path based on the preliminary classification results and confidence scores through a dynamic decision mechanism. If the current input image type is a simple sample, the processing path is to output the preliminary classification results and confidence scores as the final result of the conditional cascade model. If the current input image type is a hard sample, the processing path is to call the auxiliary network branch to extract local features from the input image and call the fusion unit to perform feature fusion and classification analysis on global semantic features and local features, outputting the generated classification results and confidence scores as the final result of the conditional cascade model. Online image reasoning: The system acquires the image to be processed, performs basic standardization on the image to obtain a preprocessed image, uses the preprocessed image as the input image, and performs reasoning analysis through a trained conditional cascade model to output classification results and confidence scores.

[0008] As a preferred option, the basic standardization process includes the following operations: Scale the image to a predetermined size; The image pixel values ​​are normalized and mapped to the [0,1] interval; Image standardization is applied to make pixel values ​​conform to the requirements of the conditional cascade model.

[0009] As a preferred method, multidimensional degradation enhancement processing includes the following operations: Highlight overexposure: Randomly generate bright spots on the image with a Gaussian distribution of decreasing brightness to simulate overexposure degradation in areas directly exposed by a flash. Moiré pattern synthesis: Superimposing sinusoidal stripe noise of a specific frequency onto an image to simulate the ripple artifacts generated by sensor interference; Color perturbation: Randomly adjusts the brightness, contrast, saturation, and hue of the image to simulate complex color shifts caused by the interaction of ambient light and flash. Noise blurring: Apply Gaussian blur to the image to simulate focus misalignment or slight motion blur; Geometric transformations: performing random cropping, flipping, rotation, and scaling operations on images.

[0010] As a preferred approach, for the conditional cascaded model, the main network branch is used for global semantic feature extraction and classification analysis based on pre-trained ResNet50, while the auxiliary network branch is used for local feature extraction based on pre-trained ResNet18. The dynamic decision unit is configured with a threshold, which is used to compare the confidence score of the preliminary classification result output by the main network branch with the threshold. If the confidence score of the current input image is lower than the current threshold, the current input image is marked as a hard sample. The corresponding processing path is as follows: call the auxiliary network branch to extract local features of the current input image, call the fusion unit to concatenate the global semantic features and local features of the current input image, perform nonlinear transformation on the concatenated features through a multilayer perceptron network, and perform classification analysis through a fully connected layer to output the classification result and confidence score. If the confidence score of the current input image is higher than the current threshold, the current input image is marked as a simple sample. The corresponding processing path is as follows: output the preliminary classification result and confidence score output by the main network branch as the final result. During model training, a linearly increasing threshold adjustment strategy is used to adjust the thresholds in the dynamic decision-making unit; During model training, the optimization strategies for conditional cascade models include: A hierarchical learning rate setting is adopted, with a basic learning rate set for the main network branch and the auxiliary network branch, and a higher learning rate set for the feature fusion network. A cosine annealing learning rate scheduling strategy is adopted to dynamically adjust the learning rate during training. The cross-entropy loss function is used to measure the difference between the model prediction and the true label, and the model parameters are optimized through backpropagation.

[0011] As a preferred approach, during online image inference, the trained conditional cascade model is deployed as a service, and the trained conditional cascade model is encapsulated as a callable image processing service. The service receives Base64 encoded image data through a Web service interface, decodes the image data, and sends it into the trained conditional cascade model for inference analysis. The output of the trained conditional cascade model is then encapsulated into a structured data format and returned. Among them, the service-oriented deployment of the trained conditional cascade model supports multiple service frameworks, including the Flask framework for synchronous processing services, the FastAPI framework for asynchronous processing services, and batch image processing, which can simultaneously receive and process recognition requests for multiple images.

[0012] Secondly, the present invention provides a dark environment flash exposure photo processing system, including a data preprocessing module, a model training and optimization module, and an online image inference module; The data preprocessing module performs the following operations: using normally exposed images taken with a flash in a dark environment and copied images as the original images, and labeling them as copied and uncopied images, the original images are subjected to basic standardization and multidimensional degradation enhancement processing respectively. The basic standardization processing is used to perform cropping and normalization operations to obtain the preprocessed image. The multidimensional degradation enhancement processing is used to perform highlight overexposure simulation, moiré synthesis, color perturbation, noise blurring and geometric transformation to generate the enhanced image. The training set is constructed based on the preprocessed image and the enhanced image, and the validation set is constructed based on the original images. The model training and optimization module performs the following: constructing a conditional cascade model, training the conditional cascade model based on the training set, and validating the trained conditional cascade model based on the validation set. The conditional cascade model includes a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. The main network branch is used to extract global features and perform classification analysis on the input image, and outputs preliminary classification results and confidence scores. The dynamic decision unit is used to determine the current input image type and processing path based on the preliminary classification results and confidence scores through a dynamic decision mechanism. If the current input image type is a simple sample, the processing path is to output the preliminary classification results and confidence scores as the final result of the conditional cascade model. If the current input image type is a hard sample, the processing path is to call the auxiliary network branch to extract local features from the input image, and call the fusion unit to perform feature fusion and classification analysis on global semantic features and local features, and output the generated classification results and confidence scores as the final result of the conditional cascade model. The online image inference module performs the following steps: acquiring the image to be processed, performing basic standardization on the image to be processed to obtain a preprocessed image, using the preprocessed image as the input image, performing inference analysis through a trained conditional cascade model, and outputting classification results and confidence scores.

[0013] As a preferred option, the basic standardization process includes the following operations: Scale the image to a predetermined size; The image pixel values ​​are normalized and mapped to the [0,1] interval; Image standardization is applied to make pixel values ​​conform to the requirements of the conditional cascade model.

[0014] As a preferred method, multidimensional degradation enhancement processing includes the following operations: Highlight overexposure: Randomly generate bright spots on the image with a Gaussian distribution of decreasing brightness to simulate overexposure degradation in areas directly exposed by a flash. Moiré pattern synthesis: Superimposing sinusoidal stripe noise of a specific frequency onto an image to simulate the ripple artifacts generated by sensor interference; Color perturbation: Randomly adjusts the brightness, contrast, saturation, and hue of the image to simulate complex color shifts caused by the interaction of ambient light and flash. Noise blurring: Apply Gaussian blur to the image to simulate focus misalignment or slight motion blur; Geometric transformations: performing random cropping, flipping, rotation, and scaling operations on images.

[0015] As a preferred approach, for the conditional cascaded model, the main network branch is used for global semantic feature extraction and classification analysis based on pre-trained ResNet50, while the auxiliary network branch is used for local feature extraction based on pre-trained ResNet18. The dynamic decision unit is configured with a threshold, which is used to compare the confidence score of the preliminary classification result output by the main network branch with the threshold. If the confidence score of the current input image is lower than the current threshold, the current input image is marked as a hard sample. The corresponding processing path is as follows: call the auxiliary network branch to extract local features of the current input image, call the fusion unit to concatenate the global semantic features and local features of the current input image, perform nonlinear transformation on the concatenated features through a multilayer perceptron network, and perform classification analysis through a fully connected layer to output the classification result and confidence score. If the confidence score of the current input image is higher than the current threshold, the current input image is marked as a simple sample. The corresponding processing path is as follows: output the preliminary classification result and confidence score output by the main network branch as the final result. During model training, a linearly increasing threshold adjustment strategy is used to adjust the thresholds in the dynamic decision-making unit; During model training, the optimization strategies for conditional cascade models include: A hierarchical learning rate setting is adopted, with a basic learning rate set for the main network branch and the auxiliary network branch, and a higher learning rate set for the feature fusion network. A cosine annealing learning rate scheduling strategy is adopted to dynamically adjust the learning rate during training. The cross-entropy loss function is used to measure the difference between the model prediction and the true label, and the model parameters are optimized through backpropagation.

[0016] As a preferred embodiment, the online image inference module is used to deploy the trained conditional cascade model as a service, encapsulate the trained conditional cascade model as a callable image processing service, receive Base64 encoded image data through the Web service interface, decode the image data and send it into the trained conditional cascade model for inference analysis, and encapsulate the output of the trained conditional cascade model into a structured data format and return it. Among them, the service-oriented deployment of the trained conditional cascade model supports multiple service frameworks, including the Flask framework for synchronous processing services, the FastAPI framework for asynchronous processing services, and batch image processing, which can simultaneously receive and process recognition requests for multiple images.

[0017] The method and system for processing photos exposed by flash in dark environments according to the present invention have the following advantages: 1. Achieve dynamic allocation of computing resources: Through the cascaded design of the illumination optimization module, the system automatically identifies the complexity of the sample and dynamically adjusts the processing path. Simple samples are processed quickly, while complex samples trigger a three-level processing chain, thereby achieving dynamic allocation of computing resources and avoiding redundant calculations in traditional architectures. 2. Improve the image recognition quality of difficult samples: Low-confidence samples are filtered through the adaptive decision module. For the difficult regions marked by the decision module, operations such as local brightness equalization, color restoration and moiré suppression are performed to output a refined feature map and improve the recognition quality of difficult samples. 3. Adapt to a variety of complex real-world scenarios: During the data preprocessing stage, multi-dimensional degradation enhancement techniques are applied to different scenarios to strengthen the training data and enable the model to adapt to a variety of complex scenarios. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] The invention will be further described below with reference to the accompanying drawings.

[0020] Figure 1 This is a flowchart of a method for processing photos exposed by flash in a dark environment, as described in Example 1. Detailed Implementation

[0021] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.

[0022] This invention provides a method and system for processing photos taken with flash in dark environments, which addresses the significant shortcomings of existing dark environment flash photo processing technologies in terms of efficiency and processing effect, dynamic adaptability, and generalization ability. Example

[0023] This invention provides a method for processing photos taken under flash exposure in dark environments, comprising three steps: data preprocessing, model training and optimization, and online image inference.

[0024] Step S100 Data Preprocessing: Using normally exposed images taken with a flash in a dark environment and copied images as the original images, and labeling them as copied and uncopied images, perform basic standardization and multidimensional degradation enhancement processing on the original images respectively. The basic standardization process involves cropping and normalization to obtain the preprocessed image. The multidimensional degradation enhancement process involves specular overexposure simulation, moiré synthesis, color perturbation, noise blurring, and geometric transformation to generate the enhanced image. A training set is constructed based on the preprocessed and enhanced images, and a validation set is constructed based on the original images.

[0025] As a specific implementation of basic standardization processing, it includes the following operations: (1) Scale the image to a predetermined size; (2) Normalize the image pixel values ​​and map them to the [0,1] interval; (3) Apply image standardization to make the pixel values ​​meet the requirements of the conditional cascade model.

[0026] As a specific implementation of multidimensional degradation enhancement processing, it includes the following operations: (1) Highlight overexposure: Randomly generate bright spots with a Gaussian distribution of brightness decay on the image to simulate the overexposure degradation of the area directly hit by the flash; (2) Moiré pattern synthesis: Sine wave stripe noise of a specific frequency is superimposed on the image to simulate the ripple artifacts generated by sensor interference; (3) Color perturbation: The brightness, contrast, saturation and hue of the image are randomly adjusted to simulate the complex color shift caused by the interaction between ambient light and flash. (4) Noise blurring: Apply Gaussian blur to the image to simulate inaccurate focus or slight motion blur; (5) Geometric transformation: Perform random cropping, flipping, rotation and scaling operations on the image.

[0027] The goal of data preprocessing in this embodiment is to construct a training dataset that fully reflects various degradation characteristics in real-world dark flash photography scenes, enabling the subsequent model to learn robust processing capabilities. In specific applications, the following operations are performed: (1) Input stage: Perform raw data collection, data organization and data labeling. Collect a large number of photos taken with flash in dark environments through raw data collection, including normal exposure and copied images. The data organization is divided into two categories, "copied images" and "uncopied images", which are stored in different directories. The data labeling is to label each image with its category label. (2) Data preprocessing stage: Basic standardization, degradation feature simulation, and training / validation data differentiation are performed. During basic standardization, the image is uniformly scaled to a standard size of 224×224 pixels, and the pixel values ​​are normalized and mapped to the [0,1] interval. Image standardization is applied to make the pixel values ​​meet the input requirements of the deep learning model. During degradation feature simulation (core enhancement strategy), specular overexposure simulation, moiré pattern synthesis, complex color shift injection, and noise and blur processing are performed. During specular overexposure simulation, a spot simulating the direct illumination of a flash lamp is generated at a random position on the image. The brightness of the spot decreases in a Gaussian distribution from the center outwards, and the spot intensity changes randomly within the range of 0.1-0.3 to simulate different degrees of overexposure. During moiré pattern synthesis, sinusoidal stripes of a specific frequency (random frequency within the range of 0.05-0.2) are generated and the stripe noise is superimposed on the original image. The stripe intensity is between 0.1- Within a range of 0.3, random adjustments are made to simulate interference effects of varying intensities. When complex color shifts are injected, the image brightness, contrast, saturation, and hue are randomly adjusted (±25%), simulating color temperature conflicts between ambient light and flash. For noise and blur handling, Gaussian blur is applied to the image with a 30% probability to simulate focus issues or slight motion blur. The image is also randomly rotated (±15 degrees) and vertically flipped with a 30% probability to increase data diversity. The image is randomly scaled (0.9-1.1 times) to simulate changes in shooting distance. During training / validation data differentiation, all the above enhancement strategies are applied to the training set to enhance the model's generalization ability, while the validation set only undergoes basic standardization to avoid data leakage affecting evaluation accuracy. (3) Data partitioning and loading: The entire dataset is randomly divided into training set and validation set in a ratio of 8:2. The training set uses image batches with a batch size of 32, and the validation set uses image batches with a batch size of 64. Multi-threaded data loading is enabled to improve data processing efficiency. (4) Output results: Output a “robust” training dataset that has been fully enhanced and contains various simulated degradation features, and a validation dataset that maintains the original distribution for accurate evaluation. Both datasets have been preprocessed into a standardized format acceptable to the model.

[0028] Step S200: Model Training and Optimization: Construct a conditional cascade model, train the model based on the training set, and validate the trained model based on the validation set. The conditional cascade model includes a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. The main network branch is used to extract global features and perform classification analysis on the input image, outputting preliminary classification results and confidence scores. The dynamic decision unit is used to determine the current input image type and processing path based on the preliminary classification results and confidence scores through a dynamic decision mechanism. If the current input image type is a simple sample, the processing path is to output the preliminary classification results and confidence scores as the final result of the conditional cascade model. If the current input image type is a hard sample, the processing path is to call the auxiliary network branch to extract local features from the input image and call the fusion unit to perform feature fusion and classification analysis on global semantic features and local features, outputting the generated classification results and confidence scores as the final result of the conditional cascade model.

[0029] For the conditional cascaded model, the main network branch is used for global semantic feature extraction and classification analysis based on pre-trained ResNet50, while the auxiliary network branch is used for local feature extraction based on pre-trained ResNet18. The dynamic decision unit is configured with a threshold, which is used to compare the confidence score of the preliminary classification result output by the main network branch with the threshold. If the confidence score of the current input image is lower than the current threshold, the current input image is labeled as a hard sample. The corresponding processing path is: calling the auxiliary network branch to extract local features from the current input image, calling the fusion unit to concatenate the global semantic features and local features corresponding to the current input image, performing a nonlinear transformation on the concatenated features through a multilayer perceptron network, and performing classification analysis through a fully connected layer to output the classification result and confidence score. If the confidence score of the current input image is higher than the current threshold, the current input image is labeled as a simple sample. The corresponding processing path is: outputting the preliminary classification result and confidence score from the main network branch as the final result.

[0030] During model training, a linearly increasing threshold adjustment strategy is used to adjust the thresholds in the dynamic decision-making units. The optimization strategies for the conditional cascade model include: (1) A hierarchical learning rate setting is adopted, with a basic learning rate set for the main network branch and the auxiliary network branch, and a higher learning rate set for the feature fusion network; (2) A cosine annealing learning rate scheduling strategy is adopted to dynamically adjust the learning rate during the training process; (3) The cross-entropy loss function is used to measure the difference between the model prediction and the true label, and the model parameters are optimized through backpropagation.

[0031] In this embodiment, the data prepared in the first stage is used to train a dual-network cascade model with dynamic decision-making capabilities.

[0032] The backbone network uses ResNet50 pre-trained on the ImageNet dataset as the main network, and its last fully connected layer is replaced with a new layer adapted to this task (the output dimension is adjusted to 2). ResNet18 pre-trained on the ImageNet dataset is used as the auxiliary network, and its last fully connected layer is also replaced with a new layer adapted to this task. A small multilayer perceptron network is designed in the fusion unit to fuse the features of the main and auxiliary networks. This network receives 4-dimensional input (2-dimensional probability of the main network + 2-dimensional probability of the auxiliary network), and after processing through a 32-dimensional hidden layer, it outputs the final 2-dimensional classification result.

[0033] In the dynamic decision unit, the threshold is set to an initial threshold of 0.1 and a maximum threshold of 0.4. The threshold adjustment cycle is 50 training rounds. The dynamic adjustment mechanism is as follows: in the first 50 training rounds, the threshold increases linearly from 0.1 to 0.4. After the 50th round, the threshold remains unchanged at the maximum value of 0.4. At the beginning of each training round, a new threshold is calculated based on the current round and updated in the model.

[0034] When training and optimizing the model, the optimizer is configured as follows: The AdamW optimization algorithm is used, with a base learning rate of 0.0001 for the main and auxiliary networks, and a higher learning rate of 0.001 for the fusion network to accelerate the learning of fusion capabilities. The weight decay parameter is set to 0.01 to prevent overfitting. Learning rate scheduling: A cosine annealing learning rate scheduling strategy is adopted. The training period (T_max) is set to the total number of training epochs (default 100), and the minimum learning rate (eta_min) is set to 0.000001. The learning rate is automatically adjusted after each training epoch. The loss function is designed as follows: The cross-entropy loss function is used as the primary loss function, which measures the difference between the model's predictions and the true labels.

[0035] The following operations are involved in the model training process: (1) Data preparation: Obtain training and validation set data loaders from the first stage and deploy the model to available computing devices (GPUs are preferred, followed by CPUs). (2) Training cycle in rounds, training phase (for each training round): update the dynamic threshold of the current round, set the model to training mode, traverse the batch of training data, where, during forward propagation, the input image is passed through the conditional concatenation model to obtain the prediction result, and the cross-entropy loss between the prediction result and the true label is calculated; during backpropagation, the gradient of the loss relative to the model parameters is calculated, the model parameters are updated using the optimizer, and the training loss is recorded once every 10 training steps; (3) Validation phase (after each training round) The following steps are performed: Set the model to evaluation mode, turn off gradient calculation to accelerate the validation process, traverse the validation data batch, forward propagate to obtain the prediction results, calculate the validation loss and accuracy, and record the validation metrics (loss value and accuracy). (4) Learning rate adjustment: Adjust the learning rate according to the cosine annealing strategy; (5) Model saving: Compare the current validation accuracy with the historical best accuracy. If the current accuracy is higher, save the current model as the best model.

[0036] The difficult sample handling mechanism works as follows: During training, the model automatically calculates the confidence score for each sample. Samples with a confidence score below the current threshold are marked as "difficult samples." The corresponding refined processing flow (only for difficult samples) involves feeding difficult samples into an auxiliary network (ResNet18) for secondary processing. The auxiliary network extracts local detail features from these samples. The fusion unit intelligently fuses the preliminary results from the main network with the detail features from the auxiliary network. The fused features are then used through a fully connected layer to generate the final prediction result. The simple sample handling path is as follows: Samples with a confidence score above the threshold are marked as "simple samples." These samples directly use the results from the main network (ResNet50) without requiring processing by the auxiliary network.

[0037] During model training, TensorBoard is used to record key metrics, including training loss, validation loss, and validation accuracy. These visualization tools help analyze the model's training status and convergence.

[0038] Through the above training, a cascaded model with conditional branching capability is output. The model file contains all parameters of the main network, auxiliary network, and fusion network. The training log file records the changes of various indicators during the training process. The best model is saved as a separate file for use in the subsequent inference stage.

[0039] Online image reasoning: The system acquires the image to be processed, performs basic standardization on the image to obtain a preprocessed image, uses the preprocessed image as the input image, and performs reasoning analysis through a trained conditional cascade model to output classification results and confidence scores.

[0040] As a specific implementation of online image inference, the trained conditional cascade model is deployed as a service. This model is encapsulated as a callable image processing service, receiving Base64-encoded image data via a web service interface. The decoded image data is then fed into the trained conditional cascade model for inference analysis. The output of the trained conditional cascade model is then encapsulated in a structured data format and returned. The service deployment of the trained conditional cascade model supports multiple service frameworks, including Flask for synchronous processing and FastAPI for asynchronous processing. It also supports batch image processing, capable of simultaneously receiving and processing recognition requests for multiple images.

[0041] This embodiment of online image inference applies the trained model to actual dark environment flash photography to be processed. The core processing steps are as follows: (1) Image Decoding and Standardization: Receive the encoded image data, perform Base64 decoding, convert the decoded byte data into an image matrix, convert the image into RGB format, ensure the color channels are correct, scale the image to a standard size of 224×224 pixels, and normalize and standardize the pixel values. (2) Cascaded model inference: The preprocessed image is input into the trained conditional cascaded model. The model first uses the main network branch to quickly analyze the image and generate preliminary classification results and confidence scores. The built-in dynamic decision module determines whether the image belongs to "hard sample" based on the confidence score output by the main network and the current threshold. If it is a simple sample (confidence score higher than the threshold), the analysis result of the main network is returned directly. If it is a hard sample (confidence score lower than the threshold), the auxiliary network branch is automatically activated to perform secondary refined analysis on the image and the features of the two networks are fused to output the final result. (3) Result generation: The model outputs the final classification label ("reproduced image" or "unreproduced image"), and at the same time outputs the model's confidence score for the judgment (probability value between 0 and 1).

[0042] The image processing results, including the classification category and the model's confidence score for the judgment, are returned in a structured data format for easy subsequent processing or display.

[0043] In this embodiment, the core processing capabilities are encapsulated into a remotely invoked service. HTTP requests from clients (such as web front-ends or mobile applications) contain Base64-encoded data of the image to be recognized in the request body. Core processing steps: (1) API Reception: POST requests are received through predefined API endpoints (such as / recognize), supporting two service frameworks: Flask (traditional synchronous) and FastAPI (modern asynchronous). (2) Request parsing: Parses the HTTP request header and body, extracts JSON format data from the request body, and obtains the Base64 encoded string of the image from the JSON data. It supports batch processing and can receive the encoded data of multiple images simultaneously. (3) Call the processing engine: Create a singleton instance of the image processing engine to ensure efficient use of resources, and pass the extracted image data into the "online image reasoning and processing" engine described in the third stage. The engine performs a complete processing flow for each image. (4) Response encapsulation: Receive the results (category and confidence level) returned by the processing engine, encapsulate the results into a standardized JSON data format, add status codes and possible error messages, and set appropriate HTTP response headers.

[0044] The HTTP response returned to the client after the above steps is a structured JSON object containing the following fields: code: Status code (200 indicates success, others indicate error). res: List of recognition results (category labels for each image). proba: a list of confidence levels (the predicted probability for each image). message: Optional error or status information The response format facilitates client integration and result display.

[0045] The method in this embodiment performs preliminary processing on the input image using a ResNet light-sensing cascade model, and only calls secondary models and lighting optimization modules for fine processing when necessary, achieving a balance between efficiency and processing accuracy. While ensuring image quality, it reduces computation, making it particularly suitable for resource-constrained edge computing scenarios, and providing an efficient and reliable solution for photo processing in dark environments.

[0046] Example 2: The present invention provides a system for processing photos taken under flash exposure in dark environments, comprising a data preprocessing module, a model training and optimization module, and an online image inference module.

[0047] The data preprocessing module performs the following operations: using normally exposed images taken with a flash in a dark environment and copied images as the original images, and labeling them as copied and uncopied images, the original images are subjected to basic standardization and multidimensional degradation enhancement processing respectively. The basic standardization process involves cropping and normalization to obtain the preprocessed image. The multidimensional degradation enhancement process involves specular overexposure simulation, moiré synthesis, color perturbation, noise blurring, and geometric transformation to generate the enhanced image. A training set is constructed based on the preprocessed and enhanced images, and a validation set is constructed based on the original images.

[0048] As a specific implementation of basic standardization processing, it includes the following operations: (1) Scale the image to a predetermined size; (2) Normalize the image pixel values ​​and map them to the [0,1] interval; (3) Apply image standardization to make the pixel values ​​meet the requirements of the conditional cascade model.

[0049] As a specific implementation of multidimensional degradation enhancement processing, it includes the following operations: (1) Highlight overexposure: Randomly generate bright spots with a Gaussian distribution of brightness decay on the image to simulate the overexposure degradation of the area directly hit by the flash; (2) Moiré pattern synthesis: Sine wave stripe noise of a specific frequency is superimposed on the image to simulate the ripple artifacts generated by sensor interference; (3) Color perturbation: The brightness, contrast, saturation and hue of the image are randomly adjusted to simulate the complex color shift caused by the interaction between ambient light and flash. (4) Noise blurring: Apply Gaussian blur to the image to simulate inaccurate focus or slight motion blur; (5) Geometric transformation: Perform random cropping, flipping, rotation and scaling operations on the image.

[0050] The goal of data preprocessing in this embodiment is to construct a training dataset that fully reflects various degradation characteristics in real-world dark flash photography scenes, enabling the subsequent model to learn robust processing capabilities. In specific applications, this module performs the following operations: (1) Input stage: Perform raw data collection, data organization and data labeling. Collect a large number of photos taken with flash in dark environments through raw data collection, including normal exposure and copied images. The data organization is divided into two categories, "copied images" and "uncopied images", which are stored in different directories. The data labeling is to label each image with its category label. (2) Data preprocessing stage: Basic standardization, degradation feature simulation, and training / validation data differentiation are performed. During basic standardization, the image is uniformly scaled to a standard size of 224×224 pixels, and the pixel values ​​are normalized and mapped to the [0,1] interval. Image standardization is applied to make the pixel values ​​meet the input requirements of the deep learning model. During degradation feature simulation (core enhancement strategy), specular overexposure simulation, moiré pattern synthesis, complex color shift injection, and noise and blur processing are performed. During specular overexposure simulation, a spot simulating the direct illumination of a flash lamp is generated at a random position on the image. The brightness of the spot decreases in a Gaussian distribution from the center outwards, and the spot intensity changes randomly within the range of 0.1-0.3 to simulate different degrees of overexposure. During moiré pattern synthesis, sinusoidal stripes of a specific frequency (random frequency within the range of 0.05-0.2) are generated and the stripe noise is superimposed on the original image. The stripe intensity is between 0.1- Within a range of 0.3, random adjustments are made to simulate interference effects of varying intensities. When complex color shifts are injected, the image brightness, contrast, saturation, and hue are randomly adjusted (±25%), simulating color temperature conflicts between ambient light and flash. For noise and blur handling, Gaussian blur is applied to the image with a 30% probability to simulate focus issues or slight motion blur. The image is also randomly rotated (±15 degrees) and vertically flipped with a 30% probability to increase data diversity. The image is randomly scaled (0.9-1.1 times) to simulate changes in shooting distance. During training / validation data differentiation, all the above enhancement strategies are applied to the training set to enhance the model's generalization ability, while the validation set only undergoes basic standardization to avoid data leakage affecting evaluation accuracy. (3) Data partitioning and loading: The entire dataset is randomly divided into training set and validation set in a ratio of 8:2. The training set uses image batches with a batch size of 32, and the validation set uses image batches with a batch size of 64. Multi-threaded data loading is enabled to improve data processing efficiency. (4) Output results: Output a “robust” training dataset that has been fully enhanced and contains various simulated degradation features, and a validation dataset that maintains the original distribution for accurate evaluation. Both datasets have been preprocessed into a standardized format acceptable to the model.

[0051] The model training and optimization module performs the following: constructing a conditional cascade model, training the conditional cascade model based on the training set, and validating the trained conditional cascade model based on the validation set. The conditional cascade model includes a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. The main network branch performs global feature extraction and classification analysis on the input image, outputting preliminary classification results and confidence scores. The dynamic decision unit determines the current input image type and processing path based on the preliminary classification results and confidence scores through a dynamic decision mechanism. If the current input image type is a simple sample, the processing path is to output the preliminary classification results and confidence scores as the final result of the conditional cascade model. If the current input image type is a hard sample, the processing path is to call the auxiliary network branch to extract local features from the input image and call the fusion unit to perform feature fusion and classification analysis on global semantic features and local features, outputting the generated classification results and confidence scores as the final result of the conditional cascade model.

[0052] For the conditional cascaded model, the main network branch is used for global semantic feature extraction and classification analysis based on pre-trained ResNet50, while the auxiliary network branch is used for local feature extraction based on pre-trained ResNet18. The dynamic decision unit is configured with a threshold, which is used to compare the confidence score of the preliminary classification result output by the main network branch with the threshold. If the confidence score of the current input image is lower than the current threshold, the current input image is labeled as a hard sample. The corresponding processing path is: calling the auxiliary network branch to extract local features from the current input image, calling the fusion unit to concatenate the global semantic features and local features corresponding to the current input image, performing a nonlinear transformation on the concatenated features through a multilayer perceptron network, and performing classification analysis through a fully connected layer to output the classification result and confidence score. If the confidence score of the current input image is higher than the current threshold, the current input image is labeled as a simple sample. The corresponding processing path is: outputting the preliminary classification result and confidence score from the main network branch as the final result.

[0053] During model training, a linearly increasing threshold adjustment strategy is used to adjust the thresholds in the dynamic decision-making units. The optimization strategies for the conditional cascade model include: (1) A hierarchical learning rate setting is adopted, with a basic learning rate set for the main network branch and the auxiliary network branch, and a higher learning rate set for the feature fusion network; (2) A cosine annealing learning rate scheduling strategy is adopted to dynamically adjust the learning rate during the training process; (3) The cross-entropy loss function is used to measure the difference between the model prediction and the true label, and the model parameters are optimized through backpropagation.

[0054] In this embodiment, the data prepared in the first stage is used to train a dual-network cascade model with dynamic decision-making capabilities.

[0055] The backbone network uses ResNet50 pre-trained on the ImageNet dataset as the main network, and its last fully connected layer is replaced with a new layer adapted to this task (the output dimension is adjusted to 2). ResNet18 pre-trained on the ImageNet dataset is used as the auxiliary network, and its last fully connected layer is also replaced with a new layer adapted to this task. A small multilayer perceptron network is designed in the fusion unit to fuse the features of the main and auxiliary networks. This network receives 4-dimensional input (2-dimensional probability of the main network + 2-dimensional probability of the auxiliary network), and after processing through a 32-dimensional hidden layer, it outputs the final 2-dimensional classification result.

[0056] In the dynamic decision unit, the threshold is set to an initial threshold of 0.1 and a maximum threshold of 0.4. The threshold adjustment cycle is 50 training rounds. The dynamic adjustment mechanism is as follows: in the first 50 training rounds, the threshold increases linearly from 0.1 to 0.4. After the 50th round, the threshold remains unchanged at the maximum value of 0.4. At the beginning of each training round, a new threshold is calculated based on the current round and updated in the model.

[0057] When training and optimizing the model, the optimizer is configured as follows: The AdamW optimization algorithm is used, with a base learning rate of 0.0001 for the main and auxiliary networks, and a higher learning rate of 0.001 for the fusion network to accelerate the learning of fusion capabilities. The weight decay parameter is set to 0.01 to prevent overfitting. Learning rate scheduling: A cosine annealing learning rate scheduling strategy is adopted. The training period (T_max) is set to the total number of training epochs (default 100), and the minimum learning rate (eta_min) is set to 0.000001. The learning rate is automatically adjusted after each training epoch. The loss function is designed as follows: The cross-entropy loss function is used as the primary loss function, which measures the difference between the model's predictions and the true labels.

[0058] The following operations are involved in the model training process: (1) Data preparation: Obtain training and validation set data loaders from the first stage and deploy the model to available computing devices (GPUs are preferred, followed by CPUs). (2) Training cycle in rounds, training phase (for each training round): update the dynamic threshold of the current round, set the model to training mode, traverse the batch of training data, where, during forward propagation, the input image is passed through the conditional concatenation model to obtain the prediction result, and the cross-entropy loss between the prediction result and the true label is calculated; during backpropagation, the gradient of the loss relative to the model parameters is calculated, the model parameters are updated using the optimizer, and the training loss is recorded once every 10 training steps; (3) Validation phase (after each training round) The following steps are performed: Set the model to evaluation mode, turn off gradient calculation to accelerate the validation process, traverse the validation data batch, forward propagate to obtain the prediction results, calculate the validation loss and accuracy, and record the validation metrics (loss value and accuracy). (4) Learning rate adjustment: Adjust the learning rate according to the cosine annealing strategy; (5) Model saving: Compare the current validation accuracy with the historical best accuracy. If the current accuracy is higher, save the current model as the best model.

[0059] The difficult sample handling mechanism works as follows: During training, the model automatically calculates the confidence score for each sample. Samples with a confidence score below the current threshold are marked as "difficult samples." The corresponding refined processing flow (only for difficult samples) involves feeding difficult samples into an auxiliary network (ResNet18) for secondary processing. The auxiliary network extracts local detail features from these samples. The fusion unit intelligently fuses the preliminary results from the main network with the detail features from the auxiliary network. The fused features are then used through a fully connected layer to generate the final prediction result. The simple sample handling path is as follows: Samples with a confidence score above the threshold are marked as "simple samples." These samples directly use the results from the main network (ResNet50) without requiring processing by the auxiliary network.

[0060] During model training, TensorBoard is used to record key metrics, including training loss, validation loss, and validation accuracy. These visualization tools help analyze the model's training status and convergence.

[0061] Through the above training, a cascaded model with conditional branching capability is output. The model file contains all parameters of the main network, auxiliary network, and fusion network. The training log file records the changes of various indicators during the training process. The best model is saved as a separate file for use in the subsequent inference stage.

[0062] The online image inference module performs the following steps: acquiring the image to be processed, performing basic standardization on the image to be processed to obtain a preprocessed image, using the preprocessed image as the input image, performing inference analysis through a trained conditional cascade model, and outputting classification results and confidence scores.

[0063] As a specific implementation of the online image inference module, this module deploys the trained conditional cascade model as a service, encapsulating it into a callable image processing service. It receives Base64-encoded image data via a web service interface, decodes the image data, and feeds it into the trained conditional cascade model for inference analysis. The output of the trained conditional cascade model is then encapsulated in a structured data format and returned. The service deployment of the trained conditional cascade model supports multiple service frameworks, including Flask for synchronous processing and FastAPI for asynchronous processing. It also supports batch image processing, capable of simultaneously receiving and processing recognition requests for multiple images.

[0064] This embodiment of online image inference applies the trained model to actual dark environment flash photography to be processed. The core processing steps are as follows: (1) Image Decoding and Standardization: Receive the encoded image data, perform Base64 decoding, convert the decoded byte data into an image matrix, convert the image into RGB format, ensure the color channels are correct, scale the image to a standard size of 224×224 pixels, and normalize and standardize the pixel values. (2) Cascaded model inference: The preprocessed image is input into the trained conditional cascaded model. The model first uses the main network branch to quickly analyze the image and generate preliminary classification results and confidence scores. The built-in dynamic decision module determines whether the image belongs to "hard sample" based on the confidence score output by the main network and the current threshold. If it is a simple sample (confidence score higher than the threshold), the analysis result of the main network is returned directly. If it is a hard sample (confidence score lower than the threshold), the auxiliary network branch is automatically activated to perform secondary refined analysis on the image and the features of the two networks are fused to output the final result. (3) Result generation: The model outputs the final classification label ("reproduced image" or "unreproduced image"), and at the same time outputs the model's confidence score for the judgment (probability value between 0 and 1).

[0065] The image processing results, including the classification category and the model's confidence score for the judgment, are returned in a structured data format for easy subsequent processing or display.

[0066] In this embodiment, the core processing capabilities are encapsulated into a remotely invoked service. HTTP requests from clients (such as web front-ends or mobile applications) contain Base64-encoded data of the image to be recognized in the request body. Core processing steps: (1) API Reception: POST requests are received through predefined API endpoints (such as / recognize), supporting two service frameworks: Flask (traditional synchronous) and FastAPI (modern asynchronous). (2) Request parsing: Parses the HTTP request header and body, extracts JSON format data from the request body, and obtains the Base64 encoded string of the image from the JSON data. It supports batch processing and can receive the encoded data of multiple images simultaneously. (3) Call the processing engine: Create a singleton instance of the image processing engine to ensure efficient use of resources, and pass the extracted image data into the "online image reasoning and processing" engine described in the third stage. The engine performs a complete processing flow for each image. (4) Response encapsulation: Receive the results (category and confidence level) returned by the processing engine, encapsulate the results into a standardized JSON data format, add status codes and possible error messages, and set appropriate HTTP response headers.

[0067] The HTTP response returned to the client after the above steps is a structured JSON object containing the following fields: code: Status code (200 indicates success, others indicate error). res: List of recognition results (category labels for each image). proba: a list of confidence levels (the predicted probability for each image). message: Optional error or status information The response format facilitates client integration and result display.

[0068] The system in this embodiment can execute the method disclosed in Embodiment 1 to process flash photos in dark environments. The above provides a detailed description of the method and system for processing photos exposed by flash in dark environments provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for processing flash-exposed photographs in dark environments, characterized in that, Includes the following steps: Data preprocessing: Normal exposure images taken with a flash in a dark environment and copied images are used as the original images. The copied images and uncopied images are labeled. Basic standardization and multidimensional degradation enhancement processing are performed on the original images respectively. The basic standardization process is followed by cropping and normalization to obtain the preprocessed image. The multidimensional degradation enhancement process is followed by highlight overexposure simulation, moiré synthesis, color perturbation, noise blurring and geometric transformation to generate the enhanced image. The training set is constructed based on the preprocessed image and the enhanced image, and the validation set is constructed based on the original images. Model Training and Optimization: A conditional cascade model is constructed. The model is trained on the training set and validated on the validation set. The conditional cascade model includes a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. The main network branch is used to extract global features and perform classification analysis on the input image, outputting preliminary classification results and confidence scores. The dynamic decision unit is used to determine the current input image type and processing path based on the preliminary classification results and confidence scores through a dynamic decision mechanism. If the current input image type is a simple sample, the processing path is to output the preliminary classification results and confidence scores as the final result of the conditional cascade model. If the current input image type is a hard sample, the processing path is to call the auxiliary network branch to extract local features from the input image and call the fusion unit to perform feature fusion and classification analysis on global semantic features and local features, outputting the generated classification results and confidence scores as the final result of the conditional cascade model. Online image reasoning: The system acquires the image to be processed, performs basic standardization on the image to obtain a preprocessed image, uses the preprocessed image as the input image, and performs reasoning analysis through a trained conditional cascade model to output classification results and confidence scores.

2. The method for processing photos exposed by flash in dark environments according to claim 1, characterized in that, Basic standardization processing includes the following operations: Scale the image to a predetermined size; The image pixel values ​​are normalized and mapped to the [0,1] interval; Image standardization is applied to make pixel values ​​conform to the requirements of the conditional cascade model.

3. The method for processing photos exposed by flash in dark environments according to claim 1, characterized in that, Multidimensional degradation enhancement processing includes the following operations: Highlight overexposure: Randomly generate bright spots on the image with a Gaussian distribution of decreasing brightness to simulate overexposure degradation in areas directly exposed by a flash. Moiré pattern synthesis: Superimposing sinusoidal stripe noise of a specific frequency onto an image to simulate the ripple artifacts generated by sensor interference; Color perturbation: Randomly adjusts the brightness, contrast, saturation, and hue of the image to simulate complex color shifts caused by the interaction of ambient light and flash. Noise blurring: Apply Gaussian blur to the image to simulate focus misalignment or slight motion blur; Geometric transformations: performing random cropping, flipping, rotation, and scaling operations on images.

4. The method for processing photos exposed by flash in dark environments according to claim 1, characterized in that, For the conditional cascaded model, the main network branch is used for global semantic feature extraction and classification analysis based on the pre-trained ResNet50, and the auxiliary network branch is used for local feature extraction based on the pre-trained ResNet18. The dynamic decision unit is configured with a threshold, which is used to compare the confidence score of the preliminary classification result output by the main network branch with the threshold. If the confidence score of the current input image is lower than the current threshold, the current input image is marked as a hard sample. The corresponding processing path is as follows: call the auxiliary network branch to extract local features of the current input image, call the fusion unit to concatenate the global semantic features and local features of the current input image, perform nonlinear transformation on the concatenated features through a multilayer perceptron network, and perform classification analysis through a fully connected layer to output the classification result and confidence score. If the confidence score of the current input image is higher than the current threshold, the current input image is marked as a simple sample. The corresponding processing path is as follows: output the preliminary classification result and confidence score output by the main network branch as the final result. During model training, a linearly increasing threshold adjustment strategy is used to adjust the thresholds in the dynamic decision-making unit; During model training, the optimization strategies for conditional cascade models include: A hierarchical learning rate setting is adopted, with a basic learning rate set for the main network branch and the auxiliary network branch, and a higher learning rate set for the feature fusion network. A cosine annealing learning rate scheduling strategy is adopted to dynamically adjust the learning rate during training. The cross-entropy loss function is used to measure the difference between the model prediction and the true label, and the model parameters are optimized through backpropagation.

5. The method for processing photos exposed by flash in dark environments according to claim 1, characterized in that, During online image inference, the trained conditional cascade model is deployed as a service, and the trained conditional cascade model is encapsulated as a callable image processing service. It receives Base64 encoded image data through a Web service interface, decodes the image data and sends it into the trained conditional cascade model for inference analysis, and encapsulates the output of the trained conditional cascade model into a structured data format and returns it. Among them, the service-oriented deployment of the trained conditional cascade model supports multiple service frameworks, including the Flask framework for synchronous processing services, the FastAPI framework for asynchronous processing services, and batch image processing, which can simultaneously receive and process recognition requests for multiple images.

6. A system for processing photos taken under flash exposure in dark environments, characterized in that, It includes a data preprocessing module, a model training and optimization module, and an online image inference module; The data preprocessing module performs the following operations: using normally exposed images taken with a flash in a dark environment and copied images as the original images, and labeling them as copied and uncopied images, the original images are subjected to basic standardization and multidimensional degradation enhancement processing respectively. The basic standardization processing is used to perform cropping and normalization operations to obtain the preprocessed image. The multidimensional degradation enhancement processing is used to perform highlight overexposure simulation, moiré synthesis, color perturbation, noise blurring and geometric transformation to generate the enhanced image. The training set is constructed based on the preprocessed image and the enhanced image, and the validation set is constructed based on the original images. The model training and optimization module performs the following: constructing a conditional cascade model, training the conditional cascade model based on the training set, and validating the trained conditional cascade model based on the validation set. The conditional cascade model includes a main network branch, an auxiliary network branch, a dynamic decision unit, and a fusion unit. The main network branch is used to extract global features and perform classification analysis on the input image, and outputs preliminary classification results and confidence scores. The dynamic decision unit is used to determine the current input image type and processing path based on the preliminary classification results and confidence scores through a dynamic decision mechanism. If the current input image type is a simple sample, the processing path is to output the preliminary classification results and confidence scores as the final result of the conditional cascade model. If the current input image type is a hard sample, the processing path is to call the auxiliary network branch to extract local features from the input image, and call the fusion unit to perform feature fusion and classification analysis on global semantic features and local features, and output the generated classification results and confidence scores as the final result of the conditional cascade model. The online image inference module performs the following steps: acquiring the image to be processed, performing basic standardization on the image to be processed to obtain a preprocessed image, using the preprocessed image as the input image, performing inference analysis through a trained conditional cascade model, and outputting classification results and confidence scores.

7. The dark environment flash exposure photo processing system according to claim 6, characterized in that, Basic standardization processing includes the following operations: Scale the image to a predetermined size; The image pixel values ​​are normalized and mapped to the [0,1] interval; Image standardization is applied to make pixel values ​​conform to the requirements of the conditional cascade model.

8. The dark environment flash exposure photo processing system according to claim 6, characterized in that, Multidimensional degradation enhancement processing includes the following operations: Highlight overexposure: Randomly generate bright spots on the image with a Gaussian distribution of decreasing brightness to simulate overexposure degradation in areas directly exposed by a flash. Moiré pattern synthesis: Superimposing sinusoidal stripe noise of a specific frequency onto an image to simulate the ripple artifacts generated by sensor interference; Color perturbation: Randomly adjusts the brightness, contrast, saturation, and hue of the image to simulate complex color shifts caused by the interaction of ambient light and flash. Noise blurring: Apply Gaussian blur to the image to simulate focus misalignment or slight motion blur; Geometric transformations: performing random cropping, flipping, rotation, and scaling operations on images.

9. The dark environment flash exposure photo processing system according to claim 6, characterized in that, For the conditional cascaded model, the main network branch is used for global semantic feature extraction and classification analysis based on the pre-trained ResNet50, and the auxiliary network branch is used for local feature extraction based on the pre-trained ResNet18. The dynamic decision unit is configured with a threshold, which is used to compare the confidence score of the preliminary classification result output by the main network branch with the threshold. If the confidence score of the current input image is lower than the current threshold, the current input image is marked as a hard sample. The corresponding processing path is as follows: call the auxiliary network branch to extract local features of the current input image, call the fusion unit to concatenate the global semantic features and local features of the current input image, perform nonlinear transformation on the concatenated features through a multilayer perceptron network, and perform classification analysis through a fully connected layer to output the classification result and confidence score. If the confidence score of the current input image is higher than the current threshold, the current input image is marked as a simple sample. The corresponding processing path is as follows: output the preliminary classification result and confidence score output by the main network branch as the final result. During model training, a linearly increasing threshold adjustment strategy is used to adjust the thresholds in the dynamic decision-making unit; During model training, the optimization strategies for conditional cascade models include: A hierarchical learning rate setting is adopted, with a basic learning rate set for the main network branch and the auxiliary network branch, and a higher learning rate set for the feature fusion network. A cosine annealing learning rate scheduling strategy is adopted to dynamically adjust the learning rate during training. The cross-entropy loss function is used to measure the difference between the model prediction and the true label, and the model parameters are optimized through backpropagation.

10. The dark environment flash exposure photo processing system according to claim 6, characterized in that, The online image inference module is used to deploy the trained conditional cascade model as a service. It encapsulates the trained conditional cascade model into a callable image processing service, receives Base64 encoded image data through a Web service interface, decodes the image data and sends it into the trained conditional cascade model for inference analysis, and encapsulates the output of the trained conditional cascade model into a structured data format and returns it. Among them, the service-oriented deployment of the trained conditional cascade model supports multiple service frameworks, including the Flask framework for synchronous processing services, the FastAPI framework for asynchronous processing services, and batch image processing, which can simultaneously receive and process recognition requests for multiple images.