diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 96f4167..31fc103 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -19,11 +19,14 @@
-
-
-
+
+
+
+
+
-
+
+
@@ -81,7 +84,7 @@
-
+
@@ -158,7 +161,7 @@
-
+
@@ -189,7 +192,7 @@
-
+
@@ -199,7 +202,7 @@
-
+
@@ -212,13 +215,13 @@
-
-
+
+
-
-
+
+
@@ -247,7 +250,7 @@
-
+
1589815443652
@@ -277,7 +280,21 @@
1589918562733
-
+
+ 1589952733192
+
+
+
+ 1589952733192
+
+
+ 1589952979012
+
+
+
+ 1589952979012
+
+
@@ -301,7 +318,9 @@
-
+
+
+
diff --git a/coder/image.py b/coder/image.py
index 50114d1..addaea2 100644
--- a/coder/image.py
+++ b/coder/image.py
@@ -1,31 +1,63 @@
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
+from sklearn import datasets
+from sklearn.metrics import accuracy_score
+from sklearn.neural_network import MLPClassifier
import cv2
-def image():
- img = cv2.cvtColor(cv2.imread('test.jpg'), cv2.COLOR_BGR2GRAY)
- img = cv2.GaussianBlur(img, (15, 15), 0) # poprawia jakosc
- img = cv2.resize(img, (8, 8), interpolation=cv2.INTER_AREA)
+# training
+# recznie napisane cyfry
+digits = datasets.load_digits()
- print(type(img))
- print(img.shape)
- print(img)
- plt.imshow(img, cmap='binary')
- plt.show()
+y = digits.target
+x = digits.images.reshape((len(digits.images), -1))
- data = []
+x_train = x[:1000000]
+y_train = y[:1000000]
+x_test = x[1000:]
+y_test = y[1000:]
- rows, cols = img.shape
- for i in range(rows):
- for j in range(cols):
- k = img[i, j]
- if k > 200:
- k = 0 # brak czarnego
- else:
- k = 1
+mlp = MLPClassifier(hidden_layer_sizes=(15,), activation='logistic', alpha=1e-4,
+ solver='sgd', tol=1e-4, random_state=1,
+ learning_rate_init=.1, verbose=True)
- data.append(k)
+mlp.fit(x_train, y_train)
+
+predictions = mlp.predict(x_test)
+print(accuracy_score(y_test, predictions))
+
+
+# image
+
+img = cv2.cvtColor(cv2.imread('test3.png'), cv2.COLOR_BGR2GRAY)
+img = cv2.GaussianBlur(img, (5, 5), 0) # poprawia jakosc
+img = cv2.resize(img, (8, 8), interpolation=cv2.INTER_AREA)
+
+print(type(img))
+print(img.shape)
+print(img)
+plt.imshow(img ,cmap='binary')
+plt.show()
+
+data = []
+
+rows, cols = img.shape
+for i in range(rows):
+ for j in range(cols):
+ k = img[i, j]
+ if k > 100:
+ k = 0 # brak czarnego
+ else:
+ k = 1
+
+ data.append(k)
+
+data = np.asarray(data, dtype=np.float32)
+print(data)
+
+predictions = mlp.predict([data])
+
+print("Liczba to:", predictions[0])
- print(data)
diff --git a/coder/rocognizer.py b/coder/rocognizer.py
new file mode 100644
index 0000000..99b0ade
--- /dev/null
+++ b/coder/rocognizer.py
@@ -0,0 +1,13 @@
+import matplotlib.pyplot as plt
+import numpy as np
+from numpy import asarray
+from sklearn import datasets
+from sklearn.neural_network import MLPClassifier
+from sklearn.metrics import accuracy_score
+from PIL import Image
+import pygame
+import functions
+import sys
+import time
+
+
diff --git a/coder/test1.jpg b/coder/test1.jpg
new file mode 100644
index 0000000..ac039f4
Binary files /dev/null and b/coder/test1.jpg differ
diff --git a/coder/test3.png b/coder/test3.png
new file mode 100644
index 0000000..06e94af
Binary files /dev/null and b/coder/test3.png differ
diff --git a/coder/test9.png b/coder/test9.png
new file mode 100644
index 0000000..c4cca14
Binary files /dev/null and b/coder/test9.png differ
diff --git a/coder/train.py b/coder/train.py
deleted file mode 100644
index 4c8abd1..0000000
--- a/coder/train.py
+++ /dev/null
@@ -1,29 +0,0 @@
-import matplotlib.pyplot as plt
-import numpy as np
-from numpy import asarray
-from sklearn import datasets
-from sklearn.neural_network import MLPClassifier
-from sklearn.metrics import accuracy_score
-from PIL import Image
-
-
-def train():
- # recznie napisane cyfry
- digits = datasets.load_digits()
-
- y = digits.target
- x = digits.images.reshape((len(digits.images), -1))
-
- x_train = x[:1000000]
- y_train = y[:1000000]
- x_test = x[1000:]
- y_test = y[1000:]
-
- mlp = MLPClassifier(hidden_layer_sizes=(15,), activation='logistic', alpha=1e-4,
- solver='sgd', tol=1e-4, random_state=1,
- learning_rate_init=.1, verbose=True)
-
- mlp.fit(x_train, y_train)
-
- predictions = mlp.predict(x_test)
- print(accuracy_score(y_test, predictions))
diff --git a/coder/train_nn.py b/coder/train_nn.py
new file mode 100644
index 0000000..30cf910
--- /dev/null
+++ b/coder/train_nn.py
@@ -0,0 +1,30 @@
+import matplotlib.pyplot as plt
+import numpy as np
+from numpy import asarray
+import pygame
+from sklearn import datasets
+from sklearn.neural_network import MLPClassifier
+from sklearn.metrics import accuracy_score
+from PIL import Image
+
+
+# recznie napisane cyfry
+digits = datasets.load_digits()
+
+y = digits.target
+x = digits.images.reshape((len(digits.images), -1))
+
+x_train = x[:1000000]
+y_train = y[:1000000]
+x_test = x[1000:]
+y_test = y[1000:]
+
+mlp = MLPClassifier(hidden_layer_sizes=(15,), activation='logistic', alpha=1e-4,
+ solver='sgd', tol=1e-4, random_state=1,
+ learning_rate_init=.1, verbose=True)
+
+mlp.fit(x_train, y_train)
+
+predictions = mlp.predict(x_test)
+print(accuracy_score(y_test, predictions))
+print(x_test[1])
\ No newline at end of file