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
评论列表
文章目录