data2lmdb.py 文件源码

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

项目:train-CRF-RNN 作者: martinkersner 项目源码 文件源码
def split_train_test_imgs(class_names, test_ratio):
  train_imgs = []
  test_imgs = []

  for i in class_names:
    file_name = i + '.txt' 
    num_lines = get_num_lines(file_name)
    num_test_imgs = test_ratio * num_lines
    current_line = 1

    with open(file_name, 'rb') as f:
      for line in f:
        if current_line < num_test_imgs:
          test_imgs.append(line.strip())
        else:
          train_imgs.append(line.strip())

        current_line += 1

  print(str(len(train_imgs)) + ' train images')
  print(str(len(test_imgs)) + ' test images')

  return train_imgs, test_imgs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号