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

AutoModelForCausalLM.from_pretrained() fails: "TypeError: 'type' object is not subscriptable" #147

Open
neuron-whisperer opened this issue Nov 2, 2024 · 2 comments

Comments

@neuron-whisperer
Copy link

neuron-whisperer commented Nov 2, 2024

I'm trying to run moondream on a Raspberry Pi 5 (8gb) running Raspberry Pi OS Bookworm Lite (fully up-to-date) and Python 3.8.19, which is the latest version of Python that is compatible with pygame 1.x (the latest version of pygame that runs on Raspberry Pi Lite).

I followed the install instructions and example script upt to the AUtoModelForCausalLM.form_pretrained statement, which generated this error:

>>> model = AutoModelForCausalLM.from_pretrained(
...     model_id, trust_remote_code=True, revision=revision
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.pyenv/versions/3.8.19/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py", line 551, in from_pretrained
    model_class = get_class_from_dynamic_module(
  File "/home/pi/.pyenv/versions/3.8.19/lib/python3.8/site-packages/transformers/dynamic_module_utils.py", line 514, in get_class_from_dynamic_module
    return get_class_in_module(class_name, final_module)
  File "/home/pi/.pyenv/versions/3.8.19/lib/python3.8/site-packages/transformers/dynamic_module_utils.py", line 212, in get_class_in_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/pi/.cache/huggingface/modules/transformers_modules/vikhyatk/moondream2/92d3d73b6fd61ab84d9fe093a9c7fd8c04bf2c0d/moondream.py", line 9, in <module>
    from .vision_encoder import VisionEncoder
  File "/home/pi/.cache/huggingface/modules/transformers_modules/vikhyatk/moondream2/92d3d73b6fd61ab84d9fe093a9c7fd8c04bf2c0d/vision_encoder.py", line 209, in <module>
    class VisionEncoder(nn.Module):
  File "/home/pi/.cache/huggingface/modules/transformers_modules/vikhyatk/moondream2/92d3d73b6fd61ab84d9fe093a9c7fd8c04bf2c0d/vision_encoder.py", line 251, in VisionEncoder
    self, images: Union[PIL.Image.Image, list[PIL.Image.Image], torch.Tensor]
TypeError: 'type' object is not subscriptable

@vikhyat
Copy link
Owner

vikhyat commented Nov 3, 2024

Could you try using the Python client library? https://pypi.org/project/moondream/

I have it set to require Python 3.10+ for now since I haven't been able to test older versions, but if you pass --ignore-requires-python it should ignore that check.

@Aritra02091998
Copy link

How to solve it, in the transformer implementation ? I need to finetune the model

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

3 participants