def main(): in_arg = get_input_args() data_dir = in_arg.data_dir save_dir = in_arg.save_dir arch = in_arg.arch learning_rate = in_arg.learning_rate hidden_units = in_arg.hidden_units epochs = in_arg.epochs #processing_unit = in_arg.gpu if torch.cuda.is_available() and in_arg.gpu == 'gpu': print('GPU will be used') processing_unit = 'gpu' elif torch.cuda.is_available() == False: print('CPU will be used') processing_unit = 'cpu' print(in_arg) training_dataloaders, validation_dataloaders, testing_dataloaders, class_to_idx = load_datas( data_dir) pre_model = pretrained_model(arch) model = classifier(pre_model, hidden_units) after_train_model = train_model(model, training_dataloaders, validation_dataloaders, learning_rate, epochs, processing_unit) valid_model(after_train_model, testing_dataloaders, processing_unit) save_checkpoint(model, save_dir, class_to_idx)
def main(): assert FLAGS.MODE in ('train', 'valid', 'demo') if FLAGS.MODE == 'demo': demo(FLAGS.checkpoint_dir, FLAGS.show_box) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
def main(): assert FLAGS.MODE in ('train', 'valid', 'demo') if FLAGS.MODE == 'demo': demo(FLAGS.checkpoint_dir, FLAGS.show_box) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
def main(): if SET_MODE == 'video': video(ckpt_dir, show_box) elif SET_MODE == 'train': train_model(train_data) elif SET_MODE == 'test': valid_model(ckpt_dir, valid_data) else: print("Wrong MODE Selected")
def main(): assert FLAGS.MODE in ('train', 'valid', 'demo') if FLAGS.MODE == 'demo': x = demo(FLAGS.checkpoint_dir, FLAGS.show_box, SAMPLE_IMAGE_PATH) print("test: = " + str(x)) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
def main(): assert FLAGS.MODE in ('train', 'valid', 'demo') # FLAGS.MODE 中含有‘train’,‘valid’,‘demo’ 三个字符串 if FLAGS.MODE == 'demo': demo(FLAGS.checkpoint_dir, FLAGS.show_box) # 运行 demo.demo() elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
def main(): assert FLAGS.MODE in ('train', 'valid', 'demo') tf.compat.v1.disable_eager_execution() if FLAGS.MODE == 'demo': demo(FLAGS.checkpoint_dir, FLAGS.show_box) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
def main(): f = input("please input you choose/n") if f == "demo": run_demo() elif f == "model": a1 = input("train?valid?") if a1 == "train": train_model() else: valid_model() else: print("usage: python3 main.py <function>")
def post(self): x = "" self.bytes_to_img(request.form['img']) if FLAGS.MODE == 'demo': img = Image.open('temp_file.jpg') open_cv_image = numpy.array(img) open_cv_image = open_cv_image[:, :, ::-1].copy() x = demo(FLAGS.checkpoint_dir, FLAGS.show_box, open_cv_image) print("test: = " + str(x)) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data) return json.loads(x)
def post(self): x = "" if not request.files: return 'File Not Found' img = Image.open(request.files['file']) if FLAGS.MODE == 'demo': img = Image.open(request.files['file']) open_cv_image = numpy.array(img) open_cv_image = open_cv_image[:, :, ::-1].copy() x = demo(FLAGS.checkpoint_dir, FLAGS.show_box, open_cv_image) print("test: = " + str(x)) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data) return json.loads(x)
def run_model(args): if args.train_or_valid == 'train': train_model() elif args.train_or_valid == 'valid': valid_model()