JackonYang / captcha-tensorflow

Image Captcha Solving Using TensorFlow and CNN Model. Accuracy 90%+
MIT License
996 stars 272 forks source link

TypeError: 'float' object cannot be interpreted as an integer #48

Open ecarey-paa opened 1 year ago

ecarey-paa commented 1 year ago

Nice project. Thanks for sharing. Having problem though. Cloned repo. Did a pip install -r requirements.txt. Tried to run gen_captcha.py and I get a TypeError.

I uncommented the tensorflow=2.1.4 line in the requirements.txt file and set it to 2.8.4 since 2.1.4 was not found and the earliest version of tensroflow was 2.8.4.

My env: MacOS Monteray v12.6 Python 3.10.7

(.env) ➜  captcha-tensorflow git:(master) python datasets/gen_captcha.py -d --npi=4 -n 6
10 choices: 0123456789
generating 6 epoches of captchas in ./images/char-4-epoch-6/train.
Traceback (most recent call last):
  File "/Users/evancarey/prj/captcha-tensorflow/datasets/gen_captcha.py", line 137, in <module>
    gen_dataset()
  File "/Users/evancarey/prj/captcha-tensorflow/datasets/gen_captcha.py", line 80, in gen_dataset
    _gen_captcha(build_file_path('train'), num_per_image, n_epoch, width, height, choices=choices, max_images_count=max_images_count)
  File "/Users/evancarey/prj/captcha-tensorflow/datasets/gen_captcha.py", line 48, in _gen_captcha
    image.write(captcha, fn)
  File "/Users/evancarey/prj/captcha-tensorflow/.env/lib/python3.10/site-packages/captcha/image.py", line 58, in write
    im = self.generate_image(chars)
  File "/Users/evancarey/prj/captcha-tensorflow/.env/lib/python3.10/site-packages/captcha/image.py", line 228, in generate_image
    im = self.create_captcha_image(chars, color, background)
  File "/Users/evancarey/prj/captcha-tensorflow/.env/lib/python3.10/site-packages/captcha/image.py", line 212, in create_captcha_image
    mask = im.convert('L').point(table)
  File "/Users/evancarey/prj/captcha-tensorflow/.env/lib/python3.10/site-packages/PIL/Image.py", line 1651, in point
    return self._new(self.im.point(lut, mode))
TypeError: 'float' object cannot be interpreted as an integer
(.env) ➜  captcha-tensorflow git:(master)
ecarey-paa commented 1 year ago

My guess so far is it's the versions of Python and Tensorflow. Have not yet found how to install that version of Tensorflow.

Troodi commented 1 year ago

@ecarey-paa use captha==0.5.0