def trainLoop(num_epochs, batch_size, gen_lr, disc_lr, gen_train_freq, disc_train_freq, logger): # Create run directory for current training run os.chdir(os.path.expanduser('~') + '/Research/psig-gan/runs/') run_dir = str(datetime.datetime.now()).replace( ' ', '', ) + "--" + "disc_lr" + str(disc_lr) + " " + "gen_lr" + str( gen_lr) + " " + "gen_train_freq" + str( gen_train_freq) + " " + "disc_train_freq" + str( disc_train_freq) + " " + "num_epochs" + str(num_epochs) os.mkdir(run_dir) # Instantiate GAN gan = DCGAN(latent_shape=100, output_image_shape=512, num_gen_images=batch_size, gen_filter_size=6, discrim_filter_size=5, gen_num_channels=128, discrim_num_channels=64) # Load real grassweeds image data data_path = '/home/data/GrassClover/' data_batch = util.createDataBatch(data_path, batch_size, 512) # Execute training loop train(gan, data_batch, num_epochs, run_dir, gen_lr, disc_lr, gen_train_freq, disc_train_freq, logger)
def trainLoop(num_epochs, batch_size, gen_lr, disc_lr, gen_train_freq, disc_train_freq, logger): # Create run directory for current training run os.chdir(os.path.expanduser('~') + '/psig-gan/runs/') run_dir = str(datetime.datetime.now()).replace(' ','',) + "--" + "disc_lr"+ str(disc_lr) + " " + "gen_lr"+ str(gen_lr) + " " + "gen_train_freq" + str(gen_train_freq) + " " + "disc_train_freq" + str(disc_train_freq) + " " + "num_epochs"+ str(num_epochs) os.mkdir(run_dir) # Instantiate GAN gan = DCGAN(latent_shape=100, output_image_shape=256, num_gen_images=batch_size, gen_filter_size=5, discrim_filter_size=5, gen_num_channels=128, discrim_num_channels=64) # Load real grassweeds image data data_path = '/home/data/dcgan-data/' data_batch = util.createDataBatch(data_path,batch_size) # Define Comet-ML API key here for error logging comet_api_key = 'Gdy4QDrOmu0P01XuBI33rPuIS' #Define Comet Project Name logger = Experiment(comet_api_key, project_name="psig-gan") #Define experiment name logger.set_name("disc_lr"+ str(disc_lr) + " " + "gen_lr"+ str(gen_lr) + " " + "gen_train_freq"+ str(gen_train_freq) + " " + "disc_train_freq" + str(disc_train_freq) + " " + "num_epochs"+ str(num_epochs)) # Execute training loop train(gan, data_batch, num_epochs, run_dir, gen_lr, disc_lr, gen_train_freq, disc_train_freq, logger)
if __name__ == "__main__": # set GPU here os.environ["CUDA_VISIBLE_DEVICES"] = "0" # Define Comet-ML API key here for error logging comet_api_key = 'Gdy4QDrOmu0P01XuBI33rPuIS' #Define Comet Project Name logger = Experiment(comet_api_key, project_name="psig-gan") #Define experiment name logger.set_name("discrim-only training") #+ str( datetime.datetime.now().replace(' ','',) )) #define epochs and lr here num_epochs = 15 batch_size = 64 disc_lr = 0.01 # Load real grassweeds image data data_path = '/home/data/dcgan-data/' data_batch = util.createDataBatch(data_path,batch_size) #make gan object here gan = DCGAN(latent_shape=100, output_image_shape=256, num_gen_images=batch_size, gen_filter_size=5, discrim_filter_size=5, gen_num_channels=128, discrim_num_channels=64) # call discrim training loop train_discrim(gan,disc_lr, data_batch, num_epochs, logger, batch_size)