diff --git a/.gitignore b/.gitignore index 1883f58..84c6f90 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ papers/* data/train/characters/dataset.csv requirement.txt GettingStart.ipynb +log_train +__pycache__ diff --git a/checkpoint b/checkpoint new file mode 100644 index 0000000..89b7328 --- /dev/null +++ b/checkpoint @@ -0,0 +1,2 @@ +model_checkpoint_path: "viet_ocr_brain.ckpt" +all_model_checkpoint_paths: "viet_ocr_brain.ckpt" diff --git a/model.py b/model.py index 370f2c0..f8e252c 100644 --- a/model.py +++ b/model.py @@ -158,7 +158,7 @@ def train(self, learning_rate, training_epochs, batch_size, keep_prob): print('Training finished!') saver = tf.train.Saver() - save_path = saver.save(self.sess, "viet_ocr_brain.ckpt") + save_path = saver.save(self.sess, "./viet_ocr_brain.ckpt") print("Trainned model is saved in file: %s" % save_path) def evaluate(self, batch_size, keep_prob): diff --git a/predict.py b/predict.py index e2fde0d..cedb03f 100644 --- a/predict.py +++ b/predict.py @@ -27,17 +27,18 @@ def predict(character_image): return (probs[0, idx], idx) -ds = DataSet(test_prob=1, one_hot=False) -characters = DataGenerator().get_list_characters() +if __name__ == '__main__': + ds = DataSet(test_prob=1, one_hot=False) + characters = DataGenerator().get_list_characters() -x, y = ds.next_batch_test(1) + x, y = ds.next_batch_test(1) -print('x.shape', x.shape) -print('y.shape', y.shape) + print('x.shape', x.shape) + print('y.shape', y.shape) -prob, idx = predict(x) + prob, idx = predict(x) -print('Input character: ', characters[int(y[0])]) -print('Predicted: ', characters[idx], ' with probability = ', prob, '%') -print('Result: ', characters[int(y[0])] == characters[idx]) -print('-' * 10) + print('Input character: ', characters[int(y[0])]) + print('Predicted: ', characters[idx], ' with probability = ', prob, '%') + print('Result: ', characters[int(y[0])] == characters[idx]) + print('-' * 10) diff --git a/requirements.txt b/requirements.txt index e69de29..1971399 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,23 @@ +absl-py==0.1.12 +astor==0.6.2 +bleach==1.5.0 +certifi==2018.1.18 +cycler==0.10.0 +gast==0.2.0 +grpcio==1.10.0 +html5lib==0.9999999 +kiwisolver==1.0.1 +Markdown==2.6.11 +matplotlib==2.2.2 +numpy==1.14.2 +pandas==0.22.0 +Pillow==5.0.0 +protobuf==3.5.2.post1 +pyparsing==2.2.0 +python-dateutil==2.7.1 +pytz==2018.3 +six==1.11.0 +tensorboard==1.6.0 +tensorflow==1.6.0 +termcolor==1.1.0 +Werkzeug==0.14.1 diff --git a/test_files/test1.png b/test_files/test1.png new file mode 100644 index 0000000..2f63227 Binary files /dev/null and b/test_files/test1.png differ diff --git a/viet_ocr_brain.ckpt.data-00000-of-00001 b/viet_ocr_brain.ckpt.data-00000-of-00001 new file mode 100644 index 0000000..f9fd063 Binary files /dev/null and b/viet_ocr_brain.ckpt.data-00000-of-00001 differ diff --git a/viet_ocr_brain.ckpt.index b/viet_ocr_brain.ckpt.index new file mode 100644 index 0000000..30153ed Binary files /dev/null and b/viet_ocr_brain.ckpt.index differ diff --git a/viet_ocr_brain.ckpt.meta b/viet_ocr_brain.ckpt.meta new file mode 100644 index 0000000..27a6df7 Binary files /dev/null and b/viet_ocr_brain.ckpt.meta differ