Skip to content

Commit a7f8e3c

Browse files
committed
Started STS reserach on OCR
1 parent de54c84 commit a7f8e3c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

STS_Research/HCR.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
import cv2
5+
import tensorflow as tf
6+
7+
def training_NN():
8+
mnist = tf.keras.datasets.mnist
9+
(x_train, y_train), (x_test, y_test) = mnist.load_data()
10+
11+
x_train = tf.keras.utils.normalize(x_train, axis=1)
12+
x_test = tf.keras.utils.normalize(x_test, axis=1)
13+
14+
model = tf.keras.models.Sequential()
15+
model.add(tf.keras.layers.Flatten(input_shape=(28, 28)))
16+
model.add(tf.keras.layers.Dense(128, activation='relu'))
17+
model.add(tf.keras.layers.Dense(128, activation='relu'))
18+
model.add(tf.keras.layers.Dense(10, activation='softmax'))
19+
20+
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
21+
22+
model.fit(x_train, y_train, epochs=3)
23+
model.save('handwritten.model')
24+
25+
26+
27+
def load_model():
28+
model = tr.keras.models.load_model('handwritten.model')
29+
30+
def main():
31+
# training_NN()
32+
load_model()

0 commit comments

Comments
 (0)