captcha_recognize
captcha_recognize copied to clipboard
TypeError: object of type 'zip' has no len()
Copying the exact error while running captcha_records.py
(tensorenviron) C:\Work\captcha_recognize-master>python captcha_records.py Looking for images in './data/train_data'
Writing ./data\train.tfrecords Traceback (most recent call last): File "captcha_records.py", line 123, in
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) File "C:\Users\User\AppData\Local\Continuum\anaconda2\envs\tensorenviron\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "captcha_records.py", line 102, in main conver_to_tfrecords(training_data, TRAIN_FILE) File "captcha_records.py", line 55, in conver_to_tfrecords num_examples = len(data_set) TypeError: object of type 'zip' has no len()
you can rewrite it as: .................................................. #num_examples = len(data_set) for image,label in data_set: #image = data_set[index][0] height = image.shape[0] width = image.shape[1] image_raw = image.tostring() #label = data_set[index][1] ........................................................................
I had met the same problem. I sovled it successfully by using the function: list(): ...... data_set = list(data_set) # just add this line num_examples = len(data_set) ......
I tried to solve the error by these suggestion but it didnt work. Do you have any soloution?
thanks in advanced
Hi @mnwato
check my fork. it works perfectly with Python 3.10, TF 2.10.0, NP 1.23.4