def main(): # Parse the CLI arguments. args = parser.parse_args() # create directory for saving trained models. if not os.path.exists('models'): os.makedirs('models') # Create the tensorflow dataset. ds = DataLoader(args.input_dir, args.target_dir, args.image_size).dataset(args.batch_size) # Initialize the GAN object. gan = FastSRGAN(args) if args.dis != None and args.gen != None: print("Loading pre-trained generator...") gan.generator = keras.models.load_model(args.gen) print("Loading pre-trained discriminator...") gan.discriminator = keras.models.load_model(args.dis) else: # Define the directory for saving pretrainig loss tensorboard summary. pretrain_summary_writer = tf.summary.create_file_writer( 'logs/pretrain') # Run pre-training. pretrain_generator(gan, ds, pretrain_summary_writer) # Define the directory for saving the SRGAN training tensorbaord summary. train_summary_writer = tf.summary.create_file_writer('logs/train') # Run training. for epoch in range(args.epochs): print("Training Epoch #", epoch) train(gan, ds, args.save_iter, train_summary_writer)
def main(): # 分析/处理CLI参数. args = parser.parse_args() # 创建目录以存储训练的模型 if not os.path.exists('models'): os.makedirs('models') # 创建tensorflow数据集 ds = DataLoader(args.image_dir, args.hr_size).dataset(args.batch_size) # 初始化GAN对象 gan = FastSRGAN(args) # 定义保存预训练loss tensorboard摘要的目录 pretrain_summary_writer = tf.summary.create_file_writer('logs/pretrain') # 执行预训练 pretrain_generator(gan, ds, pretrain_summary_writer) # 定义保存SRGAN训练tensorbaord摘要的目录 train_summary_writer = tf.summary.create_file_writer('logs/train') # 执行训练 for _ in range(args.epochs): train(gan, ds, args.save_iter, train_summary_writer)
def main(): # Parse the CLI arguments. args = parser.parse_args() # create directory for saving trained models. if not os.path.exists('models'): os.makedirs('models') # Create the tensorflow dataset. ds = DataLoader(args.image_dir, args.hr_size).dataset(args.batch_size) # Initialize the GAN object. gan = FastSRGAN(args) # Define the directory for saving pretrainig loss tensorboard summary. pretrain_summary_writer = tf.summary.create_file_writer('logs/pretrain') # Run pre-training. pretrain_generator(gan, ds, pretrain_summary_writer) # Define the directory for saving the SRGAN training tensorbaord summary. train_summary_writer = tf.summary.create_file_writer('logs/train') # Run training. for _ in range(args.epochs): train(gan, ds, args.save_iter, train_summary_writer)
def main(): # Parse the CLI arguments. args = parser.parse_args() # create directory for saving trained models. if not os.path.exists('models'): os.makedirs('models') # Create the tensorflow dataset. print('Dataset Loading.....') ds = DataLoader(args.image_dir, args.hr_size).dataset(args.batch_size) print('Complete!') # Initialize the GAN object. print('GAN Initializing......') gan = FastSRGAN(args) print('Complete!') # Define the directory for saving pretrainig loss tensorboard summary. print('Pretraon_summary_writing.....') pretrain_summary_writer = tf.summary.create_file_writer('logs/pretrain') print('Complete!') # Run pre-training. print('Run Pre-training.....') pretrain_generator(gan, ds, pretrain_summary_writer) print('Complete!') # Define the directory for saving the SRGAN training tensorbaord summary. train_summary_writer = tf.summary.create_file_writer('logs/train') # Run training. print('===== Training Start =====') for i in range(args.epochs): print('epoch = {:02d}/{:02d}'.format(i+1, args.epochs)) train(gan, ds, args.save_iter, train_summary_writer) print('Done!')