classify.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ISM2017 作者: ybayle 项目源码 文件源码
def read_train_files(indir, separator=" "):
    """Description of read_train_files

    Gather local features and GT from every individual train songs
    """
    utils.print_success("Reading multiple train files")
    indir = utils.abs_path_dir(indir) + "/"
    groundtruths = []
    features = []
    included_extenstions = ["csv"]
    filenames = [fn for fn in os.listdir(indir)
            if any(fn.endswith(ext) for ext in included_extenstions)]
    for index, filename in enumerate(filenames):
        print(str(index + 1) + "/" + str(len(filenames)) + " " + filename)
        sys.stdout.write("\033[F") # Cursor up one line       
        sys.stdout.write("\033[K") # Clear line
        with open(indir + filename, "r") as filep:
            for row in filep:
                line = row.split(separator)
                features.append([float(i) for i in line[:-1]])
                groundtruths.append(line[-1][:-1])
    sys.stdout.write("\033[K") # Clear line
    return features, groundtruths
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号