Git Product home page Git Product logo

Comments (8)

xiefg avatar xiefg commented on May 18, 2024

重新写个测试更明显点

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.

xiefg avatar xiefg commented on May 18, 2024

问题好像是:重试时不要重复定义CNN,即crack_captcha_cnn只执行一次复用即可解决

from anti-anti-spider.

1513 avatar 1513 commented on May 18, 2024

你解决了吗?好像问题不在这

from anti-anti-spider.

1513 avatar 1513 commented on May 18, 2024

我每次都是创建一个新的对象去处理,肯定是执行了一次

from anti-anti-spider.

xiefg avatar xiefg commented on May 18, 2024

@1513 crack_captcha_cnn只执行一次,如果在对象里就要处理成单例模式

from anti-anti-spider.

1513 avatar 1513 commented on May 18, 2024

@xiefg 我已经解决了需要重置tf.reset_default_graph(),每次识别前需要进行这个操作,感谢您的回复,另外,要不要设置成单例,多线程下要不要同步处理,不清楚,我试过python多线程跑,好像没有问题

from anti-anti-spider.

SimonWang00 avatar SimonWang00 commented on May 18, 2024

@ 1513 ,重置tf.reset_default_graph()代码会报错,你的重置放哪了?

from anti-anti-spider.

ResolveWang avatar ResolveWang commented on May 18, 2024

@1513 请问一下tf.reset_default_graph()这个函数放哪里啊,放预测代码中会报错

目前我的解决方案如 @xiefg 所说的,直接使用的单例

from anti-anti-spider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.