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: int() argument must be a string, a bytes-like object or a number, not 'list' #57

Open
zakinp opened this issue Dec 2, 2022 · 6 comments

Comments

@zakinp
Copy link

zakinp commented Dec 2, 2022

i got this problem when using "diffusers_trainer.py":

Exception caught on rank 0 at step 10, saving checkpoint...
int() argument must be a string, a bytes-like object or a number, not 'list'
Traceback (most recent call last):
File "/root/waifu-diffusion/trainer/diffusers_trainer.py", line 953, in main
prompt = tokenizer.decode(batch['tokens'][random.randint(0, len(batch['tokens'])-1)])
File "/root/miniconda3/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 3367, in decode
return self._decode(
File "/root/miniconda3/lib/python3.8/site-packages/transformers/tokenization_utils.py", line 931, in _decode
filtered_tokens = self.convert_ids_to_tokens(token_ids, skip_special_tokens=skip_special_tokens)
File "/root/miniconda3/lib/python3.8/site-packages/transformers/tokenization_utils.py", line 906, in convert_ids_to_tokens
index = int(index)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

@thojmr
Copy link

thojmr commented Dec 4, 2022

I got this too when I tried a few days ago, for now you can replace that line with a static prompt until it gets fixed

prompt = "put your prompt here" #tokenizer.decode(batch['tokens'][random.randint(0, len(batch['tokens'])-1)])

@zakinp
Copy link
Author

zakinp commented Dec 4, 2022

I got this too when I tried a few days ago, for now you can replace that line with a static prompt until it gets fixed

prompt = "put your prompt here" #tokenizer.decode(batch['tokens'][random.randint(0, len(batch['tokens'])-1)])

thanks, i found that set the '--extended_mode_chunks' parameter can also fix this error.

@mcrisafu
Copy link

mcrisafu commented Feb 8, 2023

@zakinp To what value did you set it? And what does it? I solved it with setting [0] at the end but this does not seem right...

Thank you and regards

@SY573M404
Copy link

@mcrisafu It is a prompt for generating log images from

@mcrisafu
Copy link

@SY573M404 Thank you. I meant the --extended_mode_chunks parameter. The question was somewhat misleading. Sry.

@SY573M404
Copy link

SY573M404 commented Feb 21, 2023

@mcrisafu It seems that anything greater that 1 would work. It is probably caused by a simple typo here:

if args.extended_mode_chunks < 2:
max_length = self.tokenizer.model_max_length - 2
input_ids = [self.tokenizer([example['input_ids']], truncation=True, return_length=True, return_overflowing_tokens=False, padding=False, add_special_tokens=False, max_length=max_length).input_ids for example in examples if example is not None]
else:
max_length = self.tokenizer.model_max_length
max_chunks = args.extended_mode_chunks
input_ids = [self.tokenizer([example['input_ids']], truncation=True, return_length=True, return_overflowing_tokens=False, padding=False, add_special_tokens=False, max_length=(max_length * max_chunks) - (max_chunks * 2)).input_ids[0] for example in examples if example is not None]

Like you mentioned before, there is [0] at the end of the second of mostly similar if branches, but not the first. I'll try it and open a PR if it works

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

4 participants