Skip to main content

Table 1 Pseudocode of algorithm

From: SeparaFill: Two generators connected mural image restoration based on generative adversarial network with skip connect

Initialize the parameters of generator G, discriminators D1 and D2, iterations = n, batch_size = m, and the super parameter k = 1 representing the steps of discriminator

 for number of training iterations do

  for k steps do

      ▪ The m real images \(\left\{ {x^{\left( 1 \right)} ,x^{\left( 2 \right)} , \ldots ,x^{\left( m \right)} } \right\}\) were taken randomly from \(P_{data} \left( x \right)\)

      ▪ The m mask maps \(\left\{ {M_{1} ,M_{2} , \ldots ,M_{m} } \right\}\) were taken in \(M_{mask}\) paired with the images

      ▪ via the HED networks to obtain contour \(sketchgray^{\left( i \right)}\) from \(x^{\left( i \right)}\)

      ▪ \(sketch^{\left( i \right)} = x^{\left( i \right)} \odot sketchgray^{\left( i \right)}\)

      ▪ \(x_{masked}^{\left( i \right)} = x^{\left( i \right)} \odot M\), \(sketch_{masked}^{\left( i \right)} = sketch^{\left( i \right)} \odot M\)

      ▪ \(sketch_{g}^{\left( i \right)} = sketch^{\left( i \right)} \odot M + G_{1} \left( {sketch^{\left( i \right)} ,M} \right) \odot \left( {1 - M} \right)\)

      ▪ \(x_{masked1}^{\left( i \right)} = sketch_{g}^{\left( i \right)} \odot \left( {1 - M} \right) + x_{masked}^{\left( i \right)}\)

      ▪ Image inpainting \(x_{g}^{\left( i \right)} = x_{masked1}^{\left( i \right)} \odot M + G_{2} \left( {x_{masked1}^{\left( i \right)} ,M} \right) \odot \left( {1 - M} \right)\)

      ▪ Calculate the restoration loss \({L}_{dS}\), \({L}_{d}\) based on the input and restore samples

      ▪ Update the parameters of discriminators D1 and D2 through Adam optimization algorithm

  end for

      ▪ Get m samples randomly from \({P}_{data}\left(x\right)\) and \({M}_{mask}\), constructing damaged images \({x}_{masked}^{\left(i\right)}\), \({sketch}_{masked}^{\left(i\right)}\), calculate the loss \({L}_{dS}\), \({L}_{d}\) based on the input samples and restored samples generated by the network

      ▪ Update the parameters of discriminators D1 and D2 through Adam optimization algorithm

  end for