Comments (8)
重新写个测试更明显点
def test():
captcha = Captcha()
text, image = captcha.gen()
image = convert2gray(image)
image = image.flatten() / 255
predict_text = captcha.crack_captcha(image)
print("正确: {} 预测: {}".format(text, predict_text))
time.sleep(1)
test()
2017-11-02 14:34:54.950657: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-02 14:34:54.950681: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
正确: 51170 预测: 51170
2017-11-02 14:34:56.887373: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_11 not found in checkpoint
2017-11-02 14:34:56.887503: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_10 not found in checkpoint
2017-11-02 14:34:56.889094: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_13 not found in checkpoint
2017-11-02 14:34:56.889150: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_12 not found in checkpoint
2017-11-02 14:34:56.890027: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_14 not found in checkpoint
2017-11-02 14:34:56.891680: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_15 not found in checkpoint
2017-11-02 14:34:56.891723: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_16 not found in checkpoint
2017-11-02 14:34:56.891904: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_19 not found in checkpoint
2017-11-02 14:34:56.894900: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_17 not found in checkpoint
2017-11-02 14:34:56.894900: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key Variable_18 not found in checkpoint
Traceback (most recent call last):
File "captcha.py", line 252, in
test()
File "captcha.py", line 248, in test
test()
File "captcha.py", line 244, in test
predict_text = captcha.crack_captcha(image) #导入模型识别
File "captcha.py", line 217, in crack_captcha
saver.restore(sess, tf.train.latest_checkpoint('.'))
File "/Library/Python/2.7/site-packages/tensorflow/python/training/saver.py", line 1457, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError
from anti-anti-spider.
问题好像是:重试时不要重复定义CNN,即crack_captcha_cnn只执行一次复用即可解决
from anti-anti-spider.
你解决了吗?好像问题不在这
from anti-anti-spider.
我每次都是创建一个新的对象去处理,肯定是执行了一次
from anti-anti-spider.
@1513 crack_captcha_cnn只执行一次,如果在对象里就要处理成单例模式
from anti-anti-spider.
@xiefg 我已经解决了需要重置tf.reset_default_graph(),每次识别前需要进行这个操作,感谢您的回复,另外,要不要设置成单例,多线程下要不要同步处理,不清楚,我试过python多线程跑,好像没有问题
from anti-anti-spider.
@ 1513 ,重置tf.reset_default_graph()代码会报错,你的重置放哪了?
from anti-anti-spider.
@1513 请问一下tf.reset_default_graph()
这个函数放哪里啊,放预测代码中会报错
目前我的解决方案如 @xiefg 所说的,直接使用的单例
from anti-anti-spider.
Related Issues (20)
- 实际项目中的验证码图片如何放入接口识别呢? HOT 3
- 请教下易盾有开源计划么 HOT 3
- 请问python对于VPN调用问题 HOT 2
- 关于验证码识别98%的模型下载问题
- 5位数验证码+尺寸80*28如何调整参数? HOT 1
- Test
- 如何训练自己的验证码模型? HOT 1
- 文件名最好别用特殊字符
- 想用tensorflow_cnn进行中文验证码识别,text2vec该怎么处理呢? HOT 1
- CNN 可以识别图片, 但是能否返回图片中文字的位置信息? HOT 1
- 代码风格有点奇怪 HOT 2
- 亚马逊图片训练集问题 HOT 1
- 大神可否指点一下快手pc端爬取主播作品cookie校验问题
- 可否研究下华为云盘登录,文件列表,下载等?
- 识别含有大写字母的图片怎么改代码
- Anti spider
- 博主有联系方式吗?想谈合作~
- 请求商务推广合作
- 关于代码这件事
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 anti-anti-spider.