Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

captcha_records.py not working? #3

Open
Gintasz opened this issue Sep 13, 2017 · 3 comments
Open

captcha_records.py not working? #3

Gintasz opened this issue Sep 13, 2017 · 3 comments

Comments

@Gintasz
Copy link

Gintasz commented Sep 13, 2017

Hey,

I wrote you on FB messenger the same, I'm trying to use your library, I set up virtualenv, installed dependencies, generated captchas, etc, didn't change any source, but when I launch $ python captcha_records.py, I get this crash:

Looking for images in './data/train_data'
>> Writing ./data/train.tfrecords
Traceback (most recent call last):
  File "captcha_records.py", line 123, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/Users/gintas/Downloads/dahoam2017-master/dahoam/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "captcha_records.py", line 102, in main
    conver_to_tfrecords(training_data, TRAIN_FILE)
  File "captcha_records.py", line 62, in conver_to_tfrecords
    label_raw = label_to_one_hot(label).tostring()
  File "captcha_records.py", line 42, in label_to_one_hot
    index.append(CHAR_SETS.index(c))
ValueError: substring not found

you said it might be because captcha generator isn't generating ans.txt or something, but looking at the source code it this repository, it means that this source isn't finished? Would you be able to commit the changes you have?

@nalakawula
Copy link

me, too. encounter an error.

(virt) [sumarsono@mesin-arch solver]$ python2 captcha_records.py 
Looking for images in './data/train_data'
Traceback (most recent call last):
  File "captcha_records.py", line 125, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/home/sumarsono/dahoam2017/virt/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "captcha_records.py", line 103, in main
    training_data = create_data_list(FLAGS.train_dir)
  File "captcha_records.py", line 92, in create_data_list
    image_gray = image.convert('L')
  File "/home/sumarsono/dahoam2017/virt/lib/python2.7/site-packages/PIL/Image.py", line 857, in convert
    self.load()
  File "/home/sumarsono/dahoam2017/virt/lib/python2.7/site-packages/PIL/ImageFile.py", line 231, in load
    "(%d bytes not processed)" % len(b))
IOError: image file is truncated (0 bytes not processed)

@yohanesgultom
Copy link

In case you haven't found out the solution for error below:

Looking for images in './data/train_data'
>> Writing ./data/train.tfrecords
Traceback (most recent call last):
  File "captcha_records.py", line 123, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/Users/gintas/Downloads/dahoam2017-master/dahoam/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "captcha_records.py", line 102, in main
    conver_to_tfrecords(training_data, TRAIN_FILE)
  File "captcha_records.py", line 62, in conver_to_tfrecords
    label_raw = label_to_one_hot(label).tostring()
  File "captcha_records.py", line 42, in label_to_one_hot
    index.append(CHAR_SETS.index(c))
ValueError: substring not found

It simply because this line of code below (function create_data_list in captcha_records.py) try to use split the captcha file name using _ as separator:

label_name = os.path.basename(file_name).split('_')[0]

Simply change it to . solve the issue:

label_name = os.path.basename(file_name).split('.')[0]

As for the IOError, apparently your captcha images are not correctly generated as I don't faced such an error.

@nalakawula
Copy link

ok, i'll try tonight
.
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants