Skip to content

Commit

Permalink
Edited image sampling to optional during training
Browse files Browse the repository at this point in the history
  • Loading branch information
lydiazajiczek authored Apr 13, 2021
1 parent 35266ef commit 0eca2c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions GAN.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, dataset_name="liver", input_type="fresh", output_type="stiffn
# For the combined model we will only train the generator
self.discriminator.trainable = False

# is input image fake or real?
# Is input image fake or real?
valid = self.discriminator([img_in, fake_out])

self.combined = Model(inputs=[img_in, img_out], outputs=[valid, fake_out])
Expand Down Expand Up @@ -134,7 +134,7 @@ def d_layer(layer_input, filters, f_size=4, bn=True, dropout_rate=0.25):

img_in = Input(shape=self.img_shape_in)

# downsample input image
# Downsample input image
img_in_ds = AveragePooling2D(pool_size=(2, 2), strides=None, padding='valid')(img_in)

img_out = Input(shape=self.img_shape_out)
Expand Down Expand Up @@ -187,8 +187,11 @@ def train(self, epochs, batch_size):

self.generator.save_weights("%s.h5" % self.model_name)

# randomly sample from validation set
self.sample_images(epoch, batch_i=0)
# randomly sample from validation set and generate image
# outputs two-panel image of generated and real image
# uncomment if tweaking network architecture to see if
# generator is converging to something useful
# self.sample_images(epoch, batch_i=0)

def sample_images(self, epoch, batch_i):
os.makedirs('images/%s' % self.dataset_name, exist_ok=True)
Expand Down

0 comments on commit 0eca2c5

Please sign in to comment.