Image translation method based on quantum computing reversibility

By introducing the reversible characteristics of quantum computing in the image translation model, the quantum generator and classic convolutional neural network of sharing parameters are designed to solve the problem of low space utilization rate of the parameter space of image translation models, and realized efficient memory use and high fourteen real true realization. A degree of image translation.

CN119338930APending Publication Date: 2025-01-21SHANGHAI MARITIME UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411137177.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

In the prior art, the space utilization rate of image translation model parameters is low, resulting in excessive memory resource utilization.

Method used

Adopt a reversible image translation method based on quantum -based, design two quantum generators with reversible and shared parameters, combined with classic convolutional neural networks and discriminators, through alternate training and mutual assignment weights to achieve two directions in the two directions Image translation.

Benefits of technology

It significantly improves memory efficiency. Only using 31.5KB of memory space can realize the image translation performance of the classic field method, prevent the pattern from collapse and ensure the high -fidelity of image translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338930A_ABST
    Figure CN119338930A_ABST
Patent Text Reader

Abstract

The invention discloses an image translation method based on quantum computing reversibility, applies a quantum computing technology to the field of image translation, provides a novel reversible quantum architecture, and innovatively combines a classical technology and a quantum technology. By introducing a classic image quality measurement feature similarity index SSIM to a target loss function and deploying an auxiliary convolutional neural network, it is ensured that loop consistency constraint is achieved to prevent model collapse, and high fidelity of image translation is ensured. The two quantum generators which are reversible and share parameters are designed by using the reversibility of quantum calculation, so that image translation in two directions can be completed by using one group of parameters, and the memory efficiency is greatly improved. According to the method, the image translation performance equivalent to that of the most advanced method in the current classical field is achieved only by using 31.5 KB memory space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of quantum computing and computer vision, and specifically relates to an image translation method based on the reversibility of quantum computing. Background Art

[0002] Image translation aims to establish a mapping relationship between source domain images and target domain images. Mathematically, we can explain the reversibility of the image translation task by introducing an inverse function. In short, the goal of image translation is to find a function f that maps the source domain image to the target domain, and its inverse function f -1 Realize the mapping of the target domain image back to the source domain. Image translation has been widely used in various fields, such as super-resolution, image style transfer, and image restoration. When dealing with complex application scenarios, many studies often introduce heavyweight modules with large parameters such as attention mechanisms and residual structures to capture subtle features and semantic information. In addition, the current research on image translation has also developed from single-target domain image translation to multi-target image translation, which greatly enriches the application scenarios of image translation, but also brings some challenges. Due to the need to process multiple target domains, these models are often large in scale and the number of parameters increases dramatically, which requires more memory resources to support the training and reasoning process of the model.

[0003] Existing memory-efficient image translation methods can be roughly divided into two categories: irreversible and reversible. The former uses a variety of strategies such as knowledge distillation, neural architecture search, and improving or replacing weighted modules to reduce the parameters of the image translation model. Although these studies help reduce model parameters, they ignore the potential of saving memory space by leveraging the approximate reversibility of image translation. For the latter, most works introduce reversible neural networks such as Flow and RevNet to build reversible image translation models, such as RevGAN and iFlowGAN. The One2One model proposed by Shen et al. uses a unique training strategy to alternately train the same generator with data in two directions to obtain a completely self-reversible image translation model. In the best case, the reversible method can save half of the memory. However, constrained by the unique structure of the classical neural network, each network layer contains multiple adjustable weights and biases, and the total number of parameters will still grow rapidly when the model complexity increases.

[0004] Quantum machine learning offers unique advantages over classical computing in many areas such as image classification, image generation, and optimization problems. Compared with classical algorithms, quantum machine learning brings some benefits, such as providing acceleration in training time or using fewer parameters to obtain better model performance. In the design of quantum circuits for quantum machine learning, the reversibility of quantum computing is widely used. For example, in quantum autoencoders, by utilizing the reversible evolution of quantum states, the encoding of input data to hidden representations and the decoding process from hidden representations to reconstructed data are realized. This reversibility not only helps to maintain the integrity and accuracy of information, but also provides a theoretical basis for the optimization and training of quantum autoencoders. Recently, researchers have made important progress in using quantum generative adversarial networks to generate images. In particular, Tsang et al. proposed a PQWGAN framework that combines qWGAN with a block strategy to generate high-resolution images, which opens up the possibility for quantum generative adversarial networks to handle more complex computer vision tasks such as image translation. Summary of the invention

[0005] The technical problem to be solved by the present invention is: a quantum-based image translation method is proposed for the first time. At the same time, the model utilizes the reversibility of quantum computing to solve the problem of low parameter space utilization of image translation models in the prior art.

[0006] The present invention adopts the following technical solutions to solve the above technical problems:

[0007] The image translation method based on quantum computing reversibility includes the following steps:

[0008] Step S1, prepare an image translation task dataset and divide it into a training set and a test set;

[0009] Step S2, constructing a reversible hybrid quantum-classical image translation model and initializing the model weights;

[0010] Step S3, setting the hyperparameters of the model;

[0011] Step S4, loading the training set, inputting the source domain image and the target domain image, and obtaining the corresponding quantum state;

[0012] Step S5, defining a loss function, training the reversible hybrid quantum-classical image translation model in two stages, and overall performing the two stages of training alternately until Nash equilibrium is reached;

[0013] Step S6: load the test set data, directly use the trained model to perform image translation, input the source domain image to be translated, and obtain the translated target domain result image;

[0014] Step S7: post-processing the translated target domain result image obtained in step S6.

[0015] In step S2, the reversible hybrid quantum-classical image translation model includes two mutually reversible and parameter-sharing quantum generators, two auxiliary classical convolutional neural networks, and two discriminators with a fully connected structure, wherein each quantum generator includes 32 5-qubit sub-quantum generators of the same structure; the sub-quantum generators respectively include an amplitude encoding module, a quantum circuit module containing trainable parameters, and a quantum state measurement module; wherein the trainable quantum circuit module of each sub-quantum generator includes 12 layers, each layer consisting of a rotation layer containing parameters and an entanglement layer without parameters, wherein the rotation layer is composed of a set of single-bit rotation quantum gates Rot gates, and the entanglement layer is composed of a set of CNOT gates without parameters;

[0016] Auxiliary classic convolutional neural network, the encoding part uses two convolutional layers for feature extraction, and the decoding part contains two deconvolutional layers for image generation. In the forward propagation, LeakyReLU is used as the activation function, and the last layer uses the tanh activation function to limit the output between -1 and 1;

[0017] The two discriminant networks adopt the discriminator structure in PQWGAN. The first layer is the input layer with 1024 neurons. Then, it passes through two hidden layers containing 512 and 256 neurons respectively. The last layer has only one neuron, which maps the 256-dimensional hidden features to a single output value to represent the authenticity of the input image. LeakyReLU is used as the activation function between each fully connected layer.

[0018] The specific process of step S4 is as follows:

[0019] Step S41: pre-process the images in the training set to obtain a 32*32 source domain image x i and the target domain image y j ;

[0020] Step S42: The preprocessed source domain image x i Input to the quantum generator G, and after horizontal block division, 32 1*32 image blocks are obtained. The 32 sub-quantum generators correspond to the 32 image blocks respectively. The 1*32 pixel values ​​of each image block are normalized. The amplitude encoding module of the sub-quantum generator encodes the pixel values ​​of the normalized image block into the 32 amplitudes of the quantum state |f> to obtain the encoded quantum state.

[0021] Step S43: The preprocessed target domain image y j Input to another quantum generator F, and according to the processing process of step S42, obtain the encoded quantum state.

[0022] In step S5, the specific process of training the reversible hybrid quantum-classical image translation model is as follows:

[0023] Step S51, update the weight sub-stage of the two discriminators, input the picture generated by the quantum generator G in step S41 to the corresponding discriminator, calculate the loss of the discriminator, and apply the Adam optimizer to update the weight of the discriminator; input the picture generated by the quantum generator F in step S41 to another discriminator, calculate the loss of the discriminator, and apply the Adam optimizer to update the weight of the discriminator;

[0024] Step S52, updating the quantum generator and auxiliary convolution neural network weight sub-stage, adopting the method of alternating training and assigning weights to each other for the two quantum generators, for each batch, the quantum generator and the auxiliary convolution neural network update the weights according to the defined total loss function of each quantum generator, and alternately executing the two sub-stages S51 and S52 of the training quantum generator and discriminator stage until the model reaches Nash equilibrium;

[0025] Step S53: After the model training is completed, the weight file of the first quantum generator is saved so that the two quantum generators share the same parameters to perform two-directional image translation tasks.

[0026] The method of alternately training two quantum generators and assigning weights to each other is as follows:

[0027] First, the weights of the first quantum generator and the first auxiliary convolutional neural network are updated through training, and the weight of the first quantum generator is assigned to the second quantum generator;

[0028] Secondly, the weights of the second quantum generator and the second auxiliary convolutional neural network are updated through training, and the weights of the second quantum generator after training and updating are again passed to the first quantum generator;

[0029] Then, the first quantum generator is used for the input image x i The translation is performed to obtain a translated image, which flows to the first discriminator and the first auxiliary classical convolutional neural network. The first discriminator determines the authenticity of the translated image and calculates the adversarial loss of the first discriminator. The first auxiliary classical convolutional neural network reconstructs the generated image again and calculates the adversarial loss, cycle consistency loss, and quality perception loss of the first quantum generator.

[0030] Finally, the second quantum generator is used to generate the input image y jThe translation is performed to obtain a translated image, which flows to the second discriminator and the second auxiliary classical convolutional neural network. The second discriminator judges the authenticity of the translated image and calculates the adversarial loss of the second discriminator. The second discriminator flows to the second auxiliary classical convolutional neural network to reconstruct the generated image again and calculate the adversarial loss, cycle consistency loss and quality perception loss of the second quantum generator.

[0031] The total loss function of each quantum generator consists of the weighted sum of adversarial loss, cycle consistency loss, and quality-aware loss.

[0032] The adversarial loss uses Wassterin distance and gradient penalty, the cycle consistency loss uses F1 distance, and the quality-aware loss uses the SSIM score of the image.

[0033] The specific process of step S6 is as follows:

[0034] Step S61: Input the image to be translated in the test set, divide the image horizontally into image blocks of size 1*32, and input them into the required quantum generator;

[0035] Step S62: the input image block is amplitude encoded into 32 quantum states by the encoding module of the sub-quantum generator, and then forward propagated through the quantum circuit module containing parameters, and finally 32 classical image block pixel values ​​are obtained by quantum state measurement;

[0036] Step S63: splice the 32 classic image pixel blocks to obtain a complete image, and generate a translated target domain result image.

[0037] The specific process of step S7 is as follows:

[0038] Step S71, for the target domain result image generated after translation obtained in step S6, the row interval of the image to be processed is customized to be [0:8], [26:32];

[0039] Step S72: Set the pixel value of the customized image target processing area to 0.

[0040] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, call all or part of the steps of the method.

[0041] Compared with the prior art, the present invention has the following beneficial effects:

[0042] 1. This invention innovatively applies quantum computing technology to the field of image translation and proposes a novel reversible quantum architecture.

[0043] 2. Innovatively combine classical and quantum technologies. By introducing the classical image quality metric feature similarity index SSIM into the target loss function and deploying auxiliary convolutional neural networks to ensure the implementation of cycle consistency constraints to prevent model collapse, we ensure high fidelity of image translation.

[0044] 3. In view of the reversibility of the image translation task, two quantum generators that are mutually reversible and share parameters are designed based on the reversibility of quantum computing. This can realize image translation in two directions with one set of parameters, greatly improving memory efficiency.

[0045] 4. The present invention realizes image translation using only 31.5KB of memory space and achieves image translation performance comparable to that of current classical field methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 Edge produced in the embodiment of the present invention Digit、Blod digit Thin digit and Denoise datasets are shown.

[0047] Figure 2 This is a reversible hybrid quantum-classical image translation model proposed in the present invention.

[0048] Figure 3 Sub-quantum circuit diagram of the two quantum generators proposed in the present invention.

[0049] Figure 4 Flow chart of the training process of the image translation method proposed in the present invention.

[0050] Figure 5 The flowchart of the testing process of the image translation method proposed in the present invention.

[0051] Figure 6 The results are compared before and after post-processing to generate the translated target domain result image for the present invention.

[0052] Figure 7 Edge in the embodiment of the present invention Comparative display of translation results of Digit images.

[0053] Figure 8 Blod digit in the embodiment of the present invention Comparative display of translation results for Thin digit images.

[0054] Fig. 9 The figure shows the comparative translation results of the Denoise image in the embodiment of the present invention.

[0055] Fig.10 Edge in the embodiment of the present invention Digit, Blod digit The loss curve of Thin Digit and Denoise during the training process on digit category 0 is shown. DETAILED DESCRIPTION

[0056] The structure and working process of the present invention will be further described below in conjunction with the accompanying drawings.

[0057] The present invention redefines the image translation task by using the reversibility of quantum computing, and for the first time proposes a memory-efficient image translation method based on the reversibility of quantum computing. The present invention makes technical innovations from the following three main aspects: First, in order to improve the memory space utilization efficiency of model parameters, the present invention designs two mutually reversible quantum circuit generators with shared parameters based on the quantum circuit for image generation in the PQWGAN quantum framework, and each generator consists of three parts: an amplitude encoding module, a trainable circuit module, and a quantum state measurement module; Second, in order to prevent mode collapse, the present invention integrates the characteristic similarity index (SSIM), an evaluation index of the classical image quality metric, into the target loss function, and deploys a pair of auxiliary classical neural networks to ensure the execution of periodic consistency; Third, in view of the reversibility of the image translation task, two mutually reversible quantum generators with shared parameters are designed based on the reversibility of quantum computing, which can realize the image translation in two directions with one set of parameters, greatly improving the memory efficiency; The technical solutions adopted by the present invention are as follows:

[0058] The image translation method based on quantum computing reversibility includes the following steps:

[0059] Step S1, prepare an image translation task dataset and divide it into a training set and a test set;

[0060] Step S2, constructing a reversible hybrid quantum-classical image translation model and initializing the model weights;

[0061] Step S3, setting the hyperparameters of the model;

[0062] Step S4, loading the training set, inputting the source domain image and the target domain image, and obtaining the corresponding quantum state;

[0063] Step S5, defining a loss function, training the reversible hybrid quantum-classical image translation model in two stages, and overall performing the two stages of training alternately until Nash equilibrium is reached;

[0064] Step S6: load the test set data, directly use the trained model to perform image translation, input the source domain image to be translated, and obtain the translated target domain result image;

[0065] Step S7: post-processing the translated target domain result image obtained in step S6.

[0066] Specific embodiments, such as Figures 1 to 10 As shown,

[0067] The image translation method based on quantum computing reversibility includes the following steps:

[0068] Step S1: Prepare the image translation task dataset and divide it into training set and test set. The specific steps are as follows:

[0069] Sub-step S11: By performing domain transformation on the MNSIT dataset, three types of image translation task datasets are prepared, namely Edge Digit, Blod digit Thin digit and Denoise datasets, each task covers digits 0-7, a total of 8 datasets, so in order to test the model effect, a total of 24 datasets were made, that is, 24 image translation tasks, each dataset has 1250 pictures, attached Figure 1 The Edge produced in the embodiment of the present invention is shown Digit, Blod digit Thin digit, Denoise dataset; the code for making the dataset has been publicly uploaded to:

[0070] https: / / github.com / yxSMU / A-Quantum-Reversible-Based-Image-Translation-Method / tree / master / DatasetMakeCode.

[0071] Sub-step S12: Each data set is divided into a source domain X and a target domain Y, and the data sets are divided into a training data set and a test data set in a ratio of 8:2; and are saved in the / source / train, / source / test, / target / train, and / target / test folders respectively.

[0072] Sub-step S13: pre-process the images of the data set and set the image size; in this embodiment, all images in the 24 data sets are converted from 28×28 size to a unified 32×32 size.

[0073] Step S2: Construct two mutually reversible quantum generators G and F that share parameters, two auxiliary classical convolutional neural networks Q and R, and two discriminators D with fully connected structures. X and D Y, forming a reversible hybrid quantum-classical image translation model, initializing the model weights, the image translation model in this embodiment is as shown in the attached Figure 1 As shown, in this embodiment, we construct a model for 24 data sets, and the specific steps are as follows:

[0074] Sub-step S21: Construct quantum generators G, F, θ G ,ω F Represent the weights of G and F respectively, θ G With ω F Satisfy θ G =ω F , G and F are composed of 32 5-qubit sub-quantum generators u with the same structure. l (l=1,…N),u k (k=1,…N), u l 、u k satisfy u l u k =u k u l =I, each sub-quantum generator u l 、u k They include amplitude encoding module, quantum circuit module with trainable parameters, and quantum state measurement module; each sub-quantum generator u l 、u k The trainable quantum circuit module contains S = 12 layers, each of which is composed of a rotation layer with parameters and an entanglement layer without parameters. The collection of single-bit rotation quantum gates Rot gates constitutes the rotation layer. The Rot gate can be regarded as a combination of single-qubit gates Rz and Ry:

[0075]

[0076] The collection of CNOT gates without parameters constitutes the entanglement layer,

[0077]

[0078] The parameter of the rotation layer of the kth generator of the sub-quantum generator G is denoted by θ G k , the quantum gate parameters of the nth quantum bit of its L(1,2…S)th layer include the parameters of the parameters recorded as The parameter of the rotation layer of the lth sub-generator of the sub-quantum generator F is denoted by ω F l , the quantum gate parameters of the nth quantum bit of its L(1,2…S)th layer include the parameters of the parameters recorded as The sub-quantum circuit diagram of this embodiment is shown in the attached Figure 2 shown.

[0079] Sub-step S22: Construct two auxiliary classical convolutional neural networks Q and R to ensure that the model implements the cycle consistency constraint. The encoding part uses two convolutional layers for feature extraction, with a convolution kernel size of 4, a step size of 2, and a default padding of 1. This is followed by the residual part. The two convolutional layers form a residual block to enhance the feature representation. The convolution kernel size is 3, the step size is 1, and the default padding is 1. Finally, the decoding part contains two deconvolution layers for image generation. The convolution kernel size is 4, the step size is 2, and the default padding is 1. In the forward propagation, LeakyReLU is used as the activation function. The negative slope parameter of LeakyReLU is set to 0.05 to ensure better handling of the gradient vanishing problem during training. The tanh activation function is used in the last layer to limit the output between -1 and 1.

[0080] Sub-step S23: Construct two discriminant networks D X and D Y The discriminator is a fully connected neural network that uses the discriminator structure in PQWGAN. The first layer is the input layer with 1024 neurons. Then, it passes through two hidden layers containing 512 and 256 neurons respectively. The last layer has only one neuron, which maps the 256-dimensional hidden features to a single output value to represent the authenticity of the input image. Between each fully connected layer, LeakyReLU is used as the activation function, with a negative slope parameter of 0.2 to introduce nonlinearity and prevent the gradient from disappearing.

[0081] Sub-step S24: Randomly initialize the model weights. In this embodiment, the torch.rand() function is used to randomly initialize the model weights.

[0082] At this point, through sub-steps S21, S22, S23, and S24, the “reversible hybrid quantum-classical image translation model” is constructed.

[0083] Step S3: Set the hyperparameters of the model; in this embodiment, the batch size is set to 10, the number of epochs is set to 20; the learning rate of quantum generators G and F is set to 0.01, and the initial learning rate of auxiliary convolutional neural networks Q and R is 0002; the discriminator D X and D Y The initial learning rate is 0.0002; the Adam optimizer is selected, and the two hyperparameters of the Adam optimizer are set to 0 and 0.9 respectively.

[0084] Step S4: Load the training set, input the source domain and target domain images, and the samples of the source domain X and target domain Y of the training set are respectively recorded as N = 1000, the sample follows the distribution x~p data (x), y~pdata (y), the image x of the source domain and the target domain i ,y j The image is divided horizontally into 32 1*32 blocks, x i P (P=1,…32),y j P (P = 1, ... 32) are respectively input into quantum generators G and F, each consisting of 32 sub-quantum generators, and the corresponding quantum state |φ> is obtained after passing through the corresponding sub-quantum generator amplitude coding module i p (P=1,…32), The specific steps are:

[0085] Sub-step S41: For the quantum generator G, the pre-processed 32*32 size image x i After horizontal segmentation, 32 image blocks of size 1*32 are obtained. i P (P = 1, ... 32), the pixel value at the pixel position (r, j) of the image block is represented by F r,j , 32 sub-quantum generators correspond to 32 image blocks respectively, and the 1*32 pixel values ​​of the image blocks are normalized. The amplitude encoding module of the sub-quantum generator encodes the normalized pixel values ​​into the 32 amplitudes of the quantum state |f>. The process is described as Where n = 5, c k =F r,j / (∑F 2 r,j ) 1 / 2 , remember x i P (P=1,…32); the encoded quantum state is |φ> i p (P = 1, ... 32);

[0086] Sub-step S42, for y j Input to the two sub-generators F, and similarly to sub-step S41, the quantum state |φ> is obtained. i p (P = 1, ... 32);

[0087] Step S5: Train the model according to the defined loss function, which is divided into two sub-stages: first, enter the two discriminators D X , D YCalculate the adversarial loss and update the weight stage. After training 2 batches in the discriminator stage each time, enter the stage of alternating quantum generator weight update. According to the adversarial loss, quality-aware loss and cycle consistency loss, weight and update the weights of quantum generators G, F and auxiliary convolutional neural networks Q, R. The second sub-stage adopts the strategy of alternating training and assigning weights to quantum generators G and F. The model as a whole alternates the two stages of training until Nash equilibrium is reached. The code for the training model has been publicly uploaded to

[0088] https: / / github.com / yxSMU / A-Quantum-Reversible-Based-Image-Translation-Method / tree / master / Traning_code_part1 and https: / / github.com / yxSMU / A-Quantum-Reversible-Based-Image-Translation-Method / tree / master / Traning_code_part2; In this embodiment, 24 data sets are trained to obtain 24 image models. The specific steps are as follows:

[0089] Sub-step S51: Update the discriminator D X , D Y Weight sub-stage, input source image y and G(x) to the discriminator D Y , calculate the discriminator D Y Loss:

[0090]

[0091] The dam optimizer updates the discriminator D Y The weights of the input source image x and F(y) are fed into the discriminator D X , calculate the discriminator D X Loss:

[0092]

[0093] The dam optimizer updates the weight D of the discriminator X , and train 2 batches each time in the discriminator stage.

[0094] Sub-step S52: In the sub-stage of updating the weights of quantum generators G, F and auxiliary convolutional neural networks Q, R, a strategy of alternately training quantum generators G and F and assigning weights to each other is adopted. For each batch, the weights of G and Q are first updated through training, and then the weights of G are assigned to F. Then, the weights of F and R are updated through training, and the weights after training and updating are passed to G again. The weights of quantum generators G, F and auxiliary convolutional neural networks Q, R are updated according to the total loss function defined for each quantum generator, and the total loss function of each quantum generator is composed of the adversarial loss L GAN (using Wassterin distance), cycle consistency loss L cyc (using F1 distance) and quality-aware loss L IQA The quantum generator G takes the input image x as a weighted sum of the three parts (using the SSIM score of the image). i Translate to get image y i ′、y i ′ flows to two branches and flows to the discriminator D Y Determine the authenticity of the translated image and calculate D Y Fighting Loss:

[0095]

[0096] in It is in y~p data (y) and y~p G It is obtained by uniform sampling between, λ is the gradient penalty coefficient;

[0097] Flow to the auxiliary classic convolutional neural network Q, reconstruct the generated image Q(G(x)) again, and calculate the cycle consistency loss of G and quality perception loss

[0098]

[0099] The quantum generator F takes the input image y j Translate to get image x i ′,x i ′ flows to two branches and flows to the discriminator D X Determine the authenticity of the translated image, discriminator D X Fighting Loss:

[0100]

[0101] Flow to the auxiliary classic convolutional neural network R, reconstruct the generated image R(F(y)) again, and calculate the cycle consistency loss of F and quality perception loss

[0102]

[0103] in, is between x and p data (x) and x~p F is uniformly sampled between, λ is the gradient penalty coefficient,

[0104] Finally, calculate the total loss function L of quantum generators G and F G , L F :

[0105]

[0106] The training of the two sub-stages of the training discriminator stage and the quantum generator is performed alternately until the Nash equilibrium is reached; in this embodiment, λ=8, ε=10, η=40, ρ=300.

[0107] Step S53: After the model training is completed, other components are discarded, and the two quantum generators G and F are retained for image translation processing of the image to be translated, and the weight file of the quantum generator G is saved. This is because the two quantum generators G and F share the same parameters;

[0108] At this point, through step S1, step S2, step S3, step S4 and step S5, the trained model is ready.

[0109] Step S6: Load the test set data, directly use the trained model to translate the image, input the source domain image to be translated, and obtain the translated target domain result image; the test code for generating the translated target domain image has been publicly uploaded to

[0110] https: / / github.com / yxSMU / A-Quantum-Reversible-Based-Image-Translation-Method / tree / master / Test_code. In this example, we load 24 test data sets. The specific steps are as follows:

[0111] Sub-step S61: Input the image to be translated in the test set and select the required quantum generator. The image is first divided horizontally into blocks of 1*32 in size and input to the required quantum generator in the same way as the image input in sub-step S41.

[0112] Sub-step S62: The input image block is amplitude encoded into 32 quantum states by the encoding module of the sub-quantum generator, and then forward propagated through the quantum circuit module containing parameters, and finally 32 classical image block pixel values ​​are obtained by quantum state measurement.

[0113] Sub-step S63: splicing the 32 classic image pixel blocks to obtain a complete image, and generating a translated target domain result image.

[0114] Step S7: Since the image generated by the PQWGAN framework based on amplitude coding contains noise, the translated target domain result image obtained in step S6 is post-processed to improve the image quality; in this embodiment, the translated target domain result images of the 24 test data sets in step 5 are subjected to the same post-processing steps:

[0115] Sub-step S71: customizing the area to be processed for the generated translated target domain result image obtained in step S6;

[0116] Sub-step S72: setting the pixel value of the customized image target processing area to 0;

[0117] At this point, the "Memory-efficient Image Translation Method Using Quantum Computing Reversibility" has been completed.

[0118] Attached Figure 6 The figure shows the comparison of the translation results before and after post-processing of the present invention; sub-figure (a) is before post-processing, and sub-figure (b) is after post-processing.

[0119] This example evaluates the performance of the model of the present invention from both qualitative and quantitative aspects:

[0120] (1) Qualitative comparison:

[0121] Figure 7 , Figure 8 The Edge in the embodiment of the present invention is shown Digit, Blod digit The translation results of Thin digit images are qualitatively compared with those of three other methods; among them, RevGAN and One2One are reversible image translation methods in the classic field, and CycleGAN is an irreversible image translation method in the classic field; GT represents the ground truth, and each image includes two sub-images (a) and (b); on the left side of each sub-image are selected samples of the numbers 0, 1, and 7 that are enlarged to show the details, and on the right side are test results for all digit categories 0-7; we mark the generated images with particularly obvious noise with red frames, and images with obvious missing pixels with green frames;

[0122] The image translation method guided by the present invention successfully generates images that are almost identical to GT, such as Figure 7 and Figure 8As shown in the figure, this shows that the image translation method guided by the present invention is robust; among all tasks, RevGAN performs best and generates clearer and smoother images on all tasks, which may be because RevGAN uses a more complex decoder-encoder network architecture; One2One performs second, and the images generated by One2One have a small amount of imperceptible noise around the content, such as Figure 7 The numbers 3 and 5 in (a), but in Figure 7 (b) In the task, the images generated by One2One almost all contain a lot of noise; CycleGAN performs averagely and generates blurry and noisy images in all tasks; it is also observed that many generated images have partially missing pixels, such as Figure 7 The numbers 2, 4 and 5 in (a) are Figure 7 Numbers 2, 3, and 4 in (b), and Figure 8 (b) The numbers 3 and 5; The image translation method guided by the present invention works well on some numbers with simple shapes. For example, the test results of numbers 1 and 7 in all tasks are relatively clean and smooth. However, for complex digital shapes, the generated images contain obvious noise; In addition, from the direct observation of the grayscale value, it is found that the difference between the pictures generated by the image translation method guided by the present invention and GT is the most obvious. This is because the images generated under the PQWGAN framework have defects of noise and blur, and the quantum generative adversarial network framework for generating clear and high-quality images needs further exploration; In general, the four methods have achieved good image translation effects in terms of content consistency;

[0123] Attached Fig. 9 The figure shows a qualitative comparison between the translation result of the Denoise image in the embodiment of the present invention and the other two methods. In this embodiment, the translation results of the other three methods are compared, among which RevGAN is a method of denoising by deep learning, and Gaussian filter is a traditional denoising method. The present invention has an obvious denoising effect. Although the denoising effect is not as good as that of RevGAN with a complex network structure, it exceeds the traditional Gaussian filter denoising.

[0124] (2) Quantitative comparison. The quantitative comparison indicators include Frechet Inception distance score (FID), Frobenius norm (F-norm), and signal-to-noise ratio (SNR). Downward arrows indicate that the smaller the value, the better, and upward arrows indicate that the larger the value, the better. Red indicates the best performance, and blue indicates the worst performance:

[0125] Table 1: Qualitative comparison of the image translation results in the Edge→Digit direction of the embodiment of the present invention and the other three methods

[0126]

[0127] Table 2: In the embodiments of the present invention, g it → Ed g Qualitative comparison of the translation results of the image in the e direction with the other three methods

[0128]

[0129] Table 3: Qualitative comparison of the translation results of the image in the direction of Blod digit→Thin digit in the embodiment of the present invention and the other three methods

[0130]

[0131] Table 4: Qualitative comparison of the translation results of images in the Thin digit→Blod digit direction in the embodiment of the present invention and the other three methods

[0132]

[0133] Table 5: Qualitative comparison of the translation results of Denoise images in the embodiment of the present invention and the other three methods

[0134]

[0135] In Table 1, Table 2, Table 3 and Table 4, RevGAN has Digit and Blod digit The Thin Digit task consistently achieves the highest scores in almost all metrics (FID, F-norm, SNR) in both directions. One2One performs second, maintaining a stable intermediate level. Lower scores appear in the calculation results of CycleGAN and the translation model guided by our method; overall, the numerical differences between all methods are not large, and numerically, the translation model guided by our method is closer to the performance of Cyclgan.

[0136] Table 5 is a quantitative comparison of the translation results of the Denoise image in the embodiment of the present invention and the other two methods; RevGAN performs best in both FID and SNR indicators, because RevGAN has a complex network structure; although the performance of the translation model guided by this method is not as good as RevGAN, compared with Gaussian filtering denoising, if the slight difference in the decimal part is ignored, the two methods have the same FID value, and the translation model guided by this method has significant superiority in the SNR indicator;

[0137] The model for memory-efficient image translation based on quantum computing reversibility guided by this method has the smallest memory footprint, only 31.5KB, as shown in Table 4:

[0138]

[0139] Attached Fig.10 The Edge task in the embodiment of the present invention Digit、Blod digit The loss curves of Thin Digit and Denoise during the training process on the digit category 0 are shown. These loss function curves all show a stable convergence process, indicating that the model training is effective. Digit training curve on digital category 0. Sub-figure b shows the task Blod digit The training curve of Thin digit on digital category 0. Sub-figure c shows the training curve of task Denoise on digital category 0.

[0140] In summary, this invention applies quantum computing technology to the field of image translation for the first time, and proposes a novel reversible quantum architecture that innovatively combines classical technology and quantum technology. Aiming at the reversibility of image translation tasks, this invention uses quantum computing reversibility to design two mutually reversible quantum circuit generators with shared parameters, so as to achieve image translation in two directions with one set of parameters, thereby improving the memory space efficiency of model parameters.

[0141] To prevent mode collapse, the present invention integrates the classic image quality metric Feature Similarity Index (SSIM) into the objective loss function and deploys a pair of auxiliary classical neural networks to ensure cycle-consistent execution.

[0142] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, call all or part of the steps of the method.

[0143] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.

[0144] Those skilled in the art should understand that they can implement variations by combining the prior art and the above embodiments. Such variations do not affect the essence of the present solution and are not described in detail here.

[0145] It should be understood that the present solution is not limited to the above-mentioned specific implementation methods, and the devices and structures not described in detail should be understood to be implemented in a common manner in the art; any technician familiar with the art can use the above-disclosed methods and technical contents to make many possible changes and modifications to the technical solution of the present solution without departing from the scope of the technical solution of the present solution, or modify it into an equivalent embodiment with equivalent changes, which does not affect the essential content of the present solution. Therefore, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present solution without departing from the content of the technical solution of the present solution still falls within the scope of protection of the technical solution of the present solution.

Claims

1. An image translation method based on the reversibility of quantum computing, characterized by: The steps include: Step S1, prepare an image translation task dataset and divide it into a training set and a test set; Step S2, constructing a reversible hybrid quantum-classical image translation model and initializing the model weights; Step S3, setting the hyperparameters of the model; Step S4, loading the training set, inputting the source domain image and the target domain image, and obtaining the corresponding quantum state; Step S5, defining a loss function, training the reversible hybrid quantum-classical image translation model in two stages, and overall performing the two stages of training alternately until Nash equilibrium is reached; Step S6: load the test set data, directly use the trained model to perform image translation, input the source domain image to be translated, and obtain the translated target domain result image; Step S7: post-processing the translated target domain result image obtained in step S6.

2. The image translation method based on quantum computing reversibility according to claim 1, characterized in that: In step S2, the reversible hybrid quantum-classical image translation model includes two mutually reversible and parameter-sharing quantum generators, two auxiliary classical convolutional neural networks, and two discriminators with a fully connected structure, wherein each quantum generator includes 32 5-qubit sub-quantum generators of the same structure; the sub-quantum generators respectively include an amplitude encoding module, a quantum circuit module containing trainable parameters, and a quantum state measurement module; wherein the trainable quantum circuit module of each sub-quantum generator includes 12 layers, each layer consisting of a rotation layer containing parameters and an entanglement layer without parameters, wherein the rotation layer is composed of a set of single-bit rotation quantum gates Rot gates, and the entanglement layer is composed of a set of CNOT gates without parameters; Auxiliary classic convolutional neural network, the encoding part uses two convolutional layers for feature extraction, and the decoding part contains two deconvolutional layers for image generation. In the forward propagation, LeakyReLU is used as the activation function, and the last layer uses the tanh activation function to limit the output between -1 and 1; The two discriminant networks adopt the discriminator structure in PQWGAN. The first layer is the input layer with 1024 neurons. Then, it passes through two hidden layers containing 512 and 256 neurons respectively. The last layer has only one neuron, which maps the 256-dimensional hidden features to a single output value to represent the authenticity of the input image. LeakyReLU is used as the activation function between each fully connected layer.

3. The image translation method based on quantum computing reversibility according to claim 2 is characterized in that: The specific process of step S4 is as follows: Step S41: pre-process the images in the training set to obtain a 32*32 source domain image x i and the target domain image y j ; Step S42: The preprocessed source domain image x i Input to the quantum generator G, and after horizontal block division, 32 1*32 image blocks are obtained. The 32 sub-quantum generators correspond to the 32 image blocks respectively. The 1*32 pixel values ​​of the image blocks are normalized. The amplitude encoding module of the sub-quantum generator encodes the normalized pixel values ​​into the 32 amplitudes of the quantum state |f> to obtain the encoded quantum state. Step S43: The preprocessed target domain image y j Input to another quantum generator F, and according to the processing process of step S42, obtain the encoded quantum state.

4. The image translation method based on quantum computing reversibility according to claim 3 is characterized in that: In step S5, the specific process of training the reversible hybrid quantum-classical image translation model is as follows: Step S51, update the weight sub-stage of the two discriminators, input the picture generated by the quantum generator G in step S41 to the corresponding discriminator, calculate the loss of the discriminator, and apply the Adam optimizer to update the weight of the discriminator; input the picture generated by the quantum generator F in step S41 to another discriminator, calculate the loss of the discriminator, and apply the Adam optimizer to update the weight of the discriminator; Step S52, updating the quantum generator and auxiliary convolutional neural network weight sub-stage, adopting the method of alternating training and assigning weights to each other for the two quantum generators, for each batch, the quantum generator and the auxiliary convolutional neural network update the weights according to the defined total loss function of each quantum generator, and alternately perform the training of the two sub-stages of the quantum generator and the discriminator stage until the Nash equilibrium; Step S53: After the model training is completed, the weight file of the first quantum generator is saved so that the two quantum generators share the same parameters to perform two-directional image translation tasks.

5. The image translation method based on quantum computing reversibility according to claim 4 is characterized in that: The method of alternately training two quantum generators and assigning weights to each other is as follows: First, the weights of the first quantum generator and the first auxiliary convolutional neural network are updated through training, and the weight of the first quantum generator is assigned to the second quantum generator; Secondly, the weights of the second quantum generator and the second auxiliary convolutional neural network are updated through training, and the weights of the second quantum generator after training and updating are again passed to the first quantum generator; Then, the first quantum generator is used for the input image x i The translation is performed to obtain a translated image, which flows to the first discriminator and the first auxiliary classical convolutional neural network. The first discriminator determines the authenticity of the translated image and calculates the adversarial loss of the first discriminator. The first auxiliary classical convolutional neural network reconstructs the generated image again and calculates the adversarial loss, cycle consistency loss, and quality perception loss of the first quantum generator. Finally, the second quantum generator is used to generate the input image y j The translation is performed to obtain a translated image, which flows to the second discriminator and the second auxiliary classical convolutional neural network. The second discriminator judges the authenticity of the translated image and calculates the adversarial loss of the second discriminator. The second discriminator flows to the second auxiliary classical convolutional neural network to reconstruct the generated image again and calculate the adversarial loss, cycle consistency loss and quality perception loss of the second quantum generator.

6. The image translation method based on quantum computing reversibility according to claim 5, characterized in that: The total loss function of each quantum generator consists of the weighted sum of three parts: adversarial loss, cycle consistency loss, and quality-aware loss.

7. The image translation method based on quantum computing reversibility according to claim 6, characterized in that: The adversarial loss uses Wassterin distance and gradient penalty, the cycle consistency loss uses F1 distance, the quality-aware loss uses the SSIM score of the image, and the spatial consistency loss uses the loss score.

8. The image translation method based on quantum computing reversibility according to claim 1, characterized in that: The specific process of step S6 is as follows: Step S61: Input the image to be translated in the test set, divide the image horizontally into image blocks of size 1*32, and input them into the required quantum generator; Step S62: the input image block is amplitude encoded into 32 quantum states by the encoding module of the sub-quantum generator, and then forward propagated through the quantum circuit module containing parameters, and finally 32 classical image block pixel values ​​are obtained by quantum state measurement; Step S63: splice the 32 classic image pixel blocks to obtain a complete image, and generate a translated target domain result image.

9. The image translation method based on quantum computing reversibility according to claim 8, characterized in that: The specific process of step S7 is as follows: Step S71, for the generated translated target domain result image obtained in step S6, the row interval to be processed is customized to be [0:8], [26:32]; Step S72: Set the pixel value of the customized image target processing area to 0.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, all or part of the steps of the method described in any one of claims 1 to 9 are called.