This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_efd.py
63 lines (45 loc) · 2.02 KB
/
run_efd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:mod:`run`
==================
.. module:: run
:platform: Unix, Windows
:synopsis:
.. moduleauthor:: hbldh <[email protected]>
Created on 2016-01-14, 09:10
"""
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
from sudokuextract.extract import extract_sudoku
from sudokuextract.ml import fit
from sudokuextract.utils import download_image, load_image
from sudokuextract import data
#images, labels, X, y = data.create_mnist_dataset()
#data.save_training_data(X, y, data_source='mnist')
#images, labels, X, y = data.create_data_set_from_images('~/Documents/SudokuExtract_Train', force=True)
#data.save_training_data(X, y, data_source='se')
#data.fetch_all_xanadoku_images('~/Documents/SudokuExtract_Test', 'bjornbar')
#image_url = "https://static-secure.guim.co.uk/sys-images/Guardian/Pix/pictures/2013/2/27/1361977880123/Sudoku2437easy.jpg"
the_image = download_image("https://res.cloudinary.com/hzlcxa6rf/image/upload/56d9d0df9f94ac0009519152")
#the_image = load_image('~/Documents/SudokuExtract_Test/56d9aad9ae834500099af4da.jpg')
#the_image = load_image('~/Documents/SudokuExtract_Test/56e006a63e921a0009d40071.jpg')
#the_image = load_image('~/Documents/SudokuExtract_Test/56e0053e3e921a0009d40070.jpg')
#the_image = load_image('~/Documents/SudokuExtract_Test/56e0a6237303ae0009e9a994.jpg')
#the_image = load_image('~/Documents/SudokuExtract_Train/i1.png')
#the_image = load_image('tests/img18.jpg')
#the_image = the_image.rotate(-90)
preds, sudoku, subimage = extract_sudoku(the_image, force=True)
import matplotlib.pyplot as plt
ax = plt.subplot2grid((9, 9+9), (0, 0), colspan=9, rowspan=9)
ax.imshow(subimage, plt.cm.gray)
ax.axis('off')
for k in range(len(sudoku)):
for kk in range(len(sudoku[k])):
ax = plt.subplot2grid((9, 9 + 9), (k, 9+kk))
ax.imshow(sudoku[k][kk], plt.cm.gray)
ax.set_title(str(preds[k, kk]))
ax.axis('off')
plt.show()