Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 5
0
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)
Esempio n. 6
0
    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()
    except Exception as e: