KarimJedda / dahoam2017

Workshop code
9 stars 5 forks source link

captcha_records.py not working? #3

Open Gintasz opened 7 years ago

Gintasz commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

ok, i'll try tonight . thank you