fun created
This commit is contained in:
parent
f1ce998628
commit
ddb652119b
@ -3,20 +3,22 @@ from PIL import Image
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
print(type(img))
|
def image():
|
||||||
print(img.shape)
|
img = cv2.cvtColor(cv2.imread('test.jpg'), cv2.COLOR_BGR2GRAY)
|
||||||
print(img)
|
img = cv2.GaussianBlur(img, (15, 15), 0) # poprawia jakosc
|
||||||
plt.imshow(img ,cmap='binary')
|
img = cv2.resize(img, (8, 8), interpolation=cv2.INTER_AREA)
|
||||||
plt.show()
|
|
||||||
|
|
||||||
data = []
|
print(type(img))
|
||||||
|
print(img.shape)
|
||||||
|
print(img)
|
||||||
|
plt.imshow(img, cmap='binary')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
rows, cols = img.shape
|
data = []
|
||||||
for i in range(rows):
|
|
||||||
|
rows, cols = img.shape
|
||||||
|
for i in range(rows):
|
||||||
for j in range(cols):
|
for j in range(cols):
|
||||||
k = img[i, j]
|
k = img[i, j]
|
||||||
if k > 200:
|
if k > 200:
|
||||||
@ -26,4 +28,4 @@ for i in range(rows):
|
|||||||
|
|
||||||
data.append(k)
|
data.append(k)
|
||||||
|
|
||||||
print(data)
|
print(data)
|
||||||
|
@ -6,22 +6,24 @@ from sklearn.neural_network import MLPClassifier
|
|||||||
from sklearn.metrics import accuracy_score
|
from sklearn.metrics import accuracy_score
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
#recznie napisane cyfry
|
|
||||||
digits = datasets.load_digits()
|
|
||||||
|
|
||||||
y = digits.target
|
def train():
|
||||||
x = digits.images.reshape((len(digits.images), -1))
|
# recznie napisane cyfry
|
||||||
|
digits = datasets.load_digits()
|
||||||
|
|
||||||
x_train = x[:1000000]
|
y = digits.target
|
||||||
y_train = y[:1000000]
|
x = digits.images.reshape((len(digits.images), -1))
|
||||||
x_test = x[1000:]
|
|
||||||
y_test = y[1000:]
|
|
||||||
|
|
||||||
mlp = MLPClassifier(hidden_layer_sizes=(15,), activation='logistic', alpha=1e-4,
|
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,
|
solver='sgd', tol=1e-4, random_state=1,
|
||||||
learning_rate_init=.1, verbose=True)
|
learning_rate_init=.1, verbose=True)
|
||||||
|
|
||||||
mlp.fit(x_train, y_train)
|
mlp.fit(x_train, y_train)
|
||||||
|
|
||||||
predictions = mlp.predict(x_test)
|
predictions = mlp.predict(x_test)
|
||||||
print(accuracy_score(y_test, predictions))
|
print(accuracy_score(y_test, predictions))
|
||||||
|
Loading…
Reference in New Issue
Block a user