Esempio n. 1
0
def get_model_paths(model_dir):
    '''Returns all model paths in the model_dir.'''
    all_models = gfile.Glob(os.path.join(model_dir, '*.meta'))
    model_filenames = [os.path.basename(m) for m in all_models]
    model_numbers_names = [
        (shipname.detect_model_num(m), shipname.detect_model_name(m))
        for m in model_filenames]
    model_names = sorted(model_numbers_names)
    return [os.path.join(model_dir, name[1]) for name in model_names]
Esempio n. 2
0
def get_latest_model():
    """Finds the latest model, returning its model number and name

    Returns: (17, 000017-modelname)
    """
    all_models = gfile.Glob(os.path.join(MODELS_DIR, '*.meta'))
    model_filenames = [os.path.basename(m) for m in all_models]
    model_numbers_names = [
        (shipname.detect_model_num(m), shipname.detect_model_name(m))
        for m in model_filenames]
    latest_model = sorted(model_numbers_names, reverse=True)[0]
    return latest_model
Esempio n. 3
0
def get_models():
    """Finds all models, returning a list of model number and names
    sorted increasing.
    Returns: [(13, 000013-modelname), (17, 000017-modelname), ...etc]
    """
    # all_models = glob.glob(os.path.join(MODELS_DIR, '*.meta'))
    all_models = glob.glob(os.path.join(MODELS_DIR, '*'))
    model_filenames = [os.path.basename(m) for m in all_models]
    model_numbers_names = sorted([(shipname.detect_model_num(m),
                                   shipname.detect_model_name(m))
                                  for m in model_filenames])
    return model_numbers_names
Esempio n. 4
0
def get_models():
    """Finds all models, returning a list of model number and names
    sorted increasing.

    Returns: [(13, 000013-modelname), (17, 000017-modelname), ...etc]
    """
    all_models = gfile.Glob(os.path.join(MODELS_DIR, '*.meta'))
    model_filenames = [os.path.basename(m) for m in all_models]
    model_numbers_names = sorted([
        (shipname.detect_model_num(m), shipname.detect_model_name(m))
        for m in model_filenames])
    return model_numbers_names
Esempio n. 5
0
def get_latest_model():
    """Finds the latest model, returning its model number and name

    Returns: (17, 000017-modelname)
    """
    all_models = gfile.Glob(os.path.join(MODELS_DIR, '*.meta'))
    model_filenames = [os.path.basename(m) for m in all_models]
    model_numbers_names = [
        (shipname.detect_model_num(m), shipname.detect_model_name(m))
        for m in model_filenames]
    latest_model = sorted(model_numbers_names, reverse=True)[0]
    return latest_model
Esempio n. 6
0
 def test_detect_name(self):
     string = '000017-model.index'
     detected_name = shipname.detect_model_name(string)
     self.assertEqual('000017-model', detected_name)
Esempio n. 7
0
 def test_detect_name(self):
     string = '000017-model.index'
     detected_name = shipname.detect_model_name(string)
     self.assertEqual(detected_name, '000017-model')