Comments (2)
同求,需要吧 tf.constant(input_images) 改成 tf.var... 但是不会呀
from captcha_recognize.
已经处理好了,
captcha_model.py 中增加方法
def test(images, keep_prob):
images = tf.reshape(images, [-1, IMAGE_HEIGHT, IMAGE_WIDTH, 1])
with tf.variable_scope('conv1') as scope:
kernel = _weight_variable('weights', shape=[3, 3, 1, 64])
biases = _bias_variable('biases', [64])
pre_activation = tf.nn.bias_add(_conv2d(images, kernel), biases)
conv1 = tf.nn.relu(pre_activation, name=scope.name)
pool1 = _max_pool_2x2(conv1, name='pool1')
with tf.variable_scope('conv2') as scope:
kernel = _weight_variable('weights', shape=[3, 3, 64, 64])
biases = _bias_variable('biases', [64])
pre_activation = tf.nn.bias_add(_conv2d(pool1, kernel), biases)
conv2 = tf.nn.relu(pre_activation, name=scope.name)
pool2 = _max_pool_2x2(conv2, name='pool2')
with tf.variable_scope('conv3') as scope:
kernel = _weight_variable('weights', shape=[3, 3, 64, 64])
biases = _bias_variable('biases', [64])
pre_activation = tf.nn.bias_add(_conv2d(pool2, kernel), biases)
conv3 = tf.nn.relu(pre_activation, name=scope.name)
pool3 = _max_pool_2x2(conv3, name='pool3')
with tf.variable_scope('conv4') as scope:
kernel = _weight_variable('weights', shape=[3, 3, 64, 64])
biases = _bias_variable('biases', [64])
pre_activation = tf.nn.bias_add(_conv2d(pool3, kernel), biases)
conv4 = tf.nn.relu(pre_activation, name=scope.name)
pool4 = _max_pool_2x2(conv4, name='pool4')
with tf.variable_scope('local1') as scope:
batch_size = 1 # images.get_shape()[0].value
reshape = tf.reshape(pool4, [batch_size, -1])
# dim = reshape.get_shape()[1].value
# dim = 512 # for 26x60
dim = 2048 # for 52x120
# dim = 3200 # for 70x160
weights = _weight_variable('weights', shape=[dim, 1024])
biases = _bias_variable('biases', [1024])
local1 = tf.nn.relu(tf.matmul(reshape, weights) + biases, name=scope.name)
local1_drop = tf.nn.dropout(local1, keep_prob)
with tf.variable_scope('softmax_linear') as scope:
weights = _weight_variable('weights', shape=[1024, CHARS_NUM * CLASSES_NUM])
biases = _bias_variable('biases', [CHARS_NUM * CLASSES_NUM])
softmax_linear = tf.add(tf.matmul(local1_drop, weights), biases, name=scope.name)
return tf.reshape(softmax_linear, [-1, CHARS_NUM, CLASSES_NUM])
调用模型
def input_image(image_path, image_height, image_width):
image = Image.open(image_path)
image_gray = image.convert('L')
image_resize = image_gray.resize(size=(image_width, image_height))
image.close()
input_img = np.array(image_resize, dtype='float32')
input_img = np.multiply(input_img.flatten(), 1. / 255) - 0.5
return np.reshape(input_img, (image_height, image_width, 1))
tf.placeholder(tf.float32, [None, image_height, image_width, 1]) # 特征向量
logits = captcha.test(self.X, keep_prob=1)
...
image = input_image(img, self.image_height, self.image_width)
...
predict_result = sess.run(self.predict, feed_dict={self.X: [image]})
from captcha_recognize.
Related Issues (20)
- generate HOT 1
- some other data
- Substring not found / Index out of bounds HOT 3
- Recognize all images.
- Dimensions must be equal, but are 1 and 91 for 'conv1/Conv2D' (op: 'Conv2D') with input shapes:
- terminate called after throwing an instance of 'std::bad_alloc'
- Facing problem while freezing graph for deployment HOT 1
- what result mean trainning is finished HOT 6
- Can't apply for dynamic length of captcha
- 训练时间 HOT 1
- TypeError: object of type 'zip' has no len() HOT 4
- 你好,请问下是用什么模型训练的?
- training.py Running Time HOT 5
- can't convert to tfjs model ValueError: Unsupported input_format - output_format pair: tf_saved_model - tfjs_layers_model
- don't understand how I can scan my captcha image
- python3.6 HOT 5
- Does it work with Multi Threading?
- module 'tensorflow' has no attribute 'app' HOT 1
- Resume Training HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from captcha_recognize.