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

TypeError: object of type 'zip' has no len() #21

Open
sbshukla opened this issue Dec 13, 2018 · 4 comments
Open

TypeError: object of type 'zip' has no len() #21

sbshukla opened this issue Dec 13, 2018 · 4 comments

Comments

@sbshukla
Copy link

sbshukla commented Dec 13, 2018

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()

@ireqhawk
Copy link

ireqhawk commented Mar 5, 2019

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]
........................................................................

@tomorrow1pan
Copy link

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)
......

@mnwato
Copy link

mnwato commented Oct 6, 2020

I tried to solve the error by these suggestion but it didnt work.
Do you have any soloution?

thanks in advanced

@SecurityEnthusiast
Copy link

Hi @mnwato

check my fork. it works perfectly with Python 3.10, TF 2.10.0, NP 1.23.4

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

5 participants