Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train model #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ papers/*
data/train/characters/dataset.csv
requirement.txt
GettingStart.ipynb
log_train
__pycache__
2 changes: 2 additions & 0 deletions checkpoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
model_checkpoint_path: "viet_ocr_brain.ckpt"
all_model_checkpoint_paths: "viet_ocr_brain.ckpt"
2 changes: 1 addition & 1 deletion model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
21 changes: 11 additions & 10 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Binary file added test_files/test1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added viet_ocr_brain.ckpt.data-00000-of-00001
Binary file not shown.
Binary file added viet_ocr_brain.ckpt.index
Binary file not shown.
Binary file added viet_ocr_brain.ckpt.meta
Binary file not shown.