Python utils.parse_args() Examples
The following are 10
code examples of utils.parse_args().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
utils
, or try the search function
.
Example #1
Source File: main.py From MobileNet-V2 with Apache License 2.0 | 5 votes |
def main(): # Parse the JSON arguments config_args = parse_args() # Create the experiment directories _, config_args.summary_dir, config_args.checkpoint_dir = create_experiment_dirs( config_args.experiment_dir) model = MobileNetV2(config_args) if config_args.cuda: model.cuda() cudnn.enabled = True cudnn.benchmark = True print("Loading Data...") data = CIFAR10Data(config_args) print("Data loaded successfully\n") trainer = Train(model, data.trainloader, data.testloader, config_args) if config_args.to_train: try: print("Training...") trainer.train() print("Training Finished\n") except KeyboardInterrupt: pass if config_args.to_test: print("Testing...") trainer.test(data.testloader) print("Testing Finished\n")
Example #2
Source File: train.py From InsightFace-PyTorch with Apache License 2.0 | 5 votes |
def main(): global args args = parse_args() train_net(args)
Example #3
Source File: train.py From CCF-BDCI2019-Multi-person-Face-Recognition-Competition-Baseline with MIT License | 5 votes |
def main(): global args args = parse_args() train_net(args)
Example #4
Source File: train.py From InsightFace-v2 with Apache License 2.0 | 5 votes |
def main(): global args args = parse_args() train_net(args)
Example #5
Source File: train.py From Speech-Transformer with MIT License | 5 votes |
def main(): global args args = parse_args() train_net(args)
Example #6
Source File: stpn_main.py From STPN with Apache License 2.0 | 5 votes |
def main(_): # Parsing Arguments args = utils.parse_args() mode = args.mode train_iter = args.training_num test_iter = args.test_iter ckpt = utils.ckpt_path(args.ckpt) input_list = { 'batch_size': args.batch_size, 'beta': args.beta, 'learning_rate': args.learning_rate, 'ckpt': ckpt, 'class_threshold': args.class_th, 'scale': args.scale} config = tf.ConfigProto() config.gpu_options.allow_growth = True tf.reset_default_graph() model = StpnModel() # Run Model with tf.Session(config=config) as sess: init = tf.global_variables_initializer() if mode == 'train': sess.run(init) train(sess, model, input_list, 'rgb', train_iter) # Train RGB stream sess.run(init) train(sess, model, input_list, 'flow', train_iter) # Train FLOW stream elif mode == 'test': sess.run(init) test(sess, model, init, input_list, test_iter) # Test
Example #7
Source File: train.py From Tacotron2-Mandarin with MIT License | 5 votes |
def main(): global args args = parse_args() train_net(args)
Example #8
Source File: main.py From MobileNet with Apache License 2.0 | 4 votes |
def main(): # Parse the JSON arguments try: config_args = parse_args() except: print("Add a config file using \'--config file_name.json\'") exit(1) # Create the experiment directories _, config_args.summary_dir, config_args.checkpoint_dir = create_experiment_dirs(config_args.experiment_dir) # Reset the default Tensorflow graph tf.reset_default_graph() # Tensorflow specific configuration config = tf.ConfigProto(allow_soft_placement=True) config.gpu_options.allow_growth = True sess = tf.Session(config=config) # Data loading data = DataLoader(config_args.batch_size, config_args.shuffle) print("Loading Data...") config_args.img_height, config_args.img_width, config_args.num_channels, \ config_args.train_data_size, config_args.test_data_size = data.load_data() print("Data loaded\n\n") # Model creation print("Building the model...") model = MobileNet(config_args) print("Model is built successfully\n\n") # Summarizer creation summarizer = Summarizer(sess, config_args.summary_dir) # Train class trainer = Train(sess, model, data, summarizer) if config_args.to_train: try: print("Training...") trainer.train() print("Training Finished\n\n") except KeyboardInterrupt: trainer.save_model() if config_args.to_test: print("Final test!") trainer.test('val') print("Testing Finished\n\n")
Example #9
Source File: main.py From face-antispoofing-using-mobileNet with Apache License 2.0 | 4 votes |
def main(): # Parse the JSON arguments try: config_args = parse_args() except: print("Add a config file using \'--config file_name.json\'") exit(1) # Create the experiment directories _, config_args.summary_dir, config_args.checkpoint_dir = create_experiment_dirs(config_args.experiment_dir) # Reset the default Tensorflow graph tf.reset_default_graph() # Tensorflow specific configuration config = tf.ConfigProto(allow_soft_placement=True) config.gpu_options.allow_growth = True sess = tf.Session(config=config) # Data loading data = DataLoader(config_args.batch_size, config_args.shuffle) print("Loading Data...") config_args.img_height, config_args.img_width, config_args.num_channels, \ config_args.train_data_size, config_args.test_data_size = data.load_data() print("Data loaded\n\n") # Model creation print("Building the model...") model = MobileNet(config_args) print("Model is built successfully\n\n") # Summarizer creation summarizer = Summarizer(sess, config_args.summary_dir) # Train class trainer = Train(sess, model, data, summarizer) if config_args.to_train: try: print("Training...") trainer.train() print("Training Finished\n\n") except KeyboardInterrupt: trainer.save_model() if config_args.to_test: print("Final test!") trainer.test('val') print("Testing Finished\n\n")
Example #10
Source File: main.py From ShuffleNet with Apache License 2.0 | 4 votes |
def main(): # Parse the JSON arguments config_args = parse_args() # Create the experiment directories _, config_args.summary_dir, config_args.checkpoint_dir = create_experiment_dirs(config_args.experiment_dir) # Reset the default Tensorflow graph tf.reset_default_graph() # Tensorflow specific configuration config = tf.ConfigProto(allow_soft_placement=True) config.gpu_options.allow_growth = True sess = tf.Session(config=config) # Data loading # The batch size is equal to 1 when testing to simulate the real experiment. data_batch_size = config_args.batch_size if config_args.train_or_test == "train" else 1 data = DataLoader(data_batch_size, config_args.shuffle) print("Loading Data...") config_args.img_height, config_args.img_width, config_args.num_channels, \ config_args.train_data_size, config_args.test_data_size = data.load_data() print("Data loaded\n\n") # Model creation print("Building the model...") model = ShuffleNet(config_args) print("Model is built successfully\n\n") # Parameters visualization show_parameters() # Summarizer creation summarizer = Summarizer(sess, config_args.summary_dir) # Train class trainer = Train(sess, model, data, summarizer) if config_args.train_or_test == 'train': try: # print("FLOPs for batch size = " + str(config_args.batch_size) + "\n") # calculate_flops() print("Training...") trainer.train() print("Training Finished\n\n") except KeyboardInterrupt: trainer.save_model() elif config_args.train_or_test == 'test': # print("FLOPs for single inference \n") # calculate_flops() # This can be 'val' or 'test' or even 'train' according to the needs. print("Testing...") trainer.test('val') print("Testing Finished\n\n") else: raise ValueError("Train or Test options only are allowed")