star-vector icon indicating copy to clipboard operation
star-vector copied to clipboard

RecursionError: maximum recursion depth exceeded

Open Charimanhua opened this issue 8 months ago • 0 comments

The quick start code:

from PIL import Image
from starvector.model.starvector_arch import StarVectorForCausalLM
from starvector.data.util import process_and_rasterize_svg

model_name = "/mnt/HDD/Hhr/model/starvector-1b-im2svg"

starvector = StarVectorForCausalLM.from_pretrained(model_name)

starvector.cuda()
starvector.eval()

image_pil = Image.open('star-vector/assets/examples/sample-0.png')
image = starvector.process_images([image_pil])[0].cuda()
batch = {"image": image}

raw_svg = starvector.generate_im2svg(batch, max_length=1000)[0]
svg, raster_image = process_and_rasterize_svg(raw_svg)

has error:

RecursionError                            Traceback (most recent call last)
File ~/anaconda3/envs/starvector/lib/python3.11/site-packages/transformers/tokenization_utils_base.py:2292, in PreTrainedTokenizerBase._from_pretrained(cls, resolved_vocab_files, pretrained_model_name_or_path, init_configuration, token, cache_dir, local_files_only, _commit_hash, _is_local, trust_remote_code, *init_inputs, **kwargs)
   2291 try:
-> 2292     tokenizer = cls(*init_inputs, **init_kwargs)
   2293 except import_protobuf_decode_error():

File ~/anaconda3/envs/starvector/lib/python3.11/site-packages/transformers/models/gpt2/tokenization_gpt2.py:169, in GPT2Tokenizer.__init__(self, vocab_file, merges_file, errors, unk_token, bos_token, eos_token, pad_token, add_prefix_space, add_bos_token, **kwargs)
    167 self.pat = re.compile(r"""'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+""")
--> 169 super().__init__(
    170     errors=errors,
    171     unk_token=unk_token,
    172     bos_token=bos_token,
    173     eos_token=eos_token,
    174     pad_token=pad_token,
    175     add_prefix_space=add_prefix_space,
    176     add_bos_token=add_bos_token,
    177     **kwargs,
    178 )

File ~/anaconda3/envs/starvector/lib/python3.11/site-packages/transformers/tokenization_utils.py:435, in PreTrainedTokenizer.__init__(self, **kwargs)
    434 # 4 init the parent class
--> 435 super().__init__(**kwargs)
    437 # 4. If some of the special tokens are not part of the vocab, we add them, at the end.
    438 # the order of addition is the same as self.SPECIAL_TOKENS_ATTRIBUTES following `tokenizers`
...
File <frozen importlib._bootstrap_external>:1643, in find_spec(self, fullname, target)

File <frozen importlib._bootstrap_external>:128, in _path_join(*path_parts)

RecursionError: maximum recursion depth exceeded

How to fix it? Thanks!

Charimanhua avatar Apr 16 '25 11:04 Charimanhua