An ancient character restoration method based on a fusion semantic guided diffusion model

CN122905899APending Publication Date: 2026-10-13HENAN NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611064179.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-17
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

其次,为了解决修复过程中的结构失真问题,本发明设计了跨样本结构检索机制(Mb)

Benefits of technology

[0021]与现有技术相比,本发明的有益效果是:本发明通过对扩散模型的约束机制与损失体系进行深度重构,使其能够精准适配古文字的拓扑特征与语义属性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122905899A_ABST
    Figure CN122905899A_ABST
Patent Text Reader

Abstract

The application discloses an ancient character repairing method based on a fusion semantic guidance diffusion model, relates to the field of ancient character repairing, and aims to solve the problems of semantic deviation, geometric distortion and weak generalization ability of a repairing result in the prior art. The technical scheme is that a diffusion repairing model fusing semantic consistency, structure prior and manifold constraint is constructed, time and semantic category vectors are embedded in a U-Net architecture, and semantic consistency is enhanced through auxiliary cross-entropy supervision; a cross-sample structure retrieval mechanism based on K nearest neighbors is introduced in the inverse diffusion process, structure prior is obtained from a complete handwriting body to provide morphological support, cross-modal structure knowledge migration is realized, a manifold geometry constraint based on isometric mapping is introduced in the training stage, feature space geometry consistency is maintained and deformation and noise interference are inhibited, the accuracy of a character shape is ensured, and the structure clarity and accuracy of a repairing result are improved through a dynamic weight joint loss.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of ancient script restoration technology, specifically to an ancient script restoration method based on a fusion semantic guided diffusion model. Background Technology

[0002] Most extant oracle bone inscriptions are preserved in the form of rubbings. However, during thousands of years of preservation and transmission, due to the aging of the original materials, environmental erosion, and differences in rubbing techniques, these rubbings generally suffer from severe degradation problems such as broken strokes, missing structures, background contamination, and complex noise superposition (such as cracks and corrosion textures). These factors damage the structural integrity of the characters, greatly hindering subsequent automatic identification and academic interpretation. Therefore, how to systematically restore damaged oracle bone fragments has become an important area of ​​interdisciplinary research encompassing paleography, archaeological conservation, and cultural heritage restoration.

[0003] In recent years, digital restoration technology centered on deep learning has made significant progress. From early two-stage generative adversarial networks (GANs) to end-to-end restoration frameworks incorporating spatial attention mechanisms, researchers have attempted to improve restoration accuracy through the collaborative capture of global and local information. Subsequently, diffusion models, with their superior inverse generation and reconstruction capabilities, have demonstrated even greater potential in oracle bone script restoration tasks. Examples include lightweight solutions combining Visual State Space (VSS) modules, the OBIFormer glyph extraction module incorporating channel self-attention, and collaborative restoration networks based on large-kernel convolutional attention mechanisms.

[0004] The following paper discloses a structure-aware diffusion model (SADM): Zhang, Y., Han, A., Wang, S., Liu, J., Li, X., Liu, D.,&Cen, Y.(2025). Generating oracle bone inscriptions based on the structure awarediffusion model. npj Heritage Science, 13(1), 461. The infrastructure of this solution is as follows: Figure 1As shown, its main implementation logic is as follows: 1) Data preprocessing and degradation simulation: retain the original rubbing features, apply deterministic transformations such as Gaussian mask to preprocess the oracle bone image, and construct simulated degradation samples; 2) Multi-step iterative sampling reconstruction: use the U-Net structure as the core backbone, execute the image reconstruction sampling algorithm (OBS) in the inverse diffusion stage, and gradually recover the oracle bone prediction image from the noise or mask state through multi-step iteration; 3) Dynamic perceptual loss function constraint: integrate perceptual loss (Perceptual Loss), absolute error loss (L1) and structural similarity loss (SSIM), and combine with an adaptive dynamic adjustment mechanism to adjust the weights of each item in the training stage to balance detail generation and pixel reconstruction.

[0005] Although the aforementioned diffusion-based methods have demonstrated restoration capabilities in processing oracle bone script images, they still face the following bottlenecks in oracle bone script restoration tasks: - Difficulty in preserving structural details: Oracle bone script strokes are delicate and varied. When removing complex coupling noise (such as erosion textures), existing models often have difficulty distinguishing between effective structure and interference noise, resulting in the loss of fine structure. - Lack of topological consistency: Due to the lack of an effective geometric structure constraint mechanism, the restoration results are prone to unreasonable deformation or breakage in topological logic, which cannot meet the accuracy requirements of ancient script research. - Weak cross-domain generalization ability: There are obvious differences in style and degradation distribution between oracle bone rubbings and standard handwriting. Existing methods are unable to effectively utilize structurally complete prior knowledge to assist in the reconstruction of highly degraded images.

[0006] A common problem with existing repair methods, including SADM, is that: - Insufficient structural and semantic modeling capabilities: Existing methods usually focus on the continuity or visual smoothness of local pixels, lacking deep semantic constraints on the specific glyphs of oracle bone script; when faced with severe degradation (such as missing key strokes), the model has difficulty using semantic information to guide the repair, resulting in semantic deviations or stroke errors in the generated results. - Lack of effective external prior guidance: Current restoration logic relies heavily on the residual information of the input image itself and fails to make full use of external expert knowledge such as structurally intact standard handwritten characters; this makes it impossible for the model to obtain reliable "morphological support" when dealing with highly degraded and large-area damaged rubbings, resulting in a lack of standardization in the restoration results; -Feature space geometric distortion: Traditional loss functions (such as pixel loss and perceptual loss) ignore the manifold distribution of data in high-dimensional space; during the denoising and reconstruction process, the model has difficulty maintaining the local geometric consistency of character features, which often leads to unreasonable topological deformation, stroke adhesion or structural collapse of the repaired characters. - Weak generalization ability across data distributions: Due to the huge modal differences between rubbing data and handwritten data, existing models show obvious instability when applied across datasets and are difficult to adapt to diverse archaeological digitization scenarios. Summary of the Invention

[0007] To address the aforementioned issues, this invention proposes a diffusion model framework (MGK-DM) that integrates semantic guidance, structural priors, and manifold constraints for high-quality generation and structural reconstruction of oracle bone inscriptions. First, this invention introduces category embedding and assisted classification supervision (CE) into the diffusion generation framework. By directly injecting semantic features into the diffusion process, it enhances the model's semantic modeling ability for specific character forms, ensuring that the restoration results possess rigorous semantic consistency while satisfying visual reconstruction requirements. Second, to solve the structural distortion problem during the restoration process, this invention designs a cross-sample structure retrieval mechanism (Mb). By constructing an offline structure prior library and combining it with KNN retrieval technology, high-fidelity handwritten features are used to provide explicit structural references for rubbing restoration, guiding the model to automatically complete missing strokes using a more standardized technical path. Finally, this invention proposes the Isomap manifold geometric consistency constraint method (Iso). By calculating the geodesic distance in the feature space and constructing a manifold geometric consistency loss, the feature distribution is regularized in both global and local dimensions, ensuring that the generated results maintain a geometric layout similar to the real samples on the nonlinear manifold, effectively solving the common problems of topological distortion and structural ambiguity in existing methods.

[0008] To achieve the above objectives, this invention discloses a method for ancient character restoration based on a fusion semantic-guided diffusion model. The technical solution adopted includes the following steps: Step 1, Image Input and Preprocessing Input a single-character image of the text to be restored, and perform standardization processing on the image to obtain the preprocessed ancient character image. ; Step 2, deterministic degradation modeling, The preprocessed ancient character image obtained in step 1 The degraded image is obtained by performing progressive convolution degradation locally using an adaptive Gaussian kernel G. To simulate the structural blurring and loss of detail caused by real weathering; Step 3, Multi-scale feature modeling and prior injection, Degraded image Time embedding and category conditions In the U-Net architecture model guided by semantic fusion and common input, degraded images are iteratively learned through an inverse diffusion process. Compared with preprocessed ancient script images The correspondence; In each iterative learning step, intermediate layer features of the current sample are extracted, and K standard handwritten features are obtained through the constructed offline structural memory. Subsequently, the retrieved standard handwritten features are constructed into a graph topology, and the topological relationships in the feature space before and after restoration are kept consistent through manifold constraints. This injects structural priors into the inverse diffusion process, providing additional geometric structural references for broken strokes, blurred edges, and missing areas, guiding the network to generate restoration results that conform to the rules of ancient Chinese character shapes. After the iteration is completed, the reconstructed image is obtained. .

[0009] As a preferred embodiment of the present invention, the U-Net architecture model with fused semantic guidance includes an encoder and a decoder, the encoder and the decoder being skip-connected, and the encoder having a bottleneck layer at its end; the time steps are... The sinusoidal position encoding is mapped to a multilayer perceptron to form a temporal embedding vector. This is used to characterize the noise intensity at different stages; character category labels are used. Mapped to class embedding vectors through learnable embedding layers. This is used to represent the category attributes and structural priors of characters; the temporal embedding vector and the category embedding vector are integrated into a conditional vector through element-wise addition. Then, it is injected as a global modulation signal into each stage of Conditioned ConvNeXt Block; An auxiliary supervision system is connected between the bottleneck layer and the decoder. This system includes an auxiliary supervision mechanism and a topological manifold constraint branch. The auxiliary supervision mechanism remains active during both training and inference phases, and it comprises a sequentially connected global average pooling layer, a flattening layer, and a fully connected layer, outputting a class prediction. The topological manifold constraint branch is a training branch that is activated only during the training phase. It includes an offline structure memory, a KNN retrieval module, and a manifold constraint module. The offline structure memory is connected to the KNN retrieval module and is used to provide lossless standard topological priors. The output of the KNN retrieval module is the input auxiliary supervision system of the manifold constraint module.

[0010] As a preferred embodiment of the present invention, the method for constructing the offline structure memory is as follows: using an encoder based on the U-Net architecture as a feature extractor. The handwritten text samples and rubbings of text samples are uniformly mapped to a high-dimensional feature space, and the feature matrix is ​​extracted from the intermediate layer. This is to capture structural information shared across modalities. The extracted feature matrix is ​​then utilized. The vector index was constructed. To support high-speed retrieval of large-scale character samples and ensure the real-time performance of the repair process, an inverted index based on L2 Euclidean distance was built using the Faiss engine. This index can quickly locate the prior structural features in high-dimensional space that are closest to the structure of the sample to be repaired. (Regarding the inverted index library...) Structural consistency screening is performed to remove outliers and abnormal matching results, thereby improving structural reliability. Feature vectors, neighborhood indices, and category labels are encapsulated into the offline structural memory.

[0011] This invention utilizes the existing Faiss engine to build a system based on... Following the initial inverted index based on Euclidean distance [Johnson, J., Douze, M., & Jégou, H. (2019). Billion-scale similarity search with GPUs. IEEE Transactions on Big Data], a structural consistency screening step was innovatively added to address the problem that traditional KNN retrieval relies solely on spatial distance and lacks topological logic verification. The specific screening method is as follows: based on the sample's... Using the neighborhood graph topology as a benchmark, a structural consistency verification algorithm (verify_consistency) is invoked to quantitatively evaluate the class consistency within the neighborhood. By calculating the proportion of outlier samples within the neighborhood of a specific sample, once this proportion exceeds a set threshold, the sample is determined to be an outlier or an abnormal match and is removed. This method effectively eliminates feature domain offset noise caused by cross-modal data through this closed-loop feedback filtering. Finally, the purified high-quality feature vectors, neighborhood topology index, and class labels are jointly encapsulated into an offline structure memory (oracle_structure_mb.pkl), realizing the collaborative storage of feature space distribution law and topological prior.

[0012] As a preferred embodiment of the present invention, in step 3, standard handwritten features are obtained from the offline structural memory using Faiss vector indexing to perform K-nearest neighbor fast search. The specific method is as follows: Using feature extractors Extracting deep semantic features from intermediate reconstruction results Its definition is: , in, For feature dimensions; To enable offline structure libraries Highly efficient retrieval, performed using the Faiss engine. Nearest neighbor search. Given Retrieve the most similar from the offline structure memory. A collection of standard handwriting styles The criteria are as follows: in, Represents offline structured memory The first stored in the middle One reference feature vector.

[0013] Through this retrieval mechanism, the model can introduce prior information that is closest to the current structure during the iteration process, thereby providing effective guidance for the gradual recovery of stroke topology.

[0014] As a preferred embodiment of the present invention, the manifold constraint module includes a normalized distance mapping submodule, a statistical consistency constraint submodule, and a manifold consistency loss function submodule; The normalized distance mapping submodule calculates the intermediate features generated at each time step. and The formula for the Euclidean distance vector between n neighborhood samples is as follows: , , in, Indicates the relationship with the first Distance of each reference feature It is an L2 norm; The formulas for calculating the first and second moments of the neighborhood distance distribution between the reconstructed features and the original features by the statistical consistency constraint submodule are as follows: , , in, and These represent the overall position and centripetal tendency of the sample on the manifold, respectively. and This indicates the degree of dispersion of neighborhood distance, reflecting the compactness of the local manifold. By aligning the above statistics, the model captures the structural framework of characters at the macroscopic distribution level, thus ensuring pixel accuracy while generating strokes that conform to the inherent topological logic of oracle bone script. The normalized distance mapping submodule performs mean normalization: , , in, To maintain numerical stability, small constants are used; The manifold consistency loss function submodule calculates the manifold consistency loss, and its function is as follows: , in, , This is the balance coefficient.

[0015] To further maintain the stability of the character topology, this invention introduces a manifold geometric consistency constraint based on the Isomap geodesic distance preservation concept. Specifically, for the currently generated feature and its corresponding ground truth feature, their K-nearest neighbor relationships are constructed, and the distance distribution features in their respective neighborhoods are calculated. By constraining the mean distance, variance distance, and neighborhood structure relationships between the predicted and ground truth features in the local manifold, a manifold geometric consistency loss function is constructed. This constraint regularizes the feature structure at the nonlinear manifold space level, effectively suppressing character structure breaks, stroke distortion, and topological disorder.

[0016] As a preferred embodiment of the present invention, the training loss function of the semantically guided U-Net architecture model is: , in, To reconstruct the loss weights, To reconstruct the loss function, To perceive loss weights, For the perceptual loss function, For semantic classification loss weights, For semantic classification loss function, Weights for manifold consistency loss. This is the manifold consistency loss function.

[0017] As a preferred technical solution of the present invention, the reconstruction loss weight The function is as follows: , in, As the initial weights, The attenuation rate; The reconstruction loss function is as follows: , in, and These represent the original image and the restored image, respectively. Constrain pixel-level deviations To balance the hyperparameters of the two contributions, , in, , and These represent the mean, standard deviation, and covariance, respectively. and It is the stability constant; The function for the perceived loss weights is as follows: , in, To maximize the weight of perceived loss, This is the growth rate control coefficient; The perceptual loss function is: , in, Indicates the network number Feature mapping of layers, , in, For the corresponding number The total number of elements in the layer feature map. , and These represent the space height, space width, and number of channels, respectively. Semantic classification loss weights The function is as follows: , in, These are the initial weights; The semantic classification loss function is as follows: , in, The total number of categories, One-hot encoding of the real label. Indicates the prediction is the first The probability of a class; manifold constraint weights The function is as follows: , in, The training progress threshold, This represents the maximum weight of the manifold constraint.

[0018] During model training, semantic classification loss, image reconstruction loss, and manifold consistency loss are jointly optimized to achieve semantic preservation, pixel restoration, and structural topological constraints on the generated results. Semantic classification loss enhances the model's ability to learn semantic features of ancient character categories, enabling the model to possess effective category discrimination and semantic representation capabilities. Based on the feature extraction capabilities acquired during training, the optimal classification model is selected to construct an offline structural memory database containing standard character structural features. In the early stages of model training, semantic classification loss provides category-level supervision information, guiding the model to learn stable character semantic representations. As training progresses, to avoid excessively strong semantic constraints limiting the ability to restore structural details during the diffusion generation process, the weight of semantic classification loss is gradually reduced, allowing the model to focus more on image reconstruction quality and structural consistency. The manifold constraint module constrains the geometric relationship between generated features and prior structural features in the low-dimensional manifold space, achieving consistency between the restoration result and the prior structural features by preserving the local topological structure in the feature space. Therefore, cross-entropy loss and manifold structure consistency loss belong to different levels of optimization objectives: the former is mainly used to enhance the semantic category consistency and feature representation ability of the model, while the latter is used to maintain the geometric topological consistency between generated features and structural prior features. The two play complementary roles in the model training process.

[0019] As a preferred technical solution of the present invention, the standardization process is as follows: the image is converted to grayscale, then the background color is determined and automatically inverted, the aspect ratio is maintained and the size is scaled and the edges are filled to unify the size to 64×64 pixels, and finally the corresponding mask information is generated.

[0020] As a preferred technical solution of the present invention, in step 2, for the preprocessed ancient character image In steps Degraded image below It can be defined as: , in, Represents the two-dimensional spatial coordinates of pixels in an image; ⊙ denotes element-wise multiplication. For the normalized mask generated based on the two-dimensional Gaussian distribution: , in, Represents randomly generated degeneracy centers, used to cover the sparse stroke structure of oracle bone script. The scale parameter increases gradually with t to control the degree of loss of local information.

[0021] Compared with the prior art, the beneficial effects of the present invention are: the present invention deeply reconstructs the constraint mechanism and loss system of the diffusion model, enabling it to accurately adapt to the topological features and semantic attributes of ancient characters.

[0022] - By embedding temporal and class vectors in the U-Net architecture, the semantics of the text to be repaired are anchored under two conditions. Then, by combining the cross-entropy loss in the auxiliary supervision system for explicit supervision, the encoding features are optimized synchronously between the reconstruction task and the semantic classification task. This allows semantic guidance for character shape repair, improving the accuracy of semantics and thus improving the accuracy of character shape repair. - By introducing a cross-sample structure retrieval mechanism (Mb) and combining it with the KNN algorithm to retrieve similar handwritten features from the offline structure library, we can make full use of prior knowledge of external structures such as structurally complete handwritten samples to provide a standardized structural morphology support for the reverse diffusion process. This enables cross-modal knowledge transfer, improves the standardization of the repaired structure, reduces the modal differences between the reconstructed ancient characters and standard handwritten characters, and improves stability. - Introducing the manifold geometric consistency constraint (Iso), based on the idea of ​​the Isomap algorithm, a geodesic structure consistency loss is constructed in the feature space. By constraining the geometric consistency between generated features and prior samples in the manifold space, stroke deformation and structural fragmentation are effectively suppressed, and the model's ability to distinguish structural features and noise disturbances is improved, accurately preserving fine structure. - By adopting a dynamic weighted joint loss system, which integrates reconstruction loss, perceptual loss, semantic classification loss and manifold geometric consistency loss, and introducing a weight scheduling strategy that evolves with the number of training steps, the model smoothly transitions from the initial pixel-level detail reconstruction to the later deep topological structure alignment, thereby improving the clarity and accuracy of strokes.

[0023] Due to the complexity of the structure and degradation patterns of oracle bone inscriptions, this invention integrates semantics, structure, and geometric manifolds into a diffusion framework, which not only improves the readability of the restoration results but also opens up a new path for the digital protection of cultural heritage through multi-constraint collaborative modeling. Attached Figure Description

[0024] Figure 1 A schematic diagram of the existing SADM framework structure; Figure 2 This is a schematic diagram of the MGK-DM frame structure of the present invention; Figure 3 This is a diagram of the improved U-Net network structure that incorporates category embedding and auxiliary classification supervision (CE) in this invention. Figure 4 This is a flowchart illustrating the cross-sample structure retrieval mechanism (Mb) and the construction of the offline structure prior library of this invention. Figure 5 This is a comparison chart of the repair effects of the present invention on different datasets; Figure 5 (a) is a comparison chart of the repair effect of the present invention on the OBIMD test dataset; Figure 5 (b) is a comparison chart of the repair effects of the present invention on the Testsingle dataset, OBC306 dataset and HWOBC dataset; Figure 6 This is a diagram showing the changing trends of the total loss function and each loss component in this invention, and the impact of the dynamic weight scheduling strategy. Figure 7 This is a visualization comparison of the t-SNE feature distribution of the present invention and the existing SADM framework. Detailed Implementation

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

[0026] Example 1 This invention discloses a method for ancient script restoration based on a fusion semantic guided diffusion model. The technical solution adopted is as follows: First, the model is built and trained. Step 1, Training data construction and preprocessing, The required training dataset was collected and constructed through publicly available ancient script digitization research channels (“Yinqi Wenyuan”) and academic open-source benchmarks; the Oracle Bone Script Multimodal Dataset (OBIMD), Oracle Bone Script Detection Dataset (TestSingle), Oracle Bone Script Character Recognition Dataset (OBC306), and Handwritten Oracle Bone Script Dataset (HWOBC) were obtained through public channels to cover the original images of the two core modalities of rubbings and handwritten characters.

[0027] During the training set construction process, this embodiment extracts single-character images from OBIMD based on character coordinate information. After filtering out invalid samples such as large areas of white pixels, a total of 151,326 valid images are obtained. To establish robust cross-modal associations, this embodiment classifies and stores rubbings and handwritten images according to 1,643 character IDs, and uses stratified random sampling to divide the training, validation, and test sets in an 8:1:1 ratio, ensuring that each category contains at least one rubbing and one handwritten image during the training phase. A dedicated feature retrieval copy directory is also constructed. The specific partitioning results of the OBIMD dataset are shown in Table 1. During the testing phase, in addition to using the OBIMD test set, TestSingle (containing real crack noise), OBC306 (with rich glyph variations), and expert handwritten data HWOBC are also introduced to comprehensively evaluate the model's generalization ability and style adaptability in complex degradation scenarios. To eliminate differences in imaging conditions and background distribution across different data sources, this embodiment performs a standardized preprocessing procedure on all original images: First, the images are converted to grayscale format, and the background color is automatically identified based on the global average brightness. White background images are then color-inverted to unify the visual style to black background with white text. Subsequently, while maintaining the original aspect ratio, the images are uniformly scaled to a standard input size of 64×64 pixels by filling with black pixels. This ensures the consistency of data distribution during model training and inference, resulting in the preprocessed oracle bone script images. Furthermore, this embodiment defines a dedicated missing region annotation mechanism for oracle bone script restoration tasks. It uses a binary mask of the same size as the input image to simulate image damage or occlusion. Regions with a value of 1 represent visible structures, while regions with a value of 0 represent missing parts.

[0028] After completing the above operations, the training samples are formed.

[0029] By using a dynamically generated mask matrix, this embodiment can precisely control the degree of missing strokes, thereby guiding the diffusion model to reconstruct the damaged topology based on the remaining visible content.

[0030] Table 1 OBIMD Dataset Division Statistics Step 2, offline structure memory construction, A multimodal structural memory bank was constructed using preprocessed oracle bone script images and standard handwritten characters.

[0031] Specifically, such as Figure 4 As shown, the encoder of the pre-trained U-Net is used as the feature extractor. The handwritten characters and rubbings are uniformly mapped to a high-dimensional feature space, and feature representations are extracted from intermediate layers (such as mid_block2). To capture cross-modal shared structural information, this embodiment then utilizes the extracted feature matrix. Complete the construction of the vector index; To support high-speed retrieval of large-scale character samples and ensure the real-time nature of the repair process, an inverted index based on L2 Euclidean distance was built using the Faiss engine. This index can quickly locate the prior structural features that are closest to the structure of the sample to be repaired in a high-dimensional space; on this basis, the search results are screened for structural consistency, outlier samples and abnormal matching results are removed, and structural reliability is improved. The specific method for structural consistency screening is as follows: For each sample feature vector in the index, the Faiss engine is used to retrieve its Top-... A topological nearest neighbor sample is calculated, and the average Euclidean distance between the sample and its nearest neighbors is calculated. A structural consistency test threshold is introduced. When the average Euclidean distance of a sample is greater than the test threshold, the sample is determined to be an outlier and is removed, thereby filtering out abnormal matching results and improving structural reliability. The number of topological nearest neighbors is... The range of values ​​is Preferred The structural consistency test threshold is a dynamic threshold, set as the mean of the average distances between all samples within the text category plus... The standard deviation is times.

[0032] Finally, the feature vectors, neighbor indexes, and category labels are encapsulated into an offline structure memory (oracle_structure_mb.pkl). The category labels are used only for auxiliary supervision and statistical analysis of retrieval results during the training phase and do not participate in the structure similarity search process. Structure retrieval during the inference phase is entirely based on distance similarity in the feature space. The constructed structure memory serves as a cross-modal structure prior library, providing a stable geometric reference for stroke topology restoration, local structure completion, and overall character shape correction during the diffusion repair process. This memory is used for structure retrieval and prior injection in subsequent training and inference phases. This correspondence is not used for character category recognition, but rather to characterize the structural similarity of samples of different modalities in a high-dimensional feature space, thereby providing a stable geometric structure prior for the diffusion repair process; Step 3, Deterministic Degradation Modeling Unlike the random noise addition that is proportional to t in the standard diffusion framework, this process introduces a sequence of local masks at random locations, enabling the model to learn during training its ability to infer the global geometry from local incomplete information.

[0033] Given the original image (i.e., the pre-processed oracle bone script image) ), in steps Degraded image below It can be defined as: , Where (x, y) represents the two-dimensional spatial coordinates of a pixel in the image, and ⊙ represents element-wise multiplication. For the normalized mask generated based on the two-dimensional Gaussian distribution: , in Represents randomly generated degeneracy centers used to cover the sparse stroke structure of oracle bone script; The scale parameter increases progressively with t to control the degree of loss of local information; Oracle bone inscription restoration aims to recover clear character images from damaged or severely weathered observation images. Unlike traditional diffusion models that use Gaussian noise to degrade, this embodiment uses a deterministic physical decay process to simulate the edge diffusion and loss of detail caused by natural weathering over thousands of years in rubbings. Step 4: Multi-scale feature modeling of the U-Net backbone network. To address the issues of stroke breakage and structural loss in oracle bone inscriptions caused by long-term weathering and rubbing, this embodiment proposes a multi-constraint U-Net architecture that integrates semantic supervision (such as...). Figure 3 This architecture is based on a symmetric encoder-decoder, achieving multi-scale feature fusion through skip connections, and introduces three core mechanisms: First, a temporal and class-based dual-conditional embedding is designed at the top of the architecture to achieve stage awareness and semantic guidance in the diffusion process; second, an auxiliary supervision system is introduced at the bottleneck layer at the end of the encoder to enhance the semantic discriminative ability of deep features; finally, a joint loss function composed of pixel-level, semantic-level, and manifold-level loss functions is constructed to collaboratively optimize the model. To address the challenge of recovering complex glyph structures from low-level pixel information in oracle bone script restoration, this embodiment designs a dual-condition embedding mechanism that injects temporal and category information into each layer of U-Net; the temporal step... sinusoidal position coding is mapped to a multilayer perceptron for temporal embedding. Used to characterize noise intensity at different stages; character category labels Mapped to semantic vectors through learnable embedding layers. This is used to represent the category attributes and structural priors of characters; the two are integrated into a conditional vector through element-wise addition. Subsequently, it is injected as a global modulation signal into each stage of Conditioned ConvNeXt Block, so that the model is subject to consistent semantic constraints throughout the entire encoding and decoding stage, which significantly improves the structural recovery capability under low signal-to-noise ratio conditions. The character category label The annotations are derived from existing standard annotations in the oracle bone script character dataset, and are constructed after character-level segmentation and unified numerical encoding during the data preprocessing stage. During the training phase, the encodings of known labeled samples are directly used as conditional supervision signals. Simultaneously, based on sample features, data is processed in an offline structured memory. Nearest neighbor search, extracting Top- Neighborhood standard features serve as explicit topological priors for manifold geometric constraints. During the inference phase, the system employs differentiated routing: unlabeled input samples are uniformly mapped to independent unregistered class codes (UNKNOWN_CLASS_ID) for blind inpainting in the generalization domain; labeled input samples directly assign known labels as signals. It then targets and retrieves corresponding standard glyph features to provide deterministic manifold priors. Subsequently, labels are generated. The learnable embedding layer is mapped to a high-dimensional semantic vector, which is then fused with the temporal embedding vector in the residual network block (ConvNextBlock) to form a global conditional guidance signal injected into each layer of U-Net, ultimately realizing semantic constraints and structural guidance throughout the entire process of inverse diffusion denoising.

[0034] To further enhance the class discrimination capability of deep semantic features in the diffusion model, this embodiment introduces an explicit semantic supervision branch between the bottleneck layer and the decoder of the diffusion backbone network based on U-Net. This explicit semantic supervision branch uses bottleneck layer features that are fused with multi-scale contextual information and class-conditionally embedded. As input, the spatial dimension is compressed through a global average pooling layer, and the feature representation is obtained after a flattening operation. The features are then represented. The input is fed into a fully connected classification layer to obtain the category prediction result. .

[0035] The cross-entropy loss function is used to explicitly supervise the class prediction results, thereby enhancing the class discrimination ability of the bottleneck layer features. The cross-entropy loss function is defined as follows: , in, The total number of categories, One-hot encoding of the real label. Indicates the predicted category result. Indicates the prediction is the first Class probability; cross-entropy loss As a semantic classification loss term, the smaller the deviation between the predicted category result and the true category label, the stronger the category discrimination ability of the feature representation.

[0036] Specifically, during model training, cross-entropy loss is calculated. Regarding classification layer parameters and feature representation The gradient of the cross-entropy loss is calculated, and the network parameters are updated using the gradient descent algorithm, enabling the fully connected classification layer to establish a mapping relationship between deep semantic features and class labels. According to the chain rule, the gradient generated by the cross-entropy loss propagates progressively from the classification layer to the bottleneck layer. The gradient propagation process is expressed as: ; in, The cross-entropy loss represents the loss with respect to the bottleneck layer features. The gradient.

[0037] Due to the bottleneck layer Located at the end of the encoder, the gradient is further propagated layer by layer along the backpropagation path of the encoder network to the parameters of each coding layer, thereby optimizing the parameters of the feature extraction network. The process is represented as follows: in, Indicates the encoder's first... Layer network parameters, Indicates the encoder's first... Layer output features.

[0038] The gradient propagates layer by layer along the downsampling path of the encoder to the parameters of each convolutional layer, thereby optimizing the feature extractor. The parameters enable the bottleneck layer features Learn more class-discriminative semantic representations. When class conditions are in the form of learnable embeddings, gradients can be further propagated to the conditional embedding parameters to optimize semantic conditional representations.

[0039] The supervised learning model, as described above, learns more distinctive glyph features, which remain active during both training and inference phases. These features are used to output category predictions, providing machine-readable semantic supervision. The topological manifold constraint branch includes an offline structure memory, a KNN retrieval module, and a manifold constraint module. During training, this branch, which is activated only during the training phase, is used to reconstruct the results. The feature representations and the standard prior features obtained by KNN retrieval are jointly mapped to a low-dimensional feature manifold space. Based on the idea of ​​the Isomap algorithm, the geodesic distance distribution and local adjacency relationship of the two are calculated, and then a manifold geometric consistency loss is constructed to constrain the generation results from the nonlinear geometric level, so that they conform to the inherent topological geometric rules of Oracle. The offline structure memory is connected to the KNN retrieval module to provide lossless standard topological priors. The output of the KNN retrieval module is the input of the manifold constraint module to guide the reconstructed features to perform high-order geometric manifold alignment. The branch of the topological manifold constraint module only participates in optimization during the training phase and does not introduce additional overhead during inference. The co-evolution of each module is achieved through multi-constraint joint loss and dynamic weight strategy. Degraded image Time embedding and category conditions The common input is a diffusion backbone network based on U-Net; the network utilizes a multi-scale encoding and decoding structure to progressively restore the structure and reconstruct details of the degraded image at each iteration of the reverse diffusion process. By capturing deep semantic features, preliminary restoration results and feature representations are generated, laying the semantic foundation for subsequent structural correction. Step 5, Cross-sample structure retrieval and prior injection. To address the problem of stroke topological breakage and structural fragmentation in oracle bone rubbings caused by severe weathering, a cross-modal prior retrieval and enhancement mechanism is introduced. The core logic of this mechanism is to use the structurally intact handwritten features as a morphological framework to guide the restoration process of damaged rubbings, thereby bridging the domain differences between modalities and providing robust geometric framework support for the deblurring process. During the reverse iteration of diffusion repair, the model needs to dynamically obtain the current generation state. Structural references, such as Figure 4 As shown, this embodiment utilizes a feature extractor. Extracting deep semantic features from intermediate reconstruction results Its definition is as follows: , in, For feature dimensions; To achieve offline structure memory Highly efficient retrieval, performed using the Faiss engine. Nearest neighbor search; given Retrieve the most similar from the offline structure memory. A set of reference features The criteria are as follows: , in, Represents offline structured memory The first stored in the middle A reference feature vector, which is generated by a pre-trained encoder. extract; In this embodiment, K=10; Through this retrieval mechanism, the model can introduce prior information that is closest to the current structure during the iteration process, thereby providing effective guidance for the gradual recovery of stroke topology; During iterative sampling, the model extracts intermediate layer features of the current sample in real time and performs a fast K-nearest neighbor search using Faiss vector indexing in the offline-built structure library. By retrieving the K most structurally similar standard handwritten features, a local structural neighborhood is constructed and injected into the reverse diffusion process as a structural scaffold, providing additional structural reference information for damaged areas, thereby enhancing the model's ability to recover complex character topologies. Step 6: Isomap manifold geometry consistency constraint regularization. Building upon an offline structural memory, a manifold consistency constraint mechanism based on isomaps is further introduced to explicitly constrain the nonlinear topological relationships of the generated results in the feature space. This effectively suppresses potential structural collapse or morphological distortion during the repair process. The overall process is as follows: Figure 2 As shown in the Isomap-GSC module; During the diffusion reverse iteration process, the model generates intermediate features at each time step. To characterize its topological location in the local manifold, a reference neighborhood is constructed based on cross-modal prior knowledge retrieval and enhancement. Calculate its relationship with Euclidean distance vector between neighboring samples: , , in, Indicates the relationship with the first Distance to each reference feature; At the same time, the original image features Calculate the corresponding distance vectors in the same neighborhood. As an alignment benchmark, the above distance represents the approximate geodesic distance in the local neighborhood using Euclidean metric, thereby mapping the high-dimensional nonlinear structure into a measurable geometric representation, providing a unified reference for subsequent structural consistency constraints; To ensure the topological stability of the repair results in the manifold space, this embodiment introduces geodesic structure consistency constraints, requiring that the relative positions of the reconstructed features and the real features in their local neighborhoods remain consistent. To enhance the robustness of the constraints, this embodiment models the neighborhood distance distribution from the perspective of statistical moment matching, calculating the first moment (mean) and second moment (variance) of the neighborhood distance distributions of the reconstructed features and the original features, respectively. , , in, and It reflects the overall position and centripetal tendency of the sample on the manifold; and The model characterizes the discreteness of neighborhood distances, reflecting the compactness of local manifolds. By aligning the above statistics, the model captures the structural framework of characters at the macroscopic distribution level, thus ensuring pixel accuracy while generating strokes that conform to the inherent topological logic of oracle bone script. Based on geometric modeling, this embodiment constructs a manifold geometric consistency loss. First, to eliminate the impact of scale differences in distance between samples on optimization, scale alignment is performed on the neighborhood distance vectors. By normalizing the mean, the distances of different samples are mapped to a comparable range, making the model focus more on topological shape rather than absolute values. , in, To maintain numerical stability, small constants are used; Based on this, we define the structural alignment loss. Fine-grained alignment to constrain local topological relationships: , By minimizing the standardized distance difference constraint on the local topology, the generated result maintains a relative geometric layout on the manifold that is similar to that of the real sample; Combining global statistical moment constraints, the final manifold consistency loss is defined as follows: , in, This indicates the alignment term for the local geodesic distance distribution. and Here, represents the mean and variance of the neighborhood distance, respectively. To balance the hyperparameters of local and global constraints, and to balance local fine alignment with global statistical characteristics, this embodiment takes a value of 0.5. This loss, by combining the local geodesic distance distribution with global statistical constraints, enables the model to maintain overall structural robustness while effectively avoiding local morphological random shifts (Mode Drift) when recovering the oracle bone script characters. In summary, the manifold geometric consistency constraint achieves closed-loop modeling from prior retrieval to structural calibration, and optimizes only through loss during the training phase without increasing the inference burden; Step 7, Dynamic weight loss optimization and smooth transition. To achieve coordinated optimization of reconstruction accuracy, semantic consistency, and structural topology, this embodiment constructs a unified joint loss function and designs a dynamic weight scheduling strategy to enable the model to gradually transition from low-level reconstruction to high-level semantic and geometric constraints. The overall optimization objective consists of four core terms: reconstruction loss, perception loss, semantic classification loss, and manifold geometric consistency loss, which are formally expressed as follows: , Among them, reconstruction losses To constrain the accuracy of the repair results at the pixel and structural levels, this embodiment uses... A weighted combination of loss and structural similarity (SSIM) loss; specifically, The loss measures the pixel-wise absolute error between the generated image and the real image to ensure pixel-level reconstruction accuracy, and is defined as follows: , in, Indicates the total number of pixels. and Represent the generated image and the real image respectively. The values ​​of each pixel are considered; furthermore, SSIM loss is introduced to measure the similarity of the image in terms of brightness, contrast, and structure, in order to enhance the consistency of stroke structure and suppress morphological distortion. Its relevant definition is as follows: , , in, , and These represent the mean, standard deviation, and covariance, respectively. and As the stability constant, in this embodiment, the values ​​are respectively taken as follows: and (based on (Normalization interval setting); Minimizing SSIM loss can enhance the model's ability to model structural information, thereby improving the performance of the generated results in terms of detail reproduction and overall recognizability.

[0040] Combining the above two points, the reconstruction loss is defined as follows: , in, and Representing the real image and the restoration result respectively, through get; SSIM constrains pixel-level deviations to ensure the correct positioning of the basic outline and strokes; it also enhances the consistency of local structures. To balance the hyperparameters of the two contributions; Perceived loss This method enhances the visual realism of the restoration results; this embodiment is based on a pre-trained feature extraction network. (VGG-16) calculates the difference between the generated image and the real image in a multi-scale feature space, in the following form: , in, Indicates the network number Feature mapping of layers, For the corresponding number The total number of elements in the layer feature map. , These represent the height and width of the space, respectively. Indicates the number of channels in its space; By minimizing this loss, stroke edges and texture details can be effectively recovered under high-level semantic constraints, thereby establishing a link between pixel reconstruction and semantic representation. Semantic classification loss Based on the auxiliary supervision system introduced in Step 4, This constraint helps to preserve key semantic information during the feature extraction stage, thereby improving the recognizability of the repair results. In addition, to ensure the effectiveness of the manifold constraint, this embodiment adopts a progressive training strategy: first, the feature space is optimized under the guidance of classification loss to make it have good discriminability and separability, and then the manifold geometric consistency constraint is introduced to perform topological calibration on the feature space. manifold geometric consistency loss It aligns the local geodesic distance distribution and its statistical characteristics to make the generated result conform to the inherent topological structure of oracle bone script. The formula is shown in Step 6. Considering that different loss terms have significantly different roles in the training process, this embodiment designs a loss term based on training progress. The dynamic weight scheduling mechanism, in which This represents the current number of training steps. Total training steps ; Specifically, reconstruction loss weights In the early stages of training, higher weights are set to quickly converge the contour, and then the weights are gradually reduced exponentially to shift the optimization focus to higher-level constraints. , in, As the initial weights, The attenuation rate; Semantic classification loss weights Early intervention is used to establish stable categorical feature representations. Once the classification accuracy stabilizes, a linear decay is used to gradually reduce the accuracy to avoid affecting the repair effect. , in, These are the initial weights; Perceived loss weights The process increases linearly with training progress, refining stroke texture and visual naturalness after the outline is determined: , in, To maximize the weight of perceived loss, Control the growth rate to ensure that perceptual constraints take effect gradually in the later stages of training; manifold constraint weights To avoid introducing incorrect geometric constraints when early features are unstable, a delayed activation strategy is adopted, which activates the features only when the training progress reaches a threshold. Then linear growth: , Activation threshold Set it to 0.15. Using the maximum weight of the manifold constraint, this strategy ensures that the model has initial generative capabilities before performing fine-grained topology calibration. Under this scheduling mechanism, the model forms a three-stage progressive optimization path: the first stage mainly uses reconstruction loss and classification loss, focusing on character contour restoration and category localization; the second stage introduces perceptual loss to refine stroke edges and textures; the third stage adds manifold geometric consistency constraints to correct complex stroke distortions and achieve topological alignment; this strategy achieves step-by-step optimization from pixel reconstruction to semantic consistency and then to topological constraints, significantly improving the model's repair stability and accuracy in complex degradation scenarios; The system employs a dynamic weighted joint loss function for overall optimization. The total loss consists of reconstruction loss, perceptual loss, semantic classification loss, and manifold geometric consistency loss, among which reconstruction loss... Used to ensure pixel-level recovery accuracy; perceptual loss Used to maintain visual texture consistency; semantic classification loss Used to enhance character semantic correctness; manifold geometric consistency loss Used to maintain topological stability; Meanwhile, a dynamic weight scheduling mechanism is adopted to adjust the weights of each loss term according to the training process; in the early stage of training, the pixel-level recovery capability is mainly strengthened; in the middle and later stages of training, the structural and semantic constraints are gradually enhanced; this scheduling mechanism realizes a smooth transition from low-level visual recovery to high-level structural consistency, thereby guiding the model to learn the structurally complete and semantically consistent oracle bone reconstruction mapping relationship. Step 8, Model Training and Convergence Model training was implemented using PyTorch, and all models were trained and inferred on a single NVIDIA Tesla V100 (32GB) GPU. The training consisted of 200,000 steps, with a batch size of 60 and an initial learning rate of [missing value]. The Adam optimizer is used, and the gradient accumulation step is set to 2. To stabilize the training process, EMA (decay rate 0.995) is introduced, and no updates are made in the first 2,000 steps. In terms of degradation simulation, a stochastically increasing Gaussian kernel is used to progressively blur the original image. The kernel standard deviation controls the degree of blurring of the mask; the larger the standard deviation, the wider the mask coverage area. The image is uniformly... The size of the mask region is determined by both the standard deviation and the image size; The loss function employs a multi-component dynamic weighting strategy. The reconstruction loss consists of L1 and SSIM losses, with a balance coefficient β of 0.1. Its weight gradually transitions from L1-dominant to SSIM-dominant during training. The perceptual loss is based on the L1 distance in the feature space calculated using a pre-trained VGG-16 network, with its weight linearly increasing from 0.01 to 0.3 during training. The classification loss is the cross-entropy loss of the auxiliary classification head, with a fixed weight of 0.05, used to enhance the semantic discriminative power of the features. The manifold geometric consistency loss uses a delayed activation strategy, with a value of 0 for the first 30k steps and linearly increasing to 0.1 from 30k to 50k. In the manifold geometric consistency constraint, the number of neighbors K retrieved by KNN is set to 10. The offline structural memory is constructed by extracting features from all images in the OBIMD training set, with a feature dimension of 512. The constant ε in the normalization operation is set to... The auxiliary supervision system adopts a three-layer fully connected network, and the output dimension corresponds to the number of character categories (1,643 categories). During training, the model is saved and intermediate results are output every 5,000 steps to monitor the convergence. The code is based on PyTorch 1.10 and supports NVIDIA Apex mixed precision training. By analyzing the loss evolution and weight scheduling throughout the entire training cycle, the robustness and hyperparameter rationality of MGK-DM were verified. Figure 6 As shown, the model exhibits a clear phased convergence characteristic: the total loss decreases logarithmically in the initial stage. Figure 6 (a)) quickly captured the macroscopic distribution of oracle bone inscriptions; based on convergence saturation (fluctuation after 150k steps). Considering performance trade-offs (the difference in metrics between the 150k and 200k step models is small, with the former showing better metrics) and computational efficiency, 150,000 steps were ultimately chosen as the output point; regarding the coordination of loss components ( Figure 6 (b) The classification loss (CE Loss) decreases to within 30k steps. The following steps construct a stable semantic clustering space for the U-Net bottleneck layer, ensuring the accuracy of knowledge base retrieval; the manifold consistency loss (IsomapLoss) is smoothly introduced at 30k steps through linear increases and stabilizes at... The magnitude of the data verified that the manifold alignment strategy can effectively correct stroke topological distortions without compromising the realism of the generated data; in terms of dynamic weight scheduling ( Figure 6 (c) This embodiment adopts a course learning strategy: It exhibits exponential decay to free up the degree of freedom for optimizing local details; Asymptotic activation in the 30k–50k step range avoids KNN mismatches and gradient oscillations caused by initial random denoising; simultaneously and Linear growth drives the model to shift from pixel fitting to structural coherence modeling, eventually reaching a global optimal balance around 150k steps. Considering the convergence of the loss function, the performance of the validation set repair, and the computational cost, this embodiment selects the model parameters saved after 150,000 training steps as the final model for subsequent inference and application stages. After training, the optimal model parameters are selected based on evaluation metrics such as FID and SSIM on the validation set, and the corresponding network weight files and structure database information are saved for use in subsequent inference stages.

[0041] Next, the trained MGK-DM model was applied to oracle bone inscription image restoration for model testing: Step a: Input the image of the oracle bone script to be repaired and perform preprocessing. The system receives an image of a damaged rubbing of a single oracle bone inscription to be restored as input. It performs a standardized processing procedure on the input image consistent with the training phase, including: grayscale conversion; background color discrimination and automatic color inversion; scaling while maintaining aspect ratio; edge filling; resizing to 64×64 pixels; and generating corresponding mask information. The processed image serves as the standard input to the model. Step b: Load the trained MGK-DM model. Load the optimal network parameter file saved during the training phase and the offline structure memory oracle_structure_mb.pkl, switch the model to inference mode, and turn off gradient calculation and backpropagation to ensure that the model performs forward inference with fixed parameters. Step c, Backdiffusion Sampling and Structure Prior Enhancement The preprocessed image to be repaired is input into a conditional diffusion network; the network performs a multi-step inverse diffusion sampling process based on the parameters learned during the training phase, and gradually restores the structure and reconstructs the details of the damaged area. During the reverse diffusion sampling process, the conditional U-Net backbone network extracts the intermediate layer features at the current time as the query vector in real time, and performs K nearest neighbor search in the offline structural memory through the Faiss vector indexing system to obtain the K standard handwritten features most similar to the current sample structure and their neighborhood information. Subsequently, the retrieved structural features are dynamically injected into the diffusion network as external structural priors to provide additional geometric structural references for broken strokes, blurred edges, and missing areas, guiding the network to generate restoration results that conform to the rules of oracle bone script. Since the model has completed parameter optimization through manifold geometric consistency constraints during the training phase, there is no need to calculate the manifold loss during the inference phase. The learned topology preservation ability can be used to generate structurally consistent repair results. Step d: Output the repair results. After the reverse diffusion sampling process is completed, the network outputs the final restored image. If the system has saved the scaling and padding parameters from the preprocessing stage, it further restores the original aspect ratio of the image and outputs the final oracle bone script restoration result. In experimental evaluation mode, the system can also compare the restoration results with real images and automatically calculate objective evaluation indicators such as FID, SSIM and RMSE to quantify and evaluate the restoration performance of the model.

[0042] Comparative Example 1: SADM Model.

[0043] The repair effects of Example 1 and Comparative Example 1 were compared using the OBIMD test set. The comparison results are as follows: The above comparisons show that MGK-DM demonstrates a particularly significant performance improvement on the topographic subset of the OBIMD test set: FID decreased from 11.72 to 5.32, a reduction of 55%; SSIM increased from 0.8994 to 0.9218; and RMSE decreased from 0.082 to 0.067. This indicates that MGK-DM outperforms SADM in terms of generated distribution similarity, structural consistency, and pixel-level reconstruction accuracy. On the handwritten subset of the OBIMD test set, MGK-DM also maintains its advantage across all metrics: FID decreased from 4.65 to 3.07, SSIM increased from 0.9300 to 0.9321, and RMSE decreased from 0.0995 to 0.0889. This result validates the effective improvement of model performance by classification loss and manifold geometry constraints. Overall, MGK-DM exhibits superior generated distribution similarity, higher structural preservation, and more accurate pixel-level reconstruction capabilities compared to SADM on the OBIMD test set.

[0044] Further comparisons of the repair performance were conducted using the TestSingle, OBC306, and HWOBC datasets. The results are as follows: The comparison results above show that MGK-DM significantly outperforms the baseline SADM in sampling and repair across all external datasets. On TestSingle, FID decreased from 10.94 to 4.35, SSIM improved to 0.9271, and RMSE decreased to 0.0652; on OBC306, FID decreased from 11.19 to 2.60, a reduction of over 75%; and on HWOBC, FID decreased from 10.10 to 3.93, SSIM improved to 0.9347, and RMSE decreased to 0.0840. These results demonstrate that MGK-DM maintains stable and excellent performance across different data distributions and exhibits good cross-dataset generalization ability.

[0045] The comparison results between Example 1 and Comparative Example 1 show that Example 1 has a greater advantage in terms of semantic certainty of the repair results. Compared with SADM, which only relies on sampling algorithms and basic adaptive loss, Example 1 introduces a dual-conditional embedding and auxiliary supervision system in the U-Net architecture, which realizes explicit supervision of character categories and ensures that the model can still be guided by the target semantics even in the case of large-area missing characters, effectively avoiding the semantic shift or character shape miscreation that SADM may produce. Secondly, Example 1 significantly improves the fidelity of the restoration through cross-modal knowledge transfer. The restoration logic of SADM is largely limited by the residual information of a single sample, while Example 1 introduces an offline structural prior library based on KNN retrieval, which provides a structural framework of standard handwritten characters for the damaged rubbings during the restoration process. This mechanism of using external expert knowledge to guide internal pixel reconstruction makes the stroke regularity of Example 1 far exceed that of SADM when dealing with extremely degraded samples. Furthermore, Example 1 demonstrates greater rigor in maintaining character topological stability. To address the structural fragmentation problem that SADM is prone to when processing complex strokes, Example 1 introduces a manifold geometric consistency constraint based on the idea of ​​Isomap, which forces the regularization of feature distribution from the perspective of nonlinear geometric distribution in feature space. This makes the generated results not only visually coherent, but also geometrically consistent with the morphological rules of oracle bone script. Finally, Example 1 has a better multi-stage collaborative optimization capability. Compared with the relatively simple loss adjustment of SADM, Example 1 designed a dynamic weight joint loss system, which realizes a smooth transition from low-level pixel repair to high-level structure alignment. This adaptive scheduling mechanism makes the model more accurate and robust than the existing SADM method when facing complex texts with different sources and different degrees of degradation.

[0046] Furthermore, ablation experiments were conducted on MGK-DM using the OBIMD test set, and the experimental results are as follows: The experimental results using the TestSingle, OBC306, and HWOBC datasets are as follows: The ablation experiments described above demonstrate that the complete MGK-DM (CE+Mb+Iso) achieves state-of-the-art performance across all datasets (OBIMD, TestSingle, OBC306, HWOCB) and all metrics (FID, SSIM, RMSE), significantly outperforming the baseline SADM. This proves that the joint architecture of the three-layer constraint of "semantic anchoring (CE) + cross-sample structure retrieval mechanism (Mb) + manifold geometry calibration (Iso)" is successful and indivisible.

[0047] The independent contributions of each module reveal that Mb has the strongest independent contribution, directly extracting external structural supports and significantly improving the repair effect, proving that "cross-modal prior retrieval" is the most direct and effective means to solve the problem of missing oracle bone script structures. Iso has strong structural regularity, effectively suppressing topological distortion, and significantly improving SSIM (0.8994→0.9048) and RMSE (0.0827→0.0725). CE has limited effect alone and even has side effects; adding CE alone even decreased SSIM on rubbings (0.8994→0.8890) and worsened FID on the OBIMD handwritten test set (4.72→6.02). This indicates that simple classification supervision forces features to be overly "discriminative," squeezing the space required for reconstruction, and must be used in conjunction with other constraints.

[0048] Furthermore, the combination characteristics of each module were analyzed. Through the combination of CE and Mb, it can be seen that the category semantic information provided by CE can guide Mb to more accurately locate handwritten characters of the same structure during retrieval, eliminating interference samples with similar shapes but incorrect categories, making the retrieval support more accurate. Through the combination of CE and Iso, it can be seen that the manifold constraint of Iso successfully "corrects" the feature space distortion caused by CE, pulling the discriminative features back to the correct reconstructed manifold, achieving accurate identification and accurate repair. Through the combination of Mb and Iso, it can be seen that Mb provides coarse-grained structural reference, while Iso performs fine-grained topological calibration in the manifold space, thereby significantly improving the repair quality.

[0049] like Figure 7 As shown, compared to the baseline method SADM, the MGK-DM proposed in Example 1 exhibits a superior discriminative structure in the feature space: the intra-class sample distribution is more compact, feature aggregation is significantly enhanced, and the interval between different classes is significantly expanded, thus forming a clearer separability boundary and effectively mitigating class overlap. In contrast, SADM's feature distribution is more dispersed, with larger intra-class variance and significant overlap between classes, resulting in weaker overall discriminative power. The results demonstrate that MGK-DM can learn discriminative feature representations with stronger semantic consistency, thereby improving the separability and structural stability of the feature space and providing a reliable feature foundation for the subsequent construction of a high-quality offline structured memory, further supporting the implementation of cross-sample retrieval and manifold constraint modules.

[0050] It should be noted that the cross-modal prior retrieval mechanism in this invention differs from traditional optical character recognition (OCR) methods. Traditional OCR technology aims to identify character categories based on the input image and output corresponding text labels; its core task is character classification. However, this invention does not use character recognition results as the final goal, nor does it rely on character category matching for retrieval.

[0051] The structural prior library constructed in this invention stores the deep structural features of characters and their neighborhood topological relationships. During the retrieval process, the system searches for the handwritten structural features closest to the current damaged sample based on structural similarity in the feature space, rather than searching for the corresponding character category. The retrieval results serve as the external structural prior of the diffusion model in the subsequent image restoration process, providing geometric information support such as stroke direction, local topological relationships, and overall character layout. Therefore, this invention essentially belongs to a cross-modal prior enhancement mechanism based on structural similarity. Its core function is to assist in image generation and structural restoration, rather than to complete the character recognition task, which is fundamentally different from traditional OCR technology in terms of objectives, processes, and implementation methods.

[0052] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for ancient script restoration based on a fusion semantic-guided diffusion model, characterized in that, Includes the following steps: Step 1, Image Input and Preprocessing Input a single-character image of the text to be restored, and perform standardization processing on the image to obtain the preprocessed ancient character image. ; Step 2, deterministic degradation modeling, The preprocessed ancient character image obtained in step 1 The degraded image is obtained by performing progressive convolution degradation using an adaptive Gaussian kernel G. ; Step 3, Multi-scale feature modeling and prior injection, Degraded image Time embedding and category conditions In the U-Net architecture model guided by semantic fusion and common input, degraded images are iteratively learned through an inverse diffusion process. Compared with preprocessed ancient script images The correspondence; In each iterative learning step, the intermediate layer features of the current sample are extracted, and K standard handwritten features are obtained through the constructed offline structural memory. Then, the retrieved standard handwritten features are constructed into a graph topology, and the topological relationship in the feature space before and after the repair is kept consistent through manifold constraints, thereby injecting the structural prior into the inverse diffusion process. The reconstructed image is obtained after the iteration. .

2. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 1, characterized in that: The semantically guided U-Net architecture model includes an encoder and a decoder, with skip connections between them, and a bottleneck layer at the end of the encoder; the time steps are... The sinusoidal position encoding is mapped to a multilayer perceptron and then embedded into a temporal embedding vector. ; label the character categories Mapped to class embedding vectors through learnable embedding layers. ; The temporal embedding vector and the category embedding vector are combined into a conditional vector through element-wise addition. Then, it is injected as a global modulation signal into each stage of Conditioned ConvNeXt Block; An auxiliary supervision system is connected between the bottleneck layer and the decoder. The auxiliary supervision system includes an auxiliary supervision system and a topological manifold constraint branch. The auxiliary supervision system remains active during both the training and inference phases. It consists of a sequentially connected global average pooling layer, a flattening layer, and a fully connected layer, outputting a class prediction. The topological manifold constraint branch is a training branch that is activated only during the training phase. It includes an offline structure memory, a KNN retrieval module, and a manifold constraint module. The offline structure memory is connected to the KNN retrieval module, and the output of the KNN retrieval module is the input of the manifold constraint module.

3. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 2, characterized in that, The method for constructing the offline structure memory is as follows: using the encoder of the U-Net architecture as the feature extractor. The handwritten text samples and rubbings of text samples are uniformly mapped to a high-dimensional feature space, and the feature matrix is ​​extracted from the intermediate layer. Using the extracted feature matrix Complete the construction of the vector index; use the Faiss engine to build an inverted index library based on L2 Euclidean distance. The consistency verification algorithm is used to verify the inverted index. Structural consistency screening is performed to remove outliers and abnormal matching results, and the feature vectors, neighborhood indexes, and category labels are encapsulated into the offline structural memory.

4. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 3, characterized in that, In step 3, standard handwritten features are obtained from the offline structural memory using Faiss vector indexing to perform K-nearest neighbor fast search. The specific method is as follows: Using feature extractors Extracting deep semantic features from intermediate reconstruction results Its definition is: , in, For feature dimensions; Given Retrieve the most similar from the offline structure memory. A collection of standard handwriting styles The criteria are as follows: in, This indicates the number of items stored in the offline structured memory. One reference feature vector.

5. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 4, characterized in that: The manifold constraint module includes a normalized distance mapping submodule, a statistical consistency constraint submodule, and a manifold consistency loss function submodule; The normalized distance mapping submodule calculates the intermediate features generated at each time step. and The formula for the Euclidean distance vector between n neighborhood samples is as follows: , , in, Indicates the relationship with the first Distance of each reference feature It is an L2 norm; The formulas for calculating the first and second moments of the neighborhood distance distribution between the reconstructed features and the original features by the statistical consistency constraint submodule are as follows: , , in, and These represent the overall position and centripetal tendency of the sample on the manifold, respectively. and Indicates the degree of dispersion of neighborhood distance; The normalized distance mapping submodule performs mean normalization: , , in, To maintain numerical stability, small constants are used; The manifold consistency loss function submodule calculates the manifold consistency loss, and its function is as follows: , in, , This is the balance coefficient.

6. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 5, characterized in that, The training loss function of the semantically guided U-Net architecture model is: , in, To reconstruct the loss weights, To reconstruct the loss function, To perceive loss weights, For the perceptual loss function, For semantic classification loss weights, For semantic classification loss function, Weights for manifold consistency loss. This is the manifold consistency loss function.

7. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 6, characterized in that, The reconstruction loss weight The function is as follows: , in, As the initial weights, The attenuation rate; The reconstruction loss function is as follows: , in, and These represent the original image and the restored image, respectively. Constrain pixel-level deviations To balance the hyperparameters of the two contributions, , in, , and These represent the mean, standard deviation, and covariance, respectively. and It is the stability constant; The function for the perceived loss weights is as follows: , in, To maximize the weight of perceived loss, This is the growth rate control coefficient; The perceptual loss function is: , in, Indicates the network number Feature mapping of layers, , in, For the corresponding number The total number of elements in the layer feature map. , and These represent the space height, space width, and number of channels, respectively. Semantic classification loss weights The function is as follows: , in, These are the initial weights; The semantic classification loss function is as follows: , in, The total number of categories, One-hot encoding of the real label. Indicates the prediction is the first The probability of a class; manifold constraint weights The function is as follows: , in, The training progress threshold, This represents the maximum weight of the manifold constraint.

8. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 1, characterized in that, The standardization process is as follows: the image is converted to grayscale, then the background color is determined and automatically inverted, the aspect ratio is maintained and the image is scaled and the edges are filled to unify the size to 64×64 pixels, and finally the corresponding mask information is generated.

9. The ancient script restoration method based on a fusion semantic guided diffusion model according to claim 1, characterized in that: In step 2, the preprocessed ancient character image In steps Degraded image below It can be defined as: , in, Represents the two-dimensional spatial coordinates of pixels in an image; ⊙ denotes element-wise multiplication. For the normalized mask generated based on the two-dimensional Gaussian distribution: , in, Represents randomly generated degeneration centers. The scale parameter increases gradually with t.