Image to image translation with generative adversiale networks (translation of satelite image to Google maps image )par Abel Azize Souna and Ilyes Chaki Université Hassiba ben Bouali de Chlef - Licence informatique 2022 |
4.5 Discriminator ImplementationListing 4.4: encoder_block 1 def define_discriminator(image_shape): 2 init = RandomNormal(stddev=0.02) 3 in_src_image = Input(shape=image_shape) 4 in_target_image = Input(shape=image_shape) 5 merged = Concatenate()([in_src_image, in_target_image]) 6 d = Conv2D(64, (4,4), strides=(2,2), padding='same', kernel_initializer=init)( merged) 7 d = LeakyReLU(alpha=0.2)(d) 8 d = Conv2D(128, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(d) 9 d = BatchNormalization()(d) 10 d = LeakyReLU(alpha=0.2)(d) 11 d = Conv2D(256, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(d) 12 d = BatchNormalization()(d) 13 d = LeakyReLU(alpha=0.2)(d) 14 d = Conv2D(512, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(d) 31 4.6 Pix2Pix Implementation 15 d = BatchNormalization()(d) 16 d = LeakyReLU(alpha=0.2)(d) 17 d = Conv2D(512, (4,4), padding='same', kernel_initializer=init)(d) 18 d = BatchNormalization()(d) 19 d = LeakyReLU(alpha=0.2)(d) 20 d = Conv2D(1, (4,4), padding='same', kernel_initializer=init)(d) 21 patch_out = Activation('sigmoid')(d) 22 model = Model([in_src_image, in_target_image], patch_out) 23 opt = Adam(lr=0.0002, beta_1=0.5) 24 model.compile(loss='binary_crossentropy', optimizer=opt, loss_weights=[0.5]) 25 return model 4.6 Pix2Pix ImplementationListing 4.5: decoder_block 1 def define_gan(g_model, d_model, image_shape): 2 d_model.trainable = False 3 in_src = Input(shape=image_shape) 4 gen_out = g_model(in_src) 5 dis_out = d_model([in_src, gen_out]) 6 model = Model(in_src, [dis_out, gen_out]) 7 opt = Adam(lr=0.0002, beta_1=0.5) 8 model.compile(loss=['binary_crossentropy', 'mae'], optimizer=opt, loss_weights =[1,100]) 9 return model 4.7 Model TrainingListing 4.6: decoder_block 1 def train(d_model, g_model, gan_model, dataset, n_epochs=10000, n_batch=1): 2 n_patch = d_model.output_shape[1] 3 trainA, trainB = dataset 4 for i in range(n_epochs): 5 [X_realA, X_realB], y_real = generate_real_samples(dataset, n_batch, n_patch) 6 X_fakeB, y_fake = generate_fake_samples(g_model, X_realA, n_patch) 7 d_loss1 = d_model.train_on_batch([X_realA, X_realB], y_real) 8 d_loss2 = d_model.train_on_batch([X_realA, X_fakeB], y_fake) 9 g_loss, _, _ = gan_model.train_on_batch(X_realA, [y_real, X_realB]) 10 11 # summarize model performance 12 if (i+1) 'f, 1000 == 0: 13 print('>'f,d, d1['f,.3f] d2['f,.3f] g['f,.3f]' 'f, (i+1, d_loss1, d_loss2, g_loss)) 32 4.8 Model Evaluation14 summarize_performance(i, g_model, dataset) 4.8 Model Evaluationfor the evaluation we used the human perspective for it's both efficient and easy ,this method was proposed and used by Ian Goodfellow et al in the original paper Improved techniques for training gans [24] , there are other methods for the evaluation of the network performance ,one being the inception score that uses the inception network to classify the generated images. 4.9 ConclusionThroughout this project we used the Pix2pix network to implement a translation from satellite images to map images , the first chapter was a introduction to artificial intelligence and machine learning then about deep learning ,then in the second chapter we advanced towards generative modeling and we talked about why it is such a useful architecture, in the same chapter we talked about GAN's and their superior performance in generative modeling ,in the third chapter we spoke on the pix2pix architecture in particular since it`'s the used architecture, in the last chapter we went through the implementation of the code. Since it's introduction by Ian Goodfellow ,generative adversarial networks held great promises ,this is totally understandable for the reason that it represent the creativity form of intelligence and a milestone in the quest of creating general intelligence. The model would generate better results given more training time and data ,so this project can be seen as a prototype and there is a room for improvement. The pix2pix model is also hard to implement cause of it's dataset obligations,the need for a couple of images from the original and the target domain can be realised to a certain degree in the satellite/ map application but is extremely hard for other style transfers,this can be improved using Cycle GAN . I would like this project to be viewed as an example of what GAN's can do ,and for it to serve as an inspiration for people wanting to take on this domain. Bibliography
34 BIBLIOGRAPHY
35 BIBLIOGRAPHY [27] Wikipedia, the free encyclopedia. python. [Online; accessed march 14,2022 ]. 2019. URL: https://fr.m.wikipedia.org/wiki/Fichier:Python.svg. |
|