Skip to content

Commit 2ecd5f4

Browse files
committedFeb 17, 2017
misc commits
1 parent ccf16ca commit 2ecd5f4

10 files changed

+420
-1036
lines changed
 

‎15-01-01 459_Mont_Lyman.jpg

1.1 MB
Loading

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ be used with E13B.
1818

1919
run_batch.sc is a bash script that runs all of the programs in the directory
2020

21-
The script file will create many files in the folder, ./plots.
21+
The script file will create many files in the folder, /tmp/plots.
2222

2323

2424
Python 3.4

‎o4_image_to_image.py

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
"""# ==========================================================================
2+
3+
# Copyright 2015 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# ==============================================================================
17+
18+
This sample program is a modified version of the Google mnist convolutional
19+
network tutorial example. See the mnist tutorial in www.tensorflow.org
20+
21+
This graph has multiple sections 3 layers each, 400 100 400 followed
22+
by a fully connected layer.
23+
24+
see tensor_flow_graph.png
25+
"""# ==============================================================================
26+
import ocr_utils
27+
import datetime
28+
from collections import namedtuple
29+
import numpy as np
30+
import pandas as pd
31+
import n1_image_to_image as nnetwork
32+
#import n1_residual3x4 as nnetwork
33+
import tensorflow as tf
34+
dtype = np.float32
35+
#with tf.device('/GPU:0'):
36+
#with tf.device('/cpu:0'):
37+
38+
39+
if True:
40+
# single font train
41+
42+
# examples
43+
# select only images from 'OCRB' scanned font
44+
# input_filters_dict = {'font': ('OCRA',)}
45+
46+
# select only images from 'HANDPRINT' font
47+
#input_filters_dict = {'font': ('HANDPRINT',)}
48+
49+
# select only images from 'OCRA' and 'OCRB' fonts with the 'scanned" fontVariant
50+
# input_filters_dict = {'font': ('OCRA','OCRB'), 'fontVariant':('scanned',)}
51+
52+
# select everything; all fonts , font variants, etc.
53+
# input_filters_dict = {}
54+
55+
# select the digits 0 through 9 in the E13B font
56+
# input_filters_dict = {'m_label': range(48,58), 'font': 'E13B'}
57+
58+
# select the digits 0 and 2in the E13B font
59+
# input_filters_dict = {'m_label': (48,50), 'font': 'E13B'}
60+
61+
# output the character label, image, italic flag, aspect_ratio and upper_case flag
62+
# output_feature_list = ['m_label_one_hot','image','italic','aspect_ratio','upper_case']
63+
64+
# output only the character label and the image
65+
# output_feature_list = ['m_label_one_hot','image']
66+
67+
# identify the font given the input images
68+
#output_feature_list = ['font_one_hot','image','italic','aspect_ratio','upper_case']
69+
70+
# train the digits 0-9 for all fonts
71+
input_filters_dict = {'m_label': range(48,58),'italic':0,'strength':.4}
72+
#input_filters_dict = {'font':'BANKGOTHIC','m_label': list(range(48,58)),'italic':0,'strength':.7}
73+
#input_filters_dict = {}
74+
output_feature_list = ['low_pass_image','image']
75+
76+
"""# ==============================================================================
77+
78+
Train and Evaluate the Model
79+
80+
"""# ==============================================================================
81+
ds = ocr_utils.read_data(input_filters_dict = input_filters_dict,
82+
output_feature_list=output_feature_list,
83+
test_size = .2,
84+
engine_type='tensorflow',dtype=dtype)
85+
nn = nnetwork.network(ds.train)
86+
nn.fit( ds.train, nEpochs=5000)
87+
nn.test2(ds.test)
88+
89+
# train_a_font(input_filters_dict, output_feature_list, nEpochs = 50000)
90+
91+
else:
92+
# loop through all the fonts and train individually
93+
94+
# pick up the entire list of fonts and font variants. Train each one.
95+
df1 = ocr_utils.get_list(input_filters_dict={'font': ()})
96+
97+
import pprint as pprint
98+
pp = pprint.PrettyPrinter(indent=4)
99+
pp.pprint(df1)
100+
101+
output_feature_list = ['m_label_one_hot','image','italic','aspect_ratio','upper_case','font_one_hot']
102+
103+
# Change nEpochs to 5000 for better results
104+
for l in df1:
105+
input_filters_dict= {'font': (l[0],)}
106+
train_a_font(input_filters_dict,output_feature_list, nEpochs = 5000)
107+
108+
109+
print ('\n########################### No Errors ####################################')
110+

0 commit comments

Comments
 (0)