test_se.py 文件源码

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

项目:sudokuextract 作者: hbldh 项目源码 文件源码
def test_se_tardata_sudokus(file_path_base):
    try:
        image_file_name = file_path_base + '.jpg'
        image = load_image(image_file_name)
    except:
        image_file_name = file_path_base + '.png'
        image = load_image(image_file_name)
    with open(file_path_base + '.txt', 'rt') as f:
        correct_parsing = f.read().strip()

    predictions, sudoku, subimage = extract_sudoku(image, classifier(), force=True)
    parsed_sudoku = predictions_to_suduko_string(predictions, oneliner=False)
    if parsed_sudoku != correct_parsing:
        predictions, sudoku, subimage = extract_sudoku(image.rotate(-90), classifier(), force=True)
        parsed_sudoku = predictions_to_suduko_string(predictions, oneliner=False)
    assert parsed_sudoku == correct_parsing


    try:
        os.remove(image_file_name)
        os.remove(file_path_base + '.txt')
        print("Deleted temporary test dir.")
        os.removedirs(os.path.dirname(file_path_base))
    except:
        pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号