Repository: deeperic/SpikeFlow
Branch: master
Commit: ffff4f5c479d
Files: 13
Total size: 71.3 KB
Directory structure:
gitextract__3f2v9ps/
├── LICENSE
├── README.md
├── receipt.gh/
│ └── find_contour_character.py
├── tf/
│ ├── convert_to_tfrecords.py
│ ├── helper.py
│ ├── ocr_model.py
│ ├── reader.py
│ ├── spikeflow.py
│ ├── test_one_char.py
│ └── train_model.py
└── training-character.gh/
├── labelling-character.py
├── trainLabels.csv
└── valLabels.csv
================================================
FILE CONTENTS
================================================
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 deeperic
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# SpikeFlow
A Chinese OCR with TensorFlow
*** Warning: The source codes in this repository may not work well with the latest version of Tensorflow. ***
To play around, follow these steps:
1/ Use Ocropy to generate Chinese character images. linegen is the tool used. You will need a font file. Put the images under folder training-character.gh.
2/ Run labelling-character.py to generate the labels on images.
3/ Run tf/convert-to-tfrecords.py to convert the images and labels in Tensorflow format.
4/ Modify the tf/helper.py for the characters you want to recognise.
5/ Run tf/train_model.py to train a model. The training will save a checkpoint on a regular interval.
6/ In receipt, run the find_contour_character.py to generate the images which may contain Chinese characters. You will have a "bw" folder containing all images. Run: python find_contour_character.py {image filename}
7/ Test the model by running: python test_one_char.py {the name of your model} {the image to be recognised}
Blog: https://deeperic.wordpress.com/2017/02/18/chinese-ocr-tensorflow
Youtube: https://youtu.be/9N9OUruPZd4
GitHub: https://github.com/deeperic/SpikeFlow
================================================
FILE: receipt.gh/find_contour_character.py
================================================
#i need this to generate chinese character images
import cv2
import os
import sys
def createFolder(folder):
if not os.path.exists(folder):
os.makedirs(folder)
def sort_bounding_boxes(cnts, method="left-to-right"):
# initialize the reverse flag and sort index
reverse = False
i = 0
# handle if we need to sort in reverse
if method == "right-to-left" or method == "bottom-to-top":
reverse = True
# handle if we are sorting against the y-coordinate rather than
# the x-coordinate of the bounding box
if method == "top-to-bottom" or method == "bottom-to-top":
i = 1
# construct the list of bounding boxes and sort them from top to
# bottom
boundingBoxes = cnts
(cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),
key=lambda b:b[1][i], reverse=reverse))
# return the list of sorted contours and bounding boxes
return (cnts, boundingBoxes)
def sort_contours(cnts, method="left-to-right"):
# initialize the reverse flag and sort index
reverse = False
i = 0
# handle if we need to sort in reverse
if method == "right-to-left" or method == "bottom-to-top":
reverse = True
# handle if we are sorting against the y-coordinate rather than
# the x-coordinate of the bounding box
if method == "top-to-bottom" or method == "bottom-to-top":
i = 1
# construct the list of bounding boxes and sort them from top to
# bottom
boundingBoxes = [cv2.boundingRect(c) for c in cnts]
(cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),
key=lambda b:b[1][i], reverse=reverse))
# return the list of sorted contours and bounding boxes
return (cnts, boundingBoxes)
def captch_ex(file_name, folder1, folder2 ):
img = cv2.imread(file_name)
img2 = cv2.imread(file_name) #for saving
img2gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
new_img = cv2.adaptiveThreshold(img2gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 9, 10)
need_img = cv2.adaptiveThreshold(img2gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 15, 15)
kernel = cv2.getStructuringElement(cv2.MORPH_CROSS,(3 , 3)) # to manipulate the orientation of dilution , large x means horizonatally dilating more, large y means vertically dilating more
dilated = cv2.dilate(new_img,kernel,iterations = 2) # dilate , more the iteration more the dilation #find section
_, contours, hierarchy = cv2.findContours(dilated,cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE) # get contours
cnts, sorted = sort_contours(contours, "top-to-bottom")
index = 0
dimension = 32
for contour in sorted:
[x,y,w,h] = contour
#Don't plot small false positives that aren't text
if w < 50:
continue
#chinese is a square, so try to get a character
capw = w
if(h > w):
capw = h
# draw rectangle around contour on original image
cv2.rectangle(img,(x,y),(x+capw,y+capw),(255,0,255),2)
cropped = img2[y :y + capw , x : x + capw]
croppedBW = need_img[y :y + capw , x : x + capw]
#cropped32 = cv2.resize(cropped, (dimension, dimension))
#s = './' + folder1 + '/' + str(index) + '.png'
#cv2.imwrite(s , cropped32)
croppedbw32 = cv2.resize(croppedBW, (dimension, dimension))
s = './' + folder2 + '/' + str(index) + '-bw.png'
cv2.imwrite(s , croppedbw32)
index = index + 1
cv2.namedWindow('captcha_result', cv2.WINDOW_NORMAL)
# write original image with added contours to disk
#resize for display
height, width, channels = img.shape
print(height)
ratio = height / width
newheight = 900
newwidth = newheight / ratio
imS = cv2.resize(img, (newheight, newwidth))
cv2.imshow('captcha_result' , imS)
cv2.waitKey()
#cv2.imshow('captcha_result' , new_img)
#cv2.waitKey()
file_name = sys.argv[1]
print file_name
filename_split = os.path.splitext(file_name)
folder1 = filename_split[0]
folder2 = filename_split[0] + 'bw'
createFolder(folder1)
createFolder(folder2)
captch_ex(file_name, folder1, folder2)
================================================
FILE: tf/convert_to_tfrecords.py
================================================
# deeperic
"""Converts images and labels to TFRecords file format."""
import csv
import glob
import os
import numpy as np
import tensorflow as tf
from PIL import Image
import helper
tf.app.flags.DEFINE_string('directory', '../tfrec',
'Directory to write the '
'converted result')
FLAGS = tf.app.flags.FLAGS
def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))
def _bytes_feature(value):
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
def convert_to(images, labels, name):
num_examples = labels.shape[0]
#print('labels shape is ' + str(labels.shape[0]))
if images.shape[0] != num_examples:
raise ValueError("Images size %d does not match label size %d." %
(images.shape[0], num_examples))
rows = images.shape[1]
cols = images.shape[2]
depth = images.shape[3]
filename = os.path.join(FLAGS.directory, name + '.tfrecords')
#print('Writing', filename)
writer = tf.python_io.TFRecordWriter(filename)
for index in range(num_examples):
image_raw = images[index].tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(rows),
'width': _int64_feature(cols),
'depth': _int64_feature(depth),
'label': _int64_feature(int(labels[index])),
'image_raw': _bytes_feature(image_raw)}))
writer.write(example.SerializeToString())
def read_images(path):
print('Reading images')
images = []
png_files_path = glob.glob(os.path.join(path, './', '*.[pP][nN][gG]'))
for filename in png_files_path:
#print('read file:' + filename)
im = Image.open(filename) # .convert("L") # Convert to greyscale
im = np.asarray(im, np.uint8)
# get only images name, not path
image_name = filename.split('/')[-1].split('.')[0]
images.append([int(image_name), im])
images = sorted(images, key=lambda image: image[0])
images_only = [np.asarray(image[1], np.uint8) for image in images] # Use unint8 or you will be !!!
images_only = np.array(images_only)
return images_only
def read_labels(path, filename):
print('Reading labels')
with open(os.path.join(path, filename), 'r') as dest_f:
data_iter = csv.reader(dest_f)
train_labels = [data for data in data_iter]
# pre process labels to int
train_labels = _label_to_int(train_labels)
train_labels = np.array(train_labels, dtype=np.uint32)
return train_labels
def _label_to_int(labels):
chars = helper.char_list
new_labels = []
for label in labels:
new_labels.append(chars.index(label[1]))
return new_labels
def main(argv):
train_images = read_images('../training-character/train')
train_labels = read_labels('../training-character', 'trainLabels.csv')
validation_images = read_images('../training-character/val')
validation_labels = read_labels('../training-character', 'valLabels.csv')
print('train shape:' + str(train_images.shape))
print('validation shape:' + str(validation_images.shape))
convert_to(train_images, train_labels, 'train')
convert_to(validation_images, validation_labels, 'validation')
if __name__ == '__main__':
tf.app.run()
================================================
FILE: tf/helper.py
================================================
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# deeperic
char_list = ['cheung', 'chin2', 'chiu', 'cup', 'ho', 'ka', 'ma', 'sheung', 'shi', 'yi', 'sin', 'ngou', 'lai']
char_list_chinese = ['場', '錢', '超', '級', '號', '卡', '碼', '賞', '市', '易', '鮮', '牛', '奶']
================================================
FILE: tf/ocr_model.py
================================================
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#deep eric
"""The network model"""
import tensorflow as tf
# Network Parameters
IMAGE_SIZE = 32
n_input = IMAGE_SIZE * IMAGE_SIZE * 3 # (img shape: 32*32)
out_conv_1 = 64
out_conv_2 = 64
n_hidden_1 = 384
n_hidden_2 = 192
dropout = 0.90 # Dropout, probability to keep units
NUM_CLASSES = 13
NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN = 40000
NUM_EXAMPLES_PER_EPOCH_FOR_EVAL = 10000
# Constants describing the training process.
NUM_EPOCHS_PER_DECAY = 10.0 # Epochs after which learning rate decays.
LEARNING_RATE_DECAY_FACTOR = 0.60 # Learning rate decay factor.
INITIAL_LEARNING_RATE = 0.001 # Initial learning rate.
FLAGS = tf.app.flags.FLAGS
# Create model
def conv2d(img, w, b):
return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(img, w, strides=[1, 1, 1, 1], padding='SAME'), b))
def max_pool(img, k):
return tf.nn.max_pool(img, ksize=[1, k, k, 1], strides=[1, k, k, 1], padding='SAME')
def inference(images):
"""Build the model up to where it may be used for inference.
Args:
Returns:
logits: Output tensor with the computed logits.
"""
# Reshape input picture
images = tf.reshape(images, shape=[-1, IMAGE_SIZE, IMAGE_SIZE, 3])
_dropout = tf.Variable(dropout) # dropout (keep probability)
#random_normal
#truncated_normal
# Store layers weight & bias
_weights = {
'wc1': tf.Variable(tf.random_normal([5, 5, 3, out_conv_1], stddev=1e-3)), # 5x5 conv, 3 input, 64 outputs
'wc2': tf.Variable(tf.random_normal([5, 5, out_conv_1, out_conv_2], stddev=1e-3)),
# 5x5 conv, 64 inputs, 64 outputs
'wd1': tf.Variable(tf.random_normal([out_conv_2 * 8 * 8, n_hidden_1], stddev=1e-3)),
'wd2': tf.Variable(tf.random_normal([n_hidden_1, n_hidden_2], stddev=1e-3)),
'out': tf.Variable(tf.random_normal([n_hidden_2, NUM_CLASSES], stddev=1e-3))
}
_biases = {
'bc1': tf.Variable(tf.random_normal([out_conv_1])),
'bc2': tf.Variable(tf.random_normal([out_conv_2])),
'bd1': tf.Variable(tf.random_normal([n_hidden_1])),
'bd2': tf.Variable(tf.random_normal([n_hidden_2])),
'out': tf.Variable(tf.random_normal([NUM_CLASSES]))
}
# Convolution Layer 1
with tf.name_scope('Conv1'):
conv1 = conv2d(images, _weights['wc1'], _biases['bc1'])
# Max Pooling (down-sampling)
conv1 = max_pool(conv1, k=2)
# norm1
conv1 = tf.nn.lrn(conv1, 4, bias=1.0, alpha=0.001 / 9.0, beta=0.75,
name='norm1')
# Apply Dropout
conv1 = tf.nn.dropout(conv1, _dropout)
# Convolution Layer 2
with tf.name_scope('Conv2'):
conv2 = conv2d(conv1, _weights['wc2'], _biases['bc2'])
# norm2
conv2 = tf.nn.lrn(conv2, 4, bias=1.0, alpha=0.001 / 9.0, beta=0.75,
name='norm2')
# # Max Pooling (down-sampling)
conv2 = max_pool(conv2, k=2)
# Apply Dropout
conv2 = tf.nn.dropout(conv2, _dropout)
# Fully connected layer 1
with tf.name_scope('Dense1'):
dense1 = tf.reshape(conv2,
[-1, _weights['wd1'].get_shape().as_list()[0]]) # Reshape conv2 output to fit dense layer input
dense1 = tf.nn.relu_layer(dense1, _weights['wd1'], _biases['bd1']) # Relu activation
dense1 = tf.nn.dropout(dense1, _dropout) # Apply Dropout
# Fully connected layer 2
with tf.name_scope('Dense2'):
dense2 = tf.nn.relu_layer(dense1, _weights['wd2'], _biases['bd2']) # Relu activation
# Output, class prediction
logits = tf.add(tf.matmul(dense2, _weights['out']), _biases['out'])
return logits
def loss(logits, labels):
"""Add L2Loss to all the trainable variables.
Add summary for for "Loss" and "Loss/avg".
Args:
logits: Logits from inference().
labels: Labels from distorted_inputs or inputs(). 1-D tensor
of shape [batch_size]
Returns:
Loss tensor of type float.
"""
# Reshape the labels into a dense Tensor of
# shape [batch_size, NUM_CLASSES].
sparse_labels = tf.reshape(labels, [FLAGS.batch_size, 1])
indices = tf.reshape(tf.range(0, FLAGS.batch_size), [FLAGS.batch_size, 1])
concated = tf.concat(axis=1, values=[indices, sparse_labels])
dense_labels = tf.sparse_to_dense(concated,
[FLAGS.batch_size, NUM_CLASSES],
1.0, 0.0)
# Calculate the average cross entropy loss across the batch.
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
logits=logits, labels=dense_labels, name='cross_entropy_per_example')
cross_entropy_mean = tf.reduce_mean(cross_entropy, name='cross_entropy')
tf.add_to_collection('losses', cross_entropy_mean)
# The total loss is defined as the cross entropy loss plus all of the weight
# decay terms (L2 loss).
return tf.add_n(tf.get_collection('losses'), name='total_loss')
def training(loss, global_step):
"""Sets up the training Ops.
Creates a summarizer to track the loss over time in TensorBoard.
Creates an optimizer and applies the gradients to all trainable variables.
The Op returned by this function is what must be passed to the
`sess.run()` call to cause the model to train.
Args:
loss: Loss tensor, from loss().
learning_rate: The learning rate to use for gradient descent.
Returns:
train_op: The Op for training.
"""
# Variables that affect learning rate.
num_batches_per_epoch = NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN / FLAGS.batch_size
decay_steps = int(num_batches_per_epoch * NUM_EPOCHS_PER_DECAY)
#print('Decay steps is: ', decay_steps)
# Decay the learning rate exponentially based on the number of steps.
lr = tf.train.exponential_decay(INITIAL_LEARNING_RATE,
global_step,
decay_steps,
LEARNING_RATE_DECAY_FACTOR,
staircase=True)
tf.summary.scalar('learning_rate', lr)
# Add a scalar summary for the snapshot loss.
tf.summary.scalar(loss.op.name, loss)
# Create the adam or gradient descent optimizer with the given learning rate.
optimizer = tf.train.AdamOptimizer(lr)
# optimizer = tf.train.GradientDescentOptimizer(lr)
# Use the optimizer to apply the gradients that minimize the loss
# (and also increment the global step counter) as a single training step.
train_op = optimizer.minimize(loss, global_step=global_step)
return train_op
def evaluation(logits, labels):
"""Evaluate the quality of the logits at predicting the label.
Args:
logits: Logits tensor, float - [batch_size, NUM_CLASSES].
labels: Labels tensor, int32 - [batch_size], with values in the
range [0, NUM_CLASSES).
Returns:
A scalar int32 tensor with the number of examples (out of batch_size)
that were predicted correctly.
"""
print('Evaluation..')
# For a classifier model, we can use the in_top_k Op.
# It returns a bool tensor with shape [batch_size] that is true for
# the examples where the label's is was in the top k (here k=1)
# of all logits for that example.
correct = tf.nn.in_top_k(logits, labels, 1)
num_correct = tf.reduce_sum(tf.cast(correct, tf.float32))
acc_percent = num_correct / FLAGS.batch_size
# Return the number of true entries.
return acc_percent * 100.0, num_correct
def main(argv=None):
return 0
if __name__ == '__main__':
tf.app.run()
================================================
FILE: tf/reader.py
================================================
#deeperic
import os
import glob
import csv
import tensorflow as tf
import numpy as np
from PIL import Image
def _read_raw_images(path, is_directory=True):
"""Reads directory of images in tensorflow
Args:
path:
is_directory:
Returns:
"""
images = []
png_files = []
jpeg_files = []
reader = tf.WholeFileReader()
png_files_path = glob.glob(os.path.join(path, '*.[pP][nN][gG]'))
jpeg_files_path = glob.glob(os.path.join(path, '*.[jJ][pP][eE][gG]'))
jpg_files_path = glob.glob(os.path.join(path, '*.[jJ][pP][gG]'))
if is_directory:
for filename in png_files_path:
png_files.append(filename)
for filename in jpeg_files_path:
jpeg_files.append(filename)
for filename in jpg_files_path:
jpeg_files.append(filename)
else:
raise ValueError('Currently only batch read from directory supported')
# Decode if there is a PNG file:
if len(png_files) > 0:
png_file_queue = tf.train.string_input_producer(png_files)
pkey, pvalue = reader.read(png_file_queue)
p_img = tf.image.decode_png(pvalue)
if len(jpeg_files) > 0:
jpeg_file_queue = tf.train.string_input_producer(jpeg_files)
jkey, jvalue = reader.read(jpeg_file_queue)
j_img = tf.image.decode_jpeg(jvalue)
return # TODO: return normal thing
def read_and_decode(filename_queue, imshape, normalize=False, flatten=True):
"""Reads
Args:
filename_queue:
imshape:
normalize:
flatten:
Returns:
"""
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
features={
'image_raw': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64)
})
# Convert from a scalar string tensor (whose single string has
# length mnist.IMAGE_PIXELS) to a uint8 tensor with shape
# [mnist.IMAGE_PIXELS].
image = tf.decode_raw(features['image_raw'], tf.uint8)
if flatten:
num_elements = 1
for i in imshape: num_elements = num_elements * i
#print num_elements
image = tf.reshape(image, [num_elements])
image.set_shape(num_elements)
else:
image = tf.reshape(image, imshape)
image.set_shape(imshape)
if normalize:
# Convert from [0, 255] -> [-0.5, 0.5] floats.
image = tf.cast(image, tf.float32)
image = tf.cast(image, tf.float32) * (1. / 255) - 0.5
# Convert label from a scalar uint8 tensor to an int32 scalar.
label = tf.cast(features['label'], tf.int32)
return image, label
# Helper, Examples
def _read_labels_csv_from(path, num_classes, one_hot=False):
"""Reads
Args:
Returns:
"""
print('Reading labels')
with open(os.path.join(path), 'r') as dest_f:
data_iter = csv.reader(dest_f)
train_labels = [data for data in data_iter]
train_labels = np.array(train_labels, dtype=np.uint32)
if one_hot:
labels_one_hot = utils.dense_to_one_hot(train_labels, num_classes)
labels_one_hot = np.asarray(labels_one_hot)
return labels_one_hot
return train_labels
def _read_pngs_from(path):
"""Reads directory of images.
Args:
path: path to the directory
Returns:
A list of all images in the directory in the TF format (You need to call sess.run() or .eval() to get the value).
"""
images = []
png_files_path = glob.glob(os.path.join(path, '*.[pP][nN][gG]'))
for filename in png_files_path:
im = Image.open(filename)
im = np.asarray(im, np.uint8)
# get only images name, not path
image_name = filename.split('/')[-1].split('.')[0]
images.append([int(image_name), im])
images = sorted(images, key=lambda image: image[0])
images_only = [np.asarray(image[1], np.uint8) for image in images] # Use unint8 or you will be !!!
images_only = np.array(images_only)
#print(images_only.shape)
return images_only
def read_and_decode_wholefile(filename_queue, imshape, normalize=False, flatten=True):
"""Reads
Args:
filename_queue:
imshape:
normalize:
flatten:
Returns:
"""
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
image = tf.image.decode_png(value, channels=3)
if flatten:
num_elements = 1
for i in imshape: num_elements = num_elements * i
#print num_elements
image = tf.reshape(image, [num_elements])
image.set_shape(num_elements)
else:
image = tf.reshape(image, imshape)
image.set_shape(imshape)
if normalize:
# Convert from [0, 255] -> [-0.5, 0.5] floats.
image = tf.cast(image, tf.float32)
image = tf.cast(image, tf.float32) * (1. / 255) - 0.5
# don't care
label = 1
return image, label
def dense_to_one_hot(labels_dense, num_classes):
"""
Convert class labels from scalars to one-hot vectors.
"""
num_labels = labels_dense.shape[0]
index_offset = np.arange(num_labels) * num_classes
labels_one_hot = np.zeros((num_labels, num_classes))
labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
print(labels_one_hot[0])
return labels_one_hot
================================================
FILE: tf/spikeflow.py
================================================
#deeperic
import convert_to_tfrecords
import reader
from numpy.random import shuffle
import tensorflow as tf
def inputs_test_files(filename, batch_size, num_epochs2, num_threads,
imshape, num_examples_per_epoch=128):
"""Reads input tfrecord file num_epochs times. Use it for validation.
Args:
filename: The path to the .tfrecords file to be read
batch_size: Number of examples per returned batch.
num_epochs: Number of times to read the input ckpt, or 0/None to
train forever.
num_threads: Number of reader workers to enqueue
imshape: The shape of image in the format
num_examples_per_epoch: Number of images to use per epoch
Returns:
A tuple (images, labels), where:
* images is a float tensor with shape [batch_size, mnist.IMAGE_PIXELS]
in the range [-0.5, 0.5].
* labels is an int32 tensor with shape [batch_size] with the true label,
a number in the range [0, mnist.NUM_CLASSES).
Note that an tf.train.QueueRunner is added to the graph, which
must be run using e.g. tf.train.start_queue_runners().
"""
tf.local_variables_initializer()
if not num_epochs2:
num_epochs2 = None
with tf.name_scope('input'):
filename_queue = tf.train.string_input_producer(
#[filename], num_epochs=num_epochs2, name='string_input_producer')
#['../character-data/test/170.png',
#'../character-data/test/214.png',
#'../character-data/test/2579.png'],
['../project/pricesplit_/0.png',
'../project/pricesplit_/1.png',
'../project/pricesplit_/2.png',
'../project/pricesplit_/3.png',
'../project/pricesplit_/4.png',
'../project/pricesplit_/5.png',
'../project/pricesplit_/6.png',
'../project/pricesplit_/7.png'],
num_epochs=num_epochs2,
shuffle=False,#must be false otherwise will shuffle everytime
name='string_input_producer')
# Even when reading in multiple threads, share the filename
# queue.
image, label = reader.read_and_decode_eric(filename_queue, imshape, normalize=True)
# Convert from [0, 255] -> [-0.5, 0.5] floats. The normalize param in read_and_decode will do the same job.
# image = tf.cast(image, tf.float32)
# image = tf.cast(image, tf.float32) * (1. / 255) - 0.5
# Shuffle the examples and collect them into batch_size batches.
# (Internally uses a RandomShuffleQueue.)
# We run this in two threads to avoid being a bottleneck.
# Ensure that the random shuffling has good mixing properties.
#min_fraction_of_examples_in_queue = 0.4
#min_queue_examples = int(num_examples_per_epoch *
# min_fraction_of_examples_in_queue)
#images, sparse_labels = tf.train.shuffle_batch(
# [image, label], batch_size=batch_size, num_threads=num_threads,
# capacity=min_queue_examples + 3 * batch_size, enqueue_many=False,
# # Ensures a minimum amount of shuffling of examples.
# min_after_dequeue=min_queue_examples, name='batching_shuffling')
#print('erieric')
images, sparse_labels = tf.train.batch(
[image, label], batch_size=batch_size, num_threads=num_threads)
return images, sparse_labels
def inputs_test(filename, batch_size, num_epochs, num_threads,
imshape, num_examples_per_epoch=128):
tf.local_variables_initializer()
if not num_epochs:
num_epochs = None
with tf.name_scope('input'):
filename_queue = tf.train.string_input_producer(
[filename], num_epochs=num_epochs, name='string_input_producer')
image, label = reader.read_and_decode_wholefile(filename_queue, imshape, normalize=True)
images, sparse_labels = tf.train.batch([image, label], batch_size=batch_size)
return images, sparse_labels
def inputs(filename, batch_size, num_epochs2, num_threads,
imshape, num_examples_per_epoch=128):
"""Reads input tfrecord file num_epochs times. Use it for validation.
Args:
filename: The path to the .tfrecords file to be read
batch_size: Number of examples per returned batch.
num_epochs: Number of times to read the input ckpt, or 0/None to
train forever.
num_threads: Number of reader workers to enqueue
imshape: The shape of image in the format
num_examples_per_epoch: Number of images to use per epoch
Returns:
A tuple (images, labels), where:
* images is a float tensor with shape [batch_size, mnist.IMAGE_PIXELS]
in the range [-0.5, 0.5].
* labels is an int32 tensor with shape [batch_size] with the true label,
a number in the range [0, mnist.NUM_CLASSES).
Note that an tf.train.QueueRunner is added to the graph, which
must be run using e.g. tf.train.start_queue_runners().
"""
tf.local_variables_initializer()
if not num_epochs2:
num_epochs2 = None
with tf.name_scope('input'):
filename_queue = tf.train.string_input_producer(
[filename], num_epochs=num_epochs2, name='string_input_producer')
# Even when reading in multiple threads, share the filename
# queue.
#image, label = reader.read_and_decode(filename_queue, imshape, normalize=True, flatten=False)
image, label = reader.read_and_decode(filename_queue, imshape, normalize=True)
# Convert from [0, 255] -> [-0.5, 0.5] floats. The normalize param in read_and_decode will do the same job.
# image = tf.cast(image, tf.float32)
# image = tf.cast(image, tf.float32) * (1. / 255) - 0.5
# Shuffle the examples and collect them into batch_size batches.
# (Internally uses a RandomShuffleQueue.)
# We run this in two threads to avoid being a bottleneck.
# Ensure that the random shuffling has good mixing properties.
min_fraction_of_examples_in_queue = 0.4
min_queue_examples = int(num_examples_per_epoch *
min_fraction_of_examples_in_queue)
images, sparse_labels = tf.train.shuffle_batch(
[image, label], batch_size=batch_size, num_threads=num_threads,
capacity=min_queue_examples + 3 * batch_size, enqueue_many=False,
# Ensures a minimum amount of shuffling of examples.
min_after_dequeue=min_queue_examples, name='batching_shuffling')
return images, sparse_labels
def _random_brightness_helper(image):
return tf.image.random_brightness(image, max_delta=63)
def _random_contrast_helper(image):
return tf.image.random_contrast(image, lower=0.2, upper=1.8)
def distorted_inputs(filename, batch_size, num_epochs, num_threads,
imshape, num_examples_per_epoch=128, flatten=True):
"""Construct distorted input for training using the Reader ops.
Raises:
ValueError: if no data_dir
Args:
filename: The name of the file containing the images
batch_size: The number of images per batch
num_epochs: The number of epochs passed to string_input_producer
num_threads: The number of threads passed to shuffle_batch
imshape: Shape of image in [height, width, n_channels] format
num_examples_per_epoch: Number of images to use per epoch
flatten: Whether to flatten image after image transformations
Returns:
images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size.
labels: Labels. 1D tensor of [batch_size] size.
"""
tf.local_variables_initializer()
tf.global_variables_initializer()
if not num_epochs:
num_epochs = None
with tf.name_scope('input'):
filename_queue = tf.train.string_input_producer(
[filename], num_epochs=num_epochs, name='string_DISTORTED_input_producer')
# Even when reading in multiple threads, share the filename
# queue.
image, label = reader.read_and_decode(filename_queue, imshape)
# Reshape to imshape as distortion methods need this shape
image = tf.reshape(image, imshape)
# Image processing for training the network. Note the many random
# distortions applied to the image.
# Removed random_crop in new TensorFlow release.
# Randomly crop a [height, width] section of the image.
# distorted_image = tf.image.random_crop(image, [height, width])
#
# Randomly flip the image horizontally.
distorted_image = tf.image.random_flip_left_right(image)
#
# Randomly apply image transformations in random_functions list
random_functions = [_random_brightness_helper, _random_contrast_helper]
shuffle(random_functions)
for fcn in random_functions:
distorted_image = fcn(distorted_image)
# # Subtract off the mean and divide by the variance of the pixels.
float_image = tf.image.per_image_standardization(distorted_image)
if flatten:
num_elements = 1
for i in imshape: num_elements = num_elements * i
image = tf.reshape(float_image, [num_elements])
else:
image = float_image
# Ensure that the random shuffling has good mixing properties.
min_fraction_of_examples_in_queue = 0.4
min_queue_examples = int(num_examples_per_epoch *
min_fraction_of_examples_in_queue)
images, sparse_labels = tf.train.shuffle_batch([image, label],
batch_size=batch_size,
num_threads=num_threads,
capacity=min_queue_examples + 3 * batch_size,
enqueue_many=False,
# Ensures a minimum amount of shuffling of examples.
min_after_dequeue=min_queue_examples,
name='batching_shuffling_distortion')
return images, sparse_labels
================================================
FILE: tf/test_one_char.py
================================================
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#deeperic
import os.path
import time
from datetime import datetime
import numpy as np
import tensorflow as tf
import glob
from PIL import Image
import sys
import spikeflow
import ocr_model
import helper
#import input_data
# Basic model parameters as external flags.
flags = tf.app.flags
FLAGS = flags.FLAGS
flags.DEFINE_integer('num_epochs', 50000, 'Number of epochs to run trainer.')
flags.DEFINE_integer('batch_size', 32, 'Batch size.')
IMAGE_PIXELS = 32 * 32 * 3
def placeholder_inputs(batch_size):
"""Generate placeholder variables to represent the the input tensors.
These placeholders are used as inputs by the rest of the model building
code and will be fed from the downloaded ckpt in the .run() loop, below.
Args:
batch_size: The batch size will be baked into both placeholders.
Returns:
images_placeholder: Images placeholder.
labels_placeholder: Labels placeholder.
"""
# Note that the shapes of the placeholders match the shapes of the full
# image and label tensors, except the first dimension is now batch_size
# rather than the full size of the train or test ckpt sets.
# batch_size = -1
images_placeholder = tf.placeholder(tf.float32, shape=(batch_size,
IMAGE_PIXELS))
labels_placeholder = tf.placeholder(tf.int32, shape=batch_size)
return images_placeholder, labels_placeholder
def test(argv):
with tf.Graph().as_default():
global_step = tf.Variable(0, trainable=False)
images_placeholder, labels_placeholder = placeholder_inputs(FLAGS.batch_size)
test_images, test_labels = spikeflow.inputs_test(filename=argv[1], batch_size=FLAGS.batch_size,
num_epochs=FLAGS.num_epochs,
num_threads=5, imshape=[32, 32, 3])
# Build a Graph that computes the logits predictions from the inference model.
logits = ocr_model.inference(images_placeholder)
# Create a saver.
saver = tf.train.Saver()
init = tf.group(tf.global_variables_initializer(),
tf.local_variables_initializer())
# Start running operations on the Graph.
NUM_CORES = 5 # Choose how many cores to use.
sess = tf.Session(config=tf.ConfigProto(inter_op_parallelism_threads=NUM_CORES,
intra_op_parallelism_threads=NUM_CORES))
sess.run(init)
# Start the queue runners.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
#print('Model:' + argv[0])
saver.restore(sess, argv[0])
#print('Model Restored!')
images_test_r, labels_test_r = sess.run([test_images, test_labels])
val_feed_test = {images_placeholder: images_test_r,
labels_placeholder: labels_test_r}
acc_r = sess.run(tf.argmax(logits,1), feed_dict=val_feed_test)
chars = helper.char_list_chinese
print('The character is: ' + str(chars[acc_r[0]]))
#print predictions
prediction=tf.argmax(logits,1)
print "Predictions:", prediction.eval(feed_dict=val_feed_test, session=sess)[0]
#print probabilities
probabilities=logits
print "Probabilities:", probabilities.eval(feed_dict=val_feed_test, session=sess)[0]
coord.request_stop()
coord.join(threads)
sess.close()
def main(argv=None):
#python test_one_char.py {model_name} {image_name}
test(sys.argv[1:]) #predict
if __name__ == '__main__':
tf.app.run()
================================================
FILE: tf/train_model.py
================================================
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#deeperic
"""Training the model"""
import os.path
import time
from datetime import datetime
import numpy as np
import tensorflow as tf
import glob
from PIL import Image
import spikeflow
import ocr_model
#import input_data
# Basic model parameters as external flags.
flags = tf.app.flags
FLAGS = flags.FLAGS
flags.DEFINE_float('learning_rate', 0.01, 'Initial learning rate.')
flags.DEFINE_integer('num_epochs', 50000, 'Number of epochs to run trainer.')
flags.DEFINE_integer('batch_size', 32, 'Batch size.')
FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_string('model_dir', '../tmp/my-model',
"""Directory where to write model proto """
""" to import in c++""")
tf.app.flags.DEFINE_string('train_dir', '../tmp/log',
"""Directory where to write event logs """
"""and checkpoint.""")
tf.app.flags.DEFINE_integer('max_steps', 100000,
"""Number of batches to run.""")
tf.app.flags.DEFINE_string('checkpoint_dir', '../checkpoint',
"""Directory where to read/write model checkpoints.""")
# Parameters
display_step = 100
val_step = 500
save_step = 500
PIXEL_DIM = 32
IMAGE_PIXELS = PIXEL_DIM * PIXEL_DIM * 3
NEW_LINE = '\n'
def placeholder_inputs(batch_size):
"""Generate placeholder variables to represent the the input tensors.
These placeholders are used as inputs by the rest of the model building
code and will be fed from the downloaded ckpt in the .run() loop, below.
Args:
batch_size: The batch size will be baked into both placeholders.
Returns:
images_placeholder: Images placeholder.
labels_placeholder: Labels placeholder.
"""
# Note that the shapes of the placeholders match the shapes of the full
# image and label tensors, except the first dimension is now batch_size
# rather than the full size of the train or test ckpt sets.
# batch_size = -1
images_placeholder = tf.placeholder(tf.float32, shape=(batch_size,
IMAGE_PIXELS))
labels_placeholder = tf.placeholder(tf.int32, shape=batch_size)
return images_placeholder, labels_placeholder
def train(continue_from_pre = False):
with tf.Graph().as_default():
global_step = tf.Variable(0, trainable=False)
images_placeholder, labels_placeholder = placeholder_inputs(FLAGS.batch_size)
#read the TF Records
images, labels = spikeflow.inputs(filename='../tfrec/train.tfrecords', batch_size=FLAGS.batch_size,
num_epochs2=FLAGS.num_epochs,
num_threads=5, imshape=[PIXEL_DIM, PIXEL_DIM, 3])
val_images, val_labels = spikeflow.inputs(filename='../tfrec/validation.tfrecords', batch_size=FLAGS.batch_size,
num_epochs2=FLAGS.num_epochs,
num_threads=5, imshape=[PIXEL_DIM, PIXEL_DIM, 3])
# Build a Graph that computes the logits predictions from the inference model.
logits = ocr_model.inference(images_placeholder)
# Calculate loss.
loss = ocr_model.loss(logits, labels_placeholder)
# Build a Graph that trains the model with one batch of examples and
# updates the model parameters.
train_op = ocr_model.training(loss, global_step)
# Calculate accuracy #
acc, n_correct = ocr_model.evaluation(logits, labels_placeholder)
# Create a saver.
saver = tf.train.Saver()
tf.summary.scalar('Acc', acc)
tf.summary.scalar('Loss', loss)
# Build the summary operation based on the TF collection of Summaries.
summary_op = tf.summary.merge_all()
# Build an initialization operation to run below.
init = tf.group(tf.global_variables_initializer(),
tf.local_variables_initializer())
# Start running operations on the Graph.
NUM_CORES = 5 # Choose how many cores to use.
sess = tf.Session(config=tf.ConfigProto(inter_op_parallelism_threads=NUM_CORES,
intra_op_parallelism_threads=NUM_CORES))
sess.run(init)
# Write all terminal output results here
val_f = open("../tmp/val.txt", "ab")
# Start the queue runners.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
summary_writer = tf.summary.FileWriter(FLAGS.train_dir,
graph=sess.graph)
# Export graph to import it later in c++
# tf.train.write_graph(sess.graph, FLAGS.model_dir, 'train.pbtxt') # TODO: uncomment to get graph and use in c++
#reload previous saved check points
continue_from_pre = False
if continue_from_pre:
ckpt = tf.train.get_checkpoint_state(checkpoint_dir=FLAGS.checkpoint_dir)
print ckpt.model_checkpoint_path
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)
print('Session Restored!')
try:
while not coord.should_stop():
for step in xrange(FLAGS.max_steps):
images_r, labels_r = sess.run([images, labels])
images_val_r, labels_val_r = sess.run([val_images, val_labels])
train_feed = {images_placeholder: images_r,
labels_placeholder: labels_r}
val_feed = {images_placeholder: images_val_r,
labels_placeholder: labels_val_r}
start_time = time.time()
_, loss_value = sess.run([train_op, loss], feed_dict=train_feed)
duration = time.time() - start_time
assert not np.isnan(loss_value), 'Model diverged with loss = NaN'
if step % display_step == 0:
num_examples_per_step = FLAGS.batch_size
examples_per_sec = num_examples_per_step / duration
sec_per_batch = float(duration)
format_str = ('%s: step %d, loss = %.6f (%.1f examples/sec; %.3f '
'sec/batch)')
print_str_loss = format_str % (datetime.now(), step, loss_value,
examples_per_sec, sec_per_batch)
print (print_str_loss)
val_f.write(print_str_loss + NEW_LINE)
summary_str = sess.run([summary_op], feed_dict=train_feed)
summary_writer.add_summary(summary_str[0], step)
if step % val_step == 0:
acc_value, num_corroect = sess.run([acc, n_correct], feed_dict=train_feed)
format_str = '%s: step %d, train acc = %.2f, n_correct= %d'
print_str_train = format_str % (datetime.now(), step, acc_value, num_corroect)
val_f.write(print_str_train + NEW_LINE)
print (print_str_train)
# Save the model checkpoint periodically.
if step % save_step == 0 or (step + 1) == FLAGS.max_steps:
val_acc_r, val_n_correct_r = sess.run([acc, n_correct], feed_dict=val_feed)
frmt_str = '%s: step %d, Val Acc = %.2f, num correct = %d'
print_str_val = frmt_str % (datetime.now(), step, val_acc_r, val_n_correct_r)
val_f.write(print_str_val + NEW_LINE)
print(print_str_val)
checkpoint_path = os.path.join(FLAGS.checkpoint_dir, 'model.ckpt')
savedpath = saver.save(sess, checkpoint_path, global_step=step)
print('model saved: ' + savedpath)
except tf.errors.OutOfRangeError:
print ('Done training -- epoch limit reached')
finally:
# When done, ask the threads to stop.
val_f.write(NEW_LINE +
NEW_LINE +
'############################ FINISHED ############################' +
NEW_LINE)
val_f.close()
coord.request_stop()
# Wait for threads to finish.
coord.join(threads)
sess.close()
def main(argv=None):
train()
if __name__ == '__main__':
tf.app.run()
================================================
FILE: training-character.gh/labelling-character.py
================================================
import os
from shutil import copyfile
import cv2
aggregatedPath = 'train'
trainPath = 'train'
valPath = 'val'
imagesPath = ['cheung', 'chin2', 'chiu', 'cup', 'ho', 'ka', 'ma', 'sheung', 'shi', 'yi', 'sin', 'ngou', 'lai']
labelsFileTrain = './trainLabels.csv'
labelsFileVal = './valLabels.csv'
numVal = 160 #200 images, 80% training, 20% validation
f = open(labelsFileTrain,'w')
f2 = open(labelsFileVal,'w')
aggregatedPath = trainPath #init with train path
writeFile = f
count = 0
eachClassCount = 0
for imagedir in imagesPath:
print(imagedir)
aggregatedPath = trainPath #init with train path
writeFile = f
eachClassCount = 0
for fileName in os.listdir(imagedir):
print(fileName)
if(fileName == ".DS_Store"):
continue
filename_split = os.path.splitext(fileName)
if eachClassCount >= numVal: #validation files
aggregatedPath = valPath
writeFile = f2
oldFileName = imagedir + "/" + fileName
newFileOnlyName = '{0:05d}'.format(count) + "." + "png"
newFileName = "./" + aggregatedPath + "/" + newFileOnlyName
print(oldFileName)
print(newFileName)
copyfile(oldFileName, newFileName)
writeFile.write('{0:05d}'.format(count) + "," + imagedir + '\n')
count = count + 1
eachClassCount = eachClassCount + 1
f.close()
f2.close()
def resizeme(path):
#resize 32x32
for fileName in os.listdir(path):
if(fileName == ".DS_Store"):
continue
print("resize:" + fileName)
image = cv2.imread(path + "/" + fileName)
resized_image = cv2.resize(image, (32, 32))
cv2.imwrite(path + "/" + fileName, resized_image)
resizeme(trainPath)
resizeme(valPath)
================================================
FILE: training-character.gh/trainLabels.csv
================================================
00000,cheung
00001,cheung
00002,cheung
00003,cheung
00004,cheung
00005,cheung
00006,cheung
00007,cheung
00008,cheung
00009,cheung
00010,cheung
00011,cheung
00012,cheung
00013,cheung
00014,cheung
00015,cheung
00016,cheung
00017,cheung
00018,cheung
00019,cheung
00020,cheung
00021,cheung
00022,cheung
00023,cheung
00024,cheung
00025,cheung
00026,cheung
00027,cheung
00028,cheung
00029,cheung
00030,cheung
00031,cheung
00032,cheung
00033,cheung
00034,cheung
00035,cheung
00036,cheung
00037,cheung
00038,cheung
00039,cheung
00040,cheung
00041,cheung
00042,cheung
00043,cheung
00044,cheung
00045,cheung
00046,cheung
00047,cheung
00048,cheung
00049,cheung
00050,cheung
00051,cheung
00052,cheung
00053,cheung
00054,cheung
00055,cheung
00056,cheung
00057,cheung
00058,cheung
00059,cheung
00060,cheung
00061,cheung
00062,cheung
00063,cheung
00064,cheung
00065,cheung
00066,cheung
00067,cheung
00068,cheung
00069,cheung
00070,cheung
00071,cheung
00072,cheung
00073,cheung
00074,cheung
00075,cheung
00076,cheung
00077,cheung
00078,cheung
00079,cheung
00080,cheung
00081,cheung
00082,cheung
00083,cheung
00084,cheung
00085,cheung
00086,cheung
00087,cheung
00088,cheung
00089,cheung
00090,cheung
00091,cheung
00092,cheung
00093,cheung
00094,cheung
00095,cheung
00096,cheung
00097,cheung
00098,cheung
00099,cheung
00100,cheung
00101,cheung
00102,cheung
00103,cheung
00104,cheung
00105,cheung
00106,cheung
00107,cheung
00108,cheung
00109,cheung
00110,cheung
00111,cheung
00112,cheung
00113,cheung
00114,cheung
00115,cheung
00116,cheung
00117,cheung
00118,cheung
00119,cheung
00120,cheung
00121,cheung
00122,cheung
00123,cheung
00124,cheung
00125,cheung
00126,cheung
00127,cheung
00128,cheung
00129,cheung
00130,cheung
00131,cheung
00132,cheung
00133,cheung
00134,cheung
00135,cheung
00136,cheung
00137,cheung
00138,cheung
00139,cheung
00140,cheung
00141,cheung
00142,cheung
00143,cheung
00144,cheung
00145,cheung
00146,cheung
00147,cheung
00148,cheung
00149,cheung
00150,cheung
00151,cheung
00152,cheung
00153,cheung
00154,cheung
00155,cheung
00156,cheung
00157,cheung
00158,cheung
00159,cheung
00200,chin2
00201,chin2
00202,chin2
00203,chin2
00204,chin2
00205,chin2
00206,chin2
00207,chin2
00208,chin2
00209,chin2
00210,chin2
00211,chin2
00212,chin2
00213,chin2
00214,chin2
00215,chin2
00216,chin2
00217,chin2
00218,chin2
00219,chin2
00220,chin2
00221,chin2
00222,chin2
00223,chin2
00224,chin2
00225,chin2
00226,chin2
00227,chin2
00228,chin2
00229,chin2
00230,chin2
00231,chin2
00232,chin2
00233,chin2
00234,chin2
00235,chin2
00236,chin2
00237,chin2
00238,chin2
00239,chin2
00240,chin2
00241,chin2
00242,chin2
00243,chin2
00244,chin2
00245,chin2
00246,chin2
00247,chin2
00248,chin2
00249,chin2
00250,chin2
00251,chin2
00252,chin2
00253,chin2
00254,chin2
00255,chin2
00256,chin2
00257,chin2
00258,chin2
00259,chin2
00260,chin2
00261,chin2
00262,chin2
00263,chin2
00264,chin2
00265,chin2
00266,chin2
00267,chin2
00268,chin2
00269,chin2
00270,chin2
00271,chin2
00272,chin2
00273,chin2
00274,chin2
00275,chin2
00276,chin2
00277,chin2
00278,chin2
00279,chin2
00280,chin2
00281,chin2
00282,chin2
00283,chin2
00284,chin2
00285,chin2
00286,chin2
00287,chin2
00288,chin2
00289,chin2
00290,chin2
00291,chin2
00292,chin2
00293,chin2
00294,chin2
00295,chin2
00296,chin2
00297,chin2
00298,chin2
00299,chin2
00300,chin2
00301,chin2
00302,chin2
00303,chin2
00304,chin2
00305,chin2
00306,chin2
00307,chin2
00308,chin2
00309,chin2
00310,chin2
00311,chin2
00312,chin2
00313,chin2
00314,chin2
00315,chin2
00316,chin2
00317,chin2
00318,chin2
00319,chin2
00320,chin2
00321,chin2
00322,chin2
00323,chin2
00324,chin2
00325,chin2
00326,chin2
00327,chin2
00328,chin2
00329,chin2
00330,chin2
00331,chin2
00332,chin2
00333,chin2
00334,chin2
00335,chin2
00336,chin2
00337,chin2
00338,chin2
00339,chin2
00340,chin2
00341,chin2
00342,chin2
00343,chin2
00344,chin2
00345,chin2
00346,chin2
00347,chin2
00348,chin2
00349,chin2
00350,chin2
00351,chin2
00352,chin2
00353,chin2
00354,chin2
00355,chin2
00356,chin2
00357,chin2
00358,chin2
00359,chin2
00400,chiu
00401,chiu
00402,chiu
00403,chiu
00404,chiu
00405,chiu
00406,chiu
00407,chiu
00408,chiu
00409,chiu
00410,chiu
00411,chiu
00412,chiu
00413,chiu
00414,chiu
00415,chiu
00416,chiu
00417,chiu
00418,chiu
00419,chiu
00420,chiu
00421,chiu
00422,chiu
00423,chiu
00424,chiu
00425,chiu
00426,chiu
00427,chiu
00428,chiu
00429,chiu
00430,chiu
00431,chiu
00432,chiu
00433,chiu
00434,chiu
00435,chiu
00436,chiu
00437,chiu
00438,chiu
00439,chiu
00440,chiu
00441,chiu
00442,chiu
00443,chiu
00444,chiu
00445,chiu
00446,chiu
00447,chiu
00448,chiu
00449,chiu
00450,chiu
00451,chiu
00452,chiu
00453,chiu
00454,chiu
00455,chiu
00456,chiu
00457,chiu
00458,chiu
00459,chiu
00460,chiu
00461,chiu
00462,chiu
00463,chiu
00464,chiu
00465,chiu
00466,chiu
00467,chiu
00468,chiu
00469,chiu
00470,chiu
00471,chiu
00472,chiu
00473,chiu
00474,chiu
00475,chiu
00476,chiu
00477,chiu
00478,chiu
00479,chiu
00480,chiu
00481,chiu
00482,chiu
00483,chiu
00484,chiu
00485,chiu
00486,chiu
00487,chiu
00488,chiu
00489,chiu
00490,chiu
00491,chiu
00492,chiu
00493,chiu
00494,chiu
00495,chiu
00496,chiu
00497,chiu
00498,chiu
00499,chiu
00500,chiu
00501,chiu
00502,chiu
00503,chiu
00504,chiu
00505,chiu
00506,chiu
00507,chiu
00508,chiu
00509,chiu
00510,chiu
00511,chiu
00512,chiu
00513,chiu
00514,chiu
00515,chiu
00516,chiu
00517,chiu
00518,chiu
00519,chiu
00520,chiu
00521,chiu
00522,chiu
00523,chiu
00524,chiu
00525,chiu
00526,chiu
00527,chiu
00528,chiu
00529,chiu
00530,chiu
00531,chiu
00532,chiu
00533,chiu
00534,chiu
00535,chiu
00536,chiu
00537,chiu
00538,chiu
00539,chiu
00540,chiu
00541,chiu
00542,chiu
00543,chiu
00544,chiu
00545,chiu
00546,chiu
00547,chiu
00548,chiu
00549,chiu
00550,chiu
00551,chiu
00552,chiu
00553,chiu
00554,chiu
00555,chiu
00556,chiu
00557,chiu
00558,chiu
00559,chiu
00600,cup
00601,cup
00602,cup
00603,cup
00604,cup
00605,cup
00606,cup
00607,cup
00608,cup
00609,cup
00610,cup
00611,cup
00612,cup
00613,cup
00614,cup
00615,cup
00616,cup
00617,cup
00618,cup
00619,cup
00620,cup
00621,cup
00622,cup
00623,cup
00624,cup
00625,cup
00626,cup
00627,cup
00628,cup
00629,cup
00630,cup
00631,cup
00632,cup
00633,cup
00634,cup
00635,cup
00636,cup
00637,cup
00638,cup
00639,cup
00640,cup
00641,cup
00642,cup
00643,cup
00644,cup
00645,cup
00646,cup
00647,cup
00648,cup
00649,cup
00650,cup
00651,cup
00652,cup
00653,cup
00654,cup
00655,cup
00656,cup
00657,cup
00658,cup
00659,cup
00660,cup
00661,cup
00662,cup
00663,cup
00664,cup
00665,cup
00666,cup
00667,cup
00668,cup
00669,cup
00670,cup
00671,cup
00672,cup
00673,cup
00674,cup
00675,cup
00676,cup
00677,cup
00678,cup
00679,cup
00680,cup
00681,cup
00682,cup
00683,cup
00684,cup
00685,cup
00686,cup
00687,cup
00688,cup
00689,cup
00690,cup
00691,cup
00692,cup
00693,cup
00694,cup
00695,cup
00696,cup
00697,cup
00698,cup
00699,cup
00700,cup
00701,cup
00702,cup
00703,cup
00704,cup
00705,cup
00706,cup
00707,cup
00708,cup
00709,cup
00710,cup
00711,cup
00712,cup
00713,cup
00714,cup
00715,cup
00716,cup
00717,cup
00718,cup
00719,cup
00720,cup
00721,cup
00722,cup
00723,cup
00724,cup
00725,cup
00726,cup
00727,cup
00728,cup
00729,cup
00730,cup
00731,cup
00732,cup
00733,cup
00734,cup
00735,cup
00736,cup
00737,cup
00738,cup
00739,cup
00740,cup
00741,cup
00742,cup
00743,cup
00744,cup
00745,cup
00746,cup
00747,cup
00748,cup
00749,cup
00750,cup
00751,cup
00752,cup
00753,cup
00754,cup
00755,cup
00756,cup
00757,cup
00758,cup
00759,cup
00800,ho
00801,ho
00802,ho
00803,ho
00804,ho
00805,ho
00806,ho
00807,ho
00808,ho
00809,ho
00810,ho
00811,ho
00812,ho
00813,ho
00814,ho
00815,ho
00816,ho
00817,ho
00818,ho
00819,ho
00820,ho
00821,ho
00822,ho
00823,ho
00824,ho
00825,ho
00826,ho
00827,ho
00828,ho
00829,ho
00830,ho
00831,ho
00832,ho
00833,ho
00834,ho
00835,ho
00836,ho
00837,ho
00838,ho
00839,ho
00840,ho
00841,ho
00842,ho
00843,ho
00844,ho
00845,ho
00846,ho
00847,ho
00848,ho
00849,ho
00850,ho
00851,ho
00852,ho
00853,ho
00854,ho
00855,ho
00856,ho
00857,ho
00858,ho
00859,ho
00860,ho
00861,ho
00862,ho
00863,ho
00864,ho
00865,ho
00866,ho
00867,ho
00868,ho
00869,ho
00870,ho
00871,ho
00872,ho
00873,ho
00874,ho
00875,ho
00876,ho
00877,ho
00878,ho
00879,ho
00880,ho
00881,ho
00882,ho
00883,ho
00884,ho
00885,ho
00886,ho
00887,ho
00888,ho
00889,ho
00890,ho
00891,ho
00892,ho
00893,ho
00894,ho
00895,ho
00896,ho
00897,ho
00898,ho
00899,ho
00900,ho
00901,ho
00902,ho
00903,ho
00904,ho
00905,ho
00906,ho
00907,ho
00908,ho
00909,ho
00910,ho
00911,ho
00912,ho
00913,ho
00914,ho
00915,ho
00916,ho
00917,ho
00918,ho
00919,ho
00920,ho
00921,ho
00922,ho
00923,ho
00924,ho
00925,ho
00926,ho
00927,ho
00928,ho
00929,ho
00930,ho
00931,ho
00932,ho
00933,ho
00934,ho
00935,ho
00936,ho
00937,ho
00938,ho
00939,ho
00940,ho
00941,ho
00942,ho
00943,ho
00944,ho
00945,ho
00946,ho
00947,ho
00948,ho
00949,ho
00950,ho
00951,ho
00952,ho
00953,ho
00954,ho
00955,ho
00956,ho
00957,ho
00958,ho
00959,ho
01000,ka
01001,ka
01002,ka
01003,ka
01004,ka
01005,ka
01006,ka
01007,ka
01008,ka
01009,ka
01010,ka
01011,ka
01012,ka
01013,ka
01014,ka
01015,ka
01016,ka
01017,ka
01018,ka
01019,ka
01020,ka
01021,ka
01022,ka
01023,ka
01024,ka
01025,ka
01026,ka
01027,ka
01028,ka
01029,ka
01030,ka
01031,ka
01032,ka
01033,ka
01034,ka
01035,ka
01036,ka
01037,ka
01038,ka
01039,ka
01040,ka
01041,ka
01042,ka
01043,ka
01044,ka
01045,ka
01046,ka
01047,ka
01048,ka
01049,ka
01050,ka
01051,ka
01052,ka
01053,ka
01054,ka
01055,ka
01056,ka
01057,ka
01058,ka
01059,ka
01060,ka
01061,ka
01062,ka
01063,ka
01064,ka
01065,ka
01066,ka
01067,ka
01068,ka
01069,ka
01070,ka
01071,ka
01072,ka
01073,ka
01074,ka
01075,ka
01076,ka
01077,ka
01078,ka
01079,ka
01080,ka
01081,ka
01082,ka
01083,ka
01084,ka
01085,ka
01086,ka
01087,ka
01088,ka
01089,ka
01090,ka
01091,ka
01092,ka
01093,ka
01094,ka
01095,ka
01096,ka
01097,ka
01098,ka
01099,ka
01100,ka
01101,ka
01102,ka
01103,ka
01104,ka
01105,ka
01106,ka
01107,ka
01108,ka
01109,ka
01110,ka
01111,ka
01112,ka
01113,ka
01114,ka
01115,ka
01116,ka
01117,ka
01118,ka
01119,ka
01120,ka
01121,ka
01122,ka
01123,ka
01124,ka
01125,ka
01126,ka
01127,ka
01128,ka
01129,ka
01130,ka
01131,ka
01132,ka
01133,ka
01134,ka
01135,ka
01136,ka
01137,ka
01138,ka
01139,ka
01140,ka
01141,ka
01142,ka
01143,ka
01144,ka
01145,ka
01146,ka
01147,ka
01148,ka
01149,ka
01150,ka
01151,ka
01152,ka
01153,ka
01154,ka
01155,ka
01156,ka
01157,ka
01158,ka
01159,ka
01200,ma
01201,ma
01202,ma
01203,ma
01204,ma
01205,ma
01206,ma
01207,ma
01208,ma
01209,ma
01210,ma
01211,ma
01212,ma
01213,ma
01214,ma
01215,ma
01216,ma
01217,ma
01218,ma
01219,ma
01220,ma
01221,ma
01222,ma
01223,ma
01224,ma
01225,ma
01226,ma
01227,ma
01228,ma
01229,ma
01230,ma
01231,ma
01232,ma
01233,ma
01234,ma
01235,ma
01236,ma
01237,ma
01238,ma
01239,ma
01240,ma
01241,ma
01242,ma
01243,ma
01244,ma
01245,ma
01246,ma
01247,ma
01248,ma
01249,ma
01250,ma
01251,ma
01252,ma
01253,ma
01254,ma
01255,ma
01256,ma
01257,ma
01258,ma
01259,ma
01260,ma
01261,ma
01262,ma
01263,ma
01264,ma
01265,ma
01266,ma
01267,ma
01268,ma
01269,ma
01270,ma
01271,ma
01272,ma
01273,ma
01274,ma
01275,ma
01276,ma
01277,ma
01278,ma
01279,ma
01280,ma
01281,ma
01282,ma
01283,ma
01284,ma
01285,ma
01286,ma
01287,ma
01288,ma
01289,ma
01290,ma
01291,ma
01292,ma
01293,ma
01294,ma
01295,ma
01296,ma
01297,ma
01298,ma
01299,ma
01300,ma
01301,ma
01302,ma
01303,ma
01304,ma
01305,ma
01306,ma
01307,ma
01308,ma
01309,ma
01310,ma
01311,ma
01312,ma
01313,ma
01314,ma
01315,ma
01316,ma
01317,ma
01318,ma
01319,ma
01320,ma
01321,ma
01322,ma
01323,ma
01324,ma
01325,ma
01326,ma
01327,ma
01328,ma
01329,ma
01330,ma
01331,ma
01332,ma
01333,ma
01334,ma
01335,ma
01336,ma
01337,ma
01338,ma
01339,ma
01340,ma
01341,ma
01342,ma
01343,ma
01344,ma
01345,ma
01346,ma
01347,ma
01348,ma
01349,ma
01350,ma
01351,ma
01352,ma
01353,ma
01354,ma
01355,ma
01356,ma
01357,ma
01358,ma
01359,ma
01400,sheung
01401,sheung
01402,sheung
01403,sheung
01404,sheung
01405,sheung
01406,sheung
01407,sheung
01408,sheung
01409,sheung
01410,sheung
01411,sheung
01412,sheung
01413,sheung
01414,sheung
01415,sheung
01416,sheung
01417,sheung
01418,sheung
01419,sheung
01420,sheung
01421,sheung
01422,sheung
01423,sheung
01424,sheung
01425,sheung
01426,sheung
01427,sheung
01428,sheung
01429,sheung
01430,sheung
01431,sheung
01432,sheung
01433,sheung
01434,sheung
01435,sheung
01436,sheung
01437,sheung
01438,sheung
01439,sheung
01440,sheung
01441,sheung
01442,sheung
01443,sheung
01444,sheung
01445,sheung
01446,sheung
01447,sheung
01448,sheung
01449,sheung
01450,sheung
01451,sheung
01452,sheung
01453,sheung
01454,sheung
01455,sheung
01456,sheung
01457,sheung
01458,sheung
01459,sheung
01460,sheung
01461,sheung
01462,sheung
01463,sheung
01464,sheung
01465,sheung
01466,sheung
01467,sheung
01468,sheung
01469,sheung
01470,sheung
01471,sheung
01472,sheung
01473,sheung
01474,sheung
01475,sheung
01476,sheung
01477,sheung
01478,sheung
01479,sheung
01480,sheung
01481,sheung
01482,sheung
01483,sheung
01484,sheung
01485,sheung
01486,sheung
01487,sheung
01488,sheung
01489,sheung
01490,sheung
01491,sheung
01492,sheung
01493,sheung
01494,sheung
01495,sheung
01496,sheung
01497,sheung
01498,sheung
01499,sheung
01500,sheung
01501,sheung
01502,sheung
01503,sheung
01504,sheung
01505,sheung
01506,sheung
01507,sheung
01508,sheung
01509,sheung
01510,sheung
01511,sheung
01512,sheung
01513,sheung
01514,sheung
01515,sheung
01516,sheung
01517,sheung
01518,sheung
01519,sheung
01520,sheung
01521,sheung
01522,sheung
01523,sheung
01524,sheung
01525,sheung
01526,sheung
01527,sheung
01528,sheung
01529,sheung
01530,sheung
01531,sheung
01532,sheung
01533,sheung
01534,sheung
01535,sheung
01536,sheung
01537,sheung
01538,sheung
01539,sheung
01540,sheung
01541,sheung
01542,sheung
01543,sheung
01544,sheung
01545,sheung
01546,sheung
01547,sheung
01548,sheung
01549,sheung
01550,sheung
01551,sheung
01552,sheung
01553,sheung
01554,sheung
01555,sheung
01556,sheung
01557,sheung
01558,sheung
01559,sheung
01600,shi
01601,shi
01602,shi
01603,shi
01604,shi
01605,shi
01606,shi
01607,shi
01608,shi
01609,shi
01610,shi
01611,shi
01612,shi
01613,shi
01614,shi
01615,shi
01616,shi
01617,shi
01618,shi
01619,shi
01620,shi
01621,shi
01622,shi
01623,shi
01624,shi
01625,shi
01626,shi
01627,shi
01628,shi
01629,shi
01630,shi
01631,shi
01632,shi
01633,shi
01634,shi
01635,shi
01636,shi
01637,shi
01638,shi
01639,shi
01640,shi
01641,shi
01642,shi
01643,shi
01644,shi
01645,shi
01646,shi
01647,shi
01648,shi
01649,shi
01650,shi
01651,shi
01652,shi
01653,shi
01654,shi
01655,shi
01656,shi
01657,shi
01658,shi
01659,shi
01660,shi
01661,shi
01662,shi
01663,shi
01664,shi
01665,shi
01666,shi
01667,shi
01668,shi
01669,shi
01670,shi
01671,shi
01672,shi
01673,shi
01674,shi
01675,shi
01676,shi
01677,shi
01678,shi
01679,shi
01680,shi
01681,shi
01682,shi
01683,shi
01684,shi
01685,shi
01686,shi
01687,shi
01688,shi
01689,shi
01690,shi
01691,shi
01692,shi
01693,shi
01694,shi
01695,shi
01696,shi
01697,shi
01698,shi
01699,shi
01700,shi
01701,shi
01702,shi
01703,shi
01704,shi
01705,shi
01706,shi
01707,shi
01708,shi
01709,shi
01710,shi
01711,shi
01712,shi
01713,shi
01714,shi
01715,shi
01716,shi
01717,shi
01718,shi
01719,shi
01720,shi
01721,shi
01722,shi
01723,shi
01724,shi
01725,shi
01726,shi
01727,shi
01728,shi
01729,shi
01730,shi
01731,shi
01732,shi
01733,shi
01734,shi
01735,shi
01736,shi
01737,shi
01738,shi
01739,shi
01740,shi
01741,shi
01742,shi
01743,shi
01744,shi
01745,shi
01746,shi
01747,shi
01748,shi
01749,shi
01750,shi
01751,shi
01752,shi
01753,shi
01754,shi
01755,shi
01756,shi
01757,shi
01758,shi
01759,shi
01800,yi
01801,yi
01802,yi
01803,yi
01804,yi
01805,yi
01806,yi
01807,yi
01808,yi
01809,yi
01810,yi
01811,yi
01812,yi
01813,yi
01814,yi
01815,yi
01816,yi
01817,yi
01818,yi
01819,yi
01820,yi
01821,yi
01822,yi
01823,yi
01824,yi
01825,yi
01826,yi
01827,yi
01828,yi
01829,yi
01830,yi
01831,yi
01832,yi
01833,yi
01834,yi
01835,yi
01836,yi
01837,yi
01838,yi
01839,yi
01840,yi
01841,yi
01842,yi
01843,yi
01844,yi
01845,yi
01846,yi
01847,yi
01848,yi
01849,yi
01850,yi
01851,yi
01852,yi
01853,yi
01854,yi
01855,yi
01856,yi
01857,yi
01858,yi
01859,yi
01860,yi
01861,yi
01862,yi
01863,yi
01864,yi
01865,yi
01866,yi
01867,yi
01868,yi
01869,yi
01870,yi
01871,yi
01872,yi
01873,yi
01874,yi
01875,yi
01876,yi
01877,yi
01878,yi
01879,yi
01880,yi
01881,yi
01882,yi
01883,yi
01884,yi
01885,yi
01886,yi
01887,yi
01888,yi
01889,yi
01890,yi
01891,yi
01892,yi
01893,yi
01894,yi
01895,yi
01896,yi
01897,yi
01898,yi
01899,yi
01900,yi
01901,yi
01902,yi
01903,yi
01904,yi
01905,yi
01906,yi
01907,yi
01908,yi
01909,yi
01910,yi
01911,yi
01912,yi
01913,yi
01914,yi
01915,yi
01916,yi
01917,yi
01918,yi
01919,yi
01920,yi
01921,yi
01922,yi
01923,yi
01924,yi
01925,yi
01926,yi
01927,yi
01928,yi
01929,yi
01930,yi
01931,yi
01932,yi
01933,yi
01934,yi
01935,yi
01936,yi
01937,yi
01938,yi
01939,yi
01940,yi
01941,yi
01942,yi
01943,yi
01944,yi
01945,yi
01946,yi
01947,yi
01948,yi
01949,yi
01950,yi
01951,yi
01952,yi
01953,yi
01954,yi
01955,yi
01956,yi
01957,yi
01958,yi
01959,yi
02000,sin
02001,sin
02002,sin
02003,sin
02004,sin
02005,sin
02006,sin
02007,sin
02008,sin
02009,sin
02010,sin
02011,sin
02012,sin
02013,sin
02014,sin
02015,sin
02016,sin
02017,sin
02018,sin
02019,sin
02020,sin
02021,sin
02022,sin
02023,sin
02024,sin
02025,sin
02026,sin
02027,sin
02028,sin
02029,sin
02030,sin
02031,sin
02032,sin
02033,sin
02034,sin
02035,sin
02036,sin
02037,sin
02038,sin
02039,sin
02040,sin
02041,sin
02042,sin
02043,sin
02044,sin
02045,sin
02046,sin
02047,sin
02048,sin
02049,sin
02050,sin
02051,sin
02052,sin
02053,sin
02054,sin
02055,sin
02056,sin
02057,sin
02058,sin
02059,sin
02060,sin
02061,sin
02062,sin
02063,sin
02064,sin
02065,sin
02066,sin
02067,sin
02068,sin
02069,sin
02070,sin
02071,sin
02072,sin
02073,sin
02074,sin
02075,sin
02076,sin
02077,sin
02078,sin
02079,sin
02080,sin
02081,sin
02082,sin
02083,sin
02084,sin
02085,sin
02086,sin
02087,sin
02088,sin
02089,sin
02090,sin
02091,sin
02092,sin
02093,sin
02094,sin
02095,sin
02096,sin
02097,sin
02098,sin
02099,sin
02100,sin
02101,sin
02102,sin
02103,sin
02104,sin
02105,sin
02106,sin
02107,sin
02108,sin
02109,sin
02110,sin
02111,sin
02112,sin
02113,sin
02114,sin
02115,sin
02116,sin
02117,sin
02118,sin
02119,sin
02120,sin
02121,sin
02122,sin
02123,sin
02124,sin
02125,sin
02126,sin
02127,sin
02128,sin
02129,sin
02130,sin
02131,sin
02132,sin
02133,sin
02134,sin
02135,sin
02136,sin
02137,sin
02138,sin
02139,sin
02140,sin
02141,sin
02142,sin
02143,sin
02144,sin
02145,sin
02146,sin
02147,sin
02148,sin
02149,sin
02150,sin
02151,sin
02152,sin
02153,sin
02154,sin
02155,sin
02156,sin
02157,sin
02158,sin
02159,sin
02200,ngou
02201,ngou
02202,ngou
02203,ngou
02204,ngou
02205,ngou
02206,ngou
02207,ngou
02208,ngou
02209,ngou
02210,ngou
02211,ngou
02212,ngou
02213,ngou
02214,ngou
02215,ngou
02216,ngou
02217,ngou
02218,ngou
02219,ngou
02220,ngou
02221,ngou
02222,ngou
02223,ngou
02224,ngou
02225,ngou
02226,ngou
02227,ngou
02228,ngou
02229,ngou
02230,ngou
02231,ngou
02232,ngou
02233,ngou
02234,ngou
02235,ngou
02236,ngou
02237,ngou
02238,ngou
02239,ngou
02240,ngou
02241,ngou
02242,ngou
02243,ngou
02244,ngou
02245,ngou
02246,ngou
02247,ngou
02248,ngou
02249,ngou
02250,ngou
02251,ngou
02252,ngou
02253,ngou
02254,ngou
02255,ngou
02256,ngou
02257,ngou
02258,ngou
02259,ngou
02260,ngou
02261,ngou
02262,ngou
02263,ngou
02264,ngou
02265,ngou
02266,ngou
02267,ngou
02268,ngou
02269,ngou
02270,ngou
02271,ngou
02272,ngou
02273,ngou
02274,ngou
02275,ngou
02276,ngou
02277,ngou
02278,ngou
02279,ngou
02280,ngou
02281,ngou
02282,ngou
02283,ngou
02284,ngou
02285,ngou
02286,ngou
02287,ngou
02288,ngou
02289,ngou
02290,ngou
02291,ngou
02292,ngou
02293,ngou
02294,ngou
02295,ngou
02296,ngou
02297,ngou
02298,ngou
02299,ngou
02300,ngou
02301,ngou
02302,ngou
02303,ngou
02304,ngou
02305,ngou
02306,ngou
02307,ngou
02308,ngou
02309,ngou
02310,ngou
02311,ngou
02312,ngou
02313,ngou
02314,ngou
02315,ngou
02316,ngou
02317,ngou
02318,ngou
02319,ngou
02320,ngou
02321,ngou
02322,ngou
02323,ngou
02324,ngou
02325,ngou
02326,ngou
02327,ngou
02328,ngou
02329,ngou
02330,ngou
02331,ngou
02332,ngou
02333,ngou
02334,ngou
02335,ngou
02336,ngou
02337,ngou
02338,ngou
02339,ngou
02340,ngou
02341,ngou
02342,ngou
02343,ngou
02344,ngou
02345,ngou
02346,ngou
02347,ngou
02348,ngou
02349,ngou
02350,ngou
02351,ngou
02352,ngou
02353,ngou
02354,ngou
02355,ngou
02356,ngou
02357,ngou
02358,ngou
02359,ngou
02400,lai
02401,lai
02402,lai
02403,lai
02404,lai
02405,lai
02406,lai
02407,lai
02408,lai
02409,lai
02410,lai
02411,lai
02412,lai
02413,lai
02414,lai
02415,lai
02416,lai
02417,lai
02418,lai
02419,lai
02420,lai
02421,lai
02422,lai
02423,lai
02424,lai
02425,lai
02426,lai
02427,lai
02428,lai
02429,lai
02430,lai
02431,lai
02432,lai
02433,lai
02434,lai
02435,lai
02436,lai
02437,lai
02438,lai
02439,lai
02440,lai
02441,lai
02442,lai
02443,lai
02444,lai
02445,lai
02446,lai
02447,lai
02448,lai
02449,lai
02450,lai
02451,lai
02452,lai
02453,lai
02454,lai
02455,lai
02456,lai
02457,lai
02458,lai
02459,lai
02460,lai
02461,lai
02462,lai
02463,lai
02464,lai
02465,lai
02466,lai
02467,lai
02468,lai
02469,lai
02470,lai
02471,lai
02472,lai
02473,lai
02474,lai
02475,lai
02476,lai
02477,lai
02478,lai
02479,lai
02480,lai
02481,lai
02482,lai
02483,lai
02484,lai
02485,lai
02486,lai
02487,lai
02488,lai
02489,lai
02490,lai
02491,lai
02492,lai
02493,lai
02494,lai
02495,lai
02496,lai
02497,lai
02498,lai
02499,lai
02500,lai
02501,lai
02502,lai
02503,lai
02504,lai
02505,lai
02506,lai
02507,lai
02508,lai
02509,lai
02510,lai
02511,lai
02512,lai
02513,lai
02514,lai
02515,lai
02516,lai
02517,lai
02518,lai
02519,lai
02520,lai
02521,lai
02522,lai
02523,lai
02524,lai
02525,lai
02526,lai
02527,lai
02528,lai
02529,lai
02530,lai
02531,lai
02532,lai
02533,lai
02534,lai
02535,lai
02536,lai
02537,lai
02538,lai
02539,lai
02540,lai
02541,lai
02542,lai
02543,lai
02544,lai
02545,lai
02546,lai
02547,lai
02548,lai
02549,lai
02550,lai
02551,lai
02552,lai
02553,lai
02554,lai
02555,lai
02556,lai
02557,lai
02558,lai
02559,lai
================================================
FILE: training-character.gh/valLabels.csv
================================================
00160,cheung
00161,cheung
00162,cheung
00163,cheung
00164,cheung
00165,cheung
00166,cheung
00167,cheung
00168,cheung
00169,cheung
00170,cheung
00171,cheung
00172,cheung
00173,cheung
00174,cheung
00175,cheung
00176,cheung
00177,cheung
00178,cheung
00179,cheung
00180,cheung
00181,cheung
00182,cheung
00183,cheung
00184,cheung
00185,cheung
00186,cheung
00187,cheung
00188,cheung
00189,cheung
00190,cheung
00191,cheung
00192,cheung
00193,cheung
00194,cheung
00195,cheung
00196,cheung
00197,cheung
00198,cheung
00199,cheung
00360,chin2
00361,chin2
00362,chin2
00363,chin2
00364,chin2
00365,chin2
00366,chin2
00367,chin2
00368,chin2
00369,chin2
00370,chin2
00371,chin2
00372,chin2
00373,chin2
00374,chin2
00375,chin2
00376,chin2
00377,chin2
00378,chin2
00379,chin2
00380,chin2
00381,chin2
00382,chin2
00383,chin2
00384,chin2
00385,chin2
00386,chin2
00387,chin2
00388,chin2
00389,chin2
00390,chin2
00391,chin2
00392,chin2
00393,chin2
00394,chin2
00395,chin2
00396,chin2
00397,chin2
00398,chin2
00399,chin2
00560,chiu
00561,chiu
00562,chiu
00563,chiu
00564,chiu
00565,chiu
00566,chiu
00567,chiu
00568,chiu
00569,chiu
00570,chiu
00571,chiu
00572,chiu
00573,chiu
00574,chiu
00575,chiu
00576,chiu
00577,chiu
00578,chiu
00579,chiu
00580,chiu
00581,chiu
00582,chiu
00583,chiu
00584,chiu
00585,chiu
00586,chiu
00587,chiu
00588,chiu
00589,chiu
00590,chiu
00591,chiu
00592,chiu
00593,chiu
00594,chiu
00595,chiu
00596,chiu
00597,chiu
00598,chiu
00599,chiu
00760,cup
00761,cup
00762,cup
00763,cup
00764,cup
00765,cup
00766,cup
00767,cup
00768,cup
00769,cup
00770,cup
00771,cup
00772,cup
00773,cup
00774,cup
00775,cup
00776,cup
00777,cup
00778,cup
00779,cup
00780,cup
00781,cup
00782,cup
00783,cup
00784,cup
00785,cup
00786,cup
00787,cup
00788,cup
00789,cup
00790,cup
00791,cup
00792,cup
00793,cup
00794,cup
00795,cup
00796,cup
00797,cup
00798,cup
00799,cup
00960,ho
00961,ho
00962,ho
00963,ho
00964,ho
00965,ho
00966,ho
00967,ho
00968,ho
00969,ho
00970,ho
00971,ho
00972,ho
00973,ho
00974,ho
00975,ho
00976,ho
00977,ho
00978,ho
00979,ho
00980,ho
00981,ho
00982,ho
00983,ho
00984,ho
00985,ho
00986,ho
00987,ho
00988,ho
00989,ho
00990,ho
00991,ho
00992,ho
00993,ho
00994,ho
00995,ho
00996,ho
00997,ho
00998,ho
00999,ho
01160,ka
01161,ka
01162,ka
01163,ka
01164,ka
01165,ka
01166,ka
01167,ka
01168,ka
01169,ka
01170,ka
01171,ka
01172,ka
01173,ka
01174,ka
01175,ka
01176,ka
01177,ka
01178,ka
01179,ka
01180,ka
01181,ka
01182,ka
01183,ka
01184,ka
01185,ka
01186,ka
01187,ka
01188,ka
01189,ka
01190,ka
01191,ka
01192,ka
01193,ka
01194,ka
01195,ka
01196,ka
01197,ka
01198,ka
01199,ka
01360,ma
01361,ma
01362,ma
01363,ma
01364,ma
01365,ma
01366,ma
01367,ma
01368,ma
01369,ma
01370,ma
01371,ma
01372,ma
01373,ma
01374,ma
01375,ma
01376,ma
01377,ma
01378,ma
01379,ma
01380,ma
01381,ma
01382,ma
01383,ma
01384,ma
01385,ma
01386,ma
01387,ma
01388,ma
01389,ma
01390,ma
01391,ma
01392,ma
01393,ma
01394,ma
01395,ma
01396,ma
01397,ma
01398,ma
01399,ma
01560,sheung
01561,sheung
01562,sheung
01563,sheung
01564,sheung
01565,sheung
01566,sheung
01567,sheung
01568,sheung
01569,sheung
01570,sheung
01571,sheung
01572,sheung
01573,sheung
01574,sheung
01575,sheung
01576,sheung
01577,sheung
01578,sheung
01579,sheung
01580,sheung
01581,sheung
01582,sheung
01583,sheung
01584,sheung
01585,sheung
01586,sheung
01587,sheung
01588,sheung
01589,sheung
01590,sheung
01591,sheung
01592,sheung
01593,sheung
01594,sheung
01595,sheung
01596,sheung
01597,sheung
01598,sheung
01599,sheung
01760,shi
01761,shi
01762,shi
01763,shi
01764,shi
01765,shi
01766,shi
01767,shi
01768,shi
01769,shi
01770,shi
01771,shi
01772,shi
01773,shi
01774,shi
01775,shi
01776,shi
01777,shi
01778,shi
01779,shi
01780,shi
01781,shi
01782,shi
01783,shi
01784,shi
01785,shi
01786,shi
01787,shi
01788,shi
01789,shi
01790,shi
01791,shi
01792,shi
01793,shi
01794,shi
01795,shi
01796,shi
01797,shi
01798,shi
01799,shi
01960,yi
01961,yi
01962,yi
01963,yi
01964,yi
01965,yi
01966,yi
01967,yi
01968,yi
01969,yi
01970,yi
01971,yi
01972,yi
01973,yi
01974,yi
01975,yi
01976,yi
01977,yi
01978,yi
01979,yi
01980,yi
01981,yi
01982,yi
01983,yi
01984,yi
01985,yi
01986,yi
01987,yi
01988,yi
01989,yi
01990,yi
01991,yi
01992,yi
01993,yi
01994,yi
01995,yi
01996,yi
01997,yi
01998,yi
01999,yi
02160,sin
02161,sin
02162,sin
02163,sin
02164,sin
02165,sin
02166,sin
02167,sin
02168,sin
02169,sin
02170,sin
02171,sin
02172,sin
02173,sin
02174,sin
02175,sin
02176,sin
02177,sin
02178,sin
02179,sin
02180,sin
02181,sin
02182,sin
02183,sin
02184,sin
02185,sin
02186,sin
02187,sin
02188,sin
02189,sin
02190,sin
02191,sin
02192,sin
02193,sin
02194,sin
02195,sin
02196,sin
02197,sin
02198,sin
02199,sin
02360,ngou
02361,ngou
02362,ngou
02363,ngou
02364,ngou
02365,ngou
02366,ngou
02367,ngou
02368,ngou
02369,ngou
02370,ngou
02371,ngou
02372,ngou
02373,ngou
02374,ngou
02375,ngou
02376,ngou
02377,ngou
02378,ngou
02379,ngou
02380,ngou
02381,ngou
02382,ngou
02383,ngou
02384,ngou
02385,ngou
02386,ngou
02387,ngou
02388,ngou
02389,ngou
02390,ngou
02391,ngou
02392,ngou
02393,ngou
02394,ngou
02395,ngou
02396,ngou
02397,ngou
02398,ngou
02399,ngou
02560,lai
02561,lai
02562,lai
02563,lai
02564,lai
02565,lai
02566,lai
02567,lai
02568,lai
02569,lai
02570,lai
02571,lai
02572,lai
02573,lai
02574,lai
02575,lai
02576,lai
02577,lai
02578,lai
02579,lai
02580,lai
02581,lai
02582,lai
02583,lai
02584,lai
02585,lai
02586,lai
02587,lai
02588,lai
02589,lai
02590,lai
02591,lai
02592,lai
02593,lai
02594,lai
02595,lai
02596,lai
02597,lai
02598,lai
02599,lai
gitextract__3f2v9ps/
├── LICENSE
├── README.md
├── receipt.gh/
│ └── find_contour_character.py
├── tf/
│ ├── convert_to_tfrecords.py
│ ├── helper.py
│ ├── ocr_model.py
│ ├── reader.py
│ ├── spikeflow.py
│ ├── test_one_char.py
│ └── train_model.py
└── training-character.gh/
├── labelling-character.py
├── trainLabels.csv
└── valLabels.csv
SYMBOL INDEX (37 symbols across 8 files) FILE: receipt.gh/find_contour_character.py function createFolder (line 8) | def createFolder(folder): function sort_bounding_boxes (line 13) | def sort_bounding_boxes(cnts, method="left-to-right"): function sort_contours (line 36) | def sort_contours(cnts, method="left-to-right"): function captch_ex (line 59) | def captch_ex(file_name, folder1, folder2 ): FILE: tf/convert_to_tfrecords.py function _int64_feature (line 20) | def _int64_feature(value): function _bytes_feature (line 24) | def _bytes_feature(value): function convert_to (line 28) | def convert_to(images, labels, name): function read_images (line 53) | def read_images(path): function read_labels (line 73) | def read_labels(path, filename): function _label_to_int (line 86) | def _label_to_int(labels): function main (line 94) | def main(argv): FILE: tf/ocr_model.py function conv2d (line 37) | def conv2d(img, w, b): function max_pool (line 41) | def max_pool(img, k): function inference (line 45) | def inference(images): function loss (line 118) | def loss(logits, labels): function training (line 151) | def training(loss, global_step): function evaluation (line 189) | def evaluation(logits, labels): function main (line 213) | def main(argv=None): FILE: tf/reader.py function _read_raw_images (line 11) | def _read_raw_images(path, is_directory=True): function read_and_decode (line 54) | def read_and_decode(filename_queue, imshape, normalize=False, flatten=Tr... function _read_labels_csv_from (line 101) | def _read_labels_csv_from(path, num_classes, one_hot=False): function _read_pngs_from (line 123) | def _read_pngs_from(path): function read_and_decode_wholefile (line 151) | def read_and_decode_wholefile(filename_queue, imshape, normalize=False, ... function dense_to_one_hot (line 189) | def dense_to_one_hot(labels_dense, num_classes): FILE: tf/spikeflow.py function inputs_test_files (line 12) | def inputs_test_files(filename, batch_size, num_epochs2, num_threads, function inputs_test (line 91) | def inputs_test(filename, batch_size, num_epochs, num_threads, function inputs (line 111) | def inputs(filename, batch_size, num_epochs2, num_threads, function _random_brightness_helper (line 169) | def _random_brightness_helper(image): function _random_contrast_helper (line 172) | def _random_contrast_helper(image): function distorted_inputs (line 175) | def distorted_inputs(filename, batch_size, num_epochs, num_threads, FILE: tf/test_one_char.py function placeholder_inputs (line 37) | def placeholder_inputs(batch_size): function test (line 59) | def test(argv): function main (line 122) | def main(argv=None): FILE: tf/train_model.py function placeholder_inputs (line 57) | def placeholder_inputs(batch_size): function train (line 79) | def train(continue_from_pre = False): function main (line 228) | def main(argv=None): FILE: training-character.gh/labelling-character.py function resizeme (line 59) | def resizeme(path):
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (78K chars).
[
{
"path": "LICENSE",
"chars": 1065,
"preview": "MIT License\n\nCopyright (c) 2017 deeperic\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\no"
},
{
"path": "README.md",
"chars": 1160,
"preview": "# SpikeFlow\nA Chinese OCR with TensorFlow\n\n*** Warning: The source codes in this repository may not work well with the l"
},
{
"path": "receipt.gh/find_contour_character.py",
"chars": 4191,
"preview": "#i need this to generate chinese character images\n\nimport cv2\nimport os\nimport sys\n\n\ndef createFolder(folder):\n if no"
},
{
"path": "tf/convert_to_tfrecords.py",
"chars": 3239,
"preview": "# deeperic\n\n\"\"\"Converts images and labels to TFRecords file format.\"\"\"\n\nimport csv\nimport glob\nimport os\nimport numpy as"
},
{
"path": "tf/helper.py",
"chars": 255,
"preview": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\n# deeperic\n\n\nchar_list = ['cheung', 'chin2', 'chiu', 'cup', 'ho', 'ka', '"
},
{
"path": "tf/ocr_model.py",
"chars": 7314,
"preview": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\n#deep eric\n\n\"\"\"The network model\"\"\"\n\nimport tensorflow as tf\n\n\n\n# Network"
},
{
"path": "tf/reader.py",
"chars": 5017,
"preview": "#deeperic\n\nimport os\nimport glob\nimport csv\nimport tensorflow as tf\nimport numpy as np\nfrom PIL import Image\n\n\ndef _read"
},
{
"path": "tf/spikeflow.py",
"chars": 9766,
"preview": "#deeperic\n\nimport convert_to_tfrecords\nimport reader\n\n\nfrom numpy.random import shuffle\nimport tensorflow as tf\n\n\n\ndef i"
},
{
"path": "tf/test_one_char.py",
"chars": 3717,
"preview": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\n\n\n#deeperic\n\nimport os.path\nimport time\nfrom datetime import datetime\n\nim"
},
{
"path": "tf/train_model.py",
"chars": 8243,
"preview": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\n#deeperic\n\n\"\"\"Training the model\"\"\"\n\n\nimport os.path\nimport time\nfrom dat"
},
{
"path": "training-character.gh/labelling-character.py",
"chars": 1804,
"preview": "import os\nfrom shutil import copyfile\nimport cv2\n\naggregatedPath = 'train'\ntrainPath = 'train'\nvalPath = 'val'\nimagesPat"
},
{
"path": "training-character.gh/trainLabels.csv",
"chars": 21760,
"preview": "00000,cheung\n00001,cheung\n00002,cheung\n00003,cheung\n00004,cheung\n00005,cheung\n00006,cheung\n00007,cheung\n00008,cheung\n000"
},
{
"path": "training-character.gh/valLabels.csv",
"chars": 5440,
"preview": "00160,cheung\n00161,cheung\n00162,cheung\n00163,cheung\n00164,cheung\n00165,cheung\n00166,cheung\n00167,cheung\n00168,cheung\n001"
}
]
About this extraction
This page contains the full source code of the deeperic/SpikeFlow GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (71.3 KB), approximately 25.4k tokens, and a symbol index with 37 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.