def init(): util.lock() util.set_img_format() util.override_keras_directory_iterator_next() util.set_classes_from_train_dir() util.set_samples_info() if not os.path.exists(config.trained_dir): os.mkdir(config.trained_dir)
def init(): util.lock()#detect previous precess has completed or not util.set_img_format()#set image format: channels first or channels last util.override_keras_directory_iterator_next() util.set_classes_from_train_dir()#data_dir: data/sorted/train/ util.set_samples_info() if util.get_keras_backend_name() != 'theano': util.tf_allow_growth() if not os.path.exists(config.trained_dir): os.mkdir(config.trained_dir)
def init(): util.lock() util.set_img_format() util.override_keras_directory_iterator_next() util.set_classes_from_train_dir() util.set_samples_info() if util.get_keras_backend_name() != 'theano': util.tf_allow_growth() if not os.path.exists(config.trained_dir): os.mkdir(config.trained_dir)
def init(): util.lock() util.set_img_format() util.override_keras_directory_iterator_next() util.set_classes_from_train_dir() util.set_samples_info() if util.get_keras_backend_name() != 'theano': util.tf_allow_growth() if not os.path.exists(config.trained_dir): os.mkdir(config.trained_dir)
def init(): util.lock() util.set_img_format() # Pay extremely attention to the RGB->BGR, the next method is override. util.override_keras_directory_iterator_next() util.set_classes_from_train_dir() util.set_samples_info() if util.get_keras_backend_name() != 'theano': util.tf_allow_growth() if not os.path.exists(config.trained_dir): os.mkdir(config.trained_dir)
help='will freeze the first N layers and unfreeze the rest') return parser.parse_args() if __name__ == '__main__': try: args = parse_args() if args.data_dir: config.data_dir = args.data_dir config.set_paths() if args.model: config.model = args.model util.lock() util.override_keras_directory_iterator_next() util.set_classes_from_train_dir() util.set_samples_info() if not os.path.exists(config.trained_dir): os.mkdir(config.trained_dir) class_weight = util.get_class_weight(config.train_dir) # TODO: create class instance without dynamic module import model = util.get_model_class_instance( class_weight=class_weight, nb_epoch=args.nb_epoch, freeze_layers_number=args.freeze_layers_number) model.train() print('Training is finished!') except (KeyboardInterrupt, SystemExit): util.unlock()