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

[Usage] ImportError: cannot import name 'LlavaLlamaForCausalLM' from 'llava.model' #1291

Closed
Pompey21 opened this issue Mar 17, 2024 · 4 comments

Comments

@Pompey21
Copy link

Pompey21 commented Mar 17, 2024

Describe the issue

Issue:
Hi, I've been trying to setup the project on my local machine and after downloading/installing all necessary pip libraries I tried running the exemplary test script (see below) but am running into problems.
I created a new python file in the home directory of the project - where llava folder is also present.

Also please note that I made a fork and names it deep-llava. Nothing has been changed yet.

Command:

from llava.model.builder import load_pretrained_model
from llava.mm_utils import get_model_name_from_path
from llava.eval.run_llava import eval_model

model_path = "liuhaotian/llava-v1.5-7b"

tokenizer, model, image_processor, context_len = load_pretrained_model(
    model_path=model_path,
    model_base=None,
    model_name=get_model_name_from_path(model_path)
)

Log:

Traceback (most recent call last):
  File "/path-on-my-machine/deep-llava/test.py", line 1, in <module>
    from llava.model.builder import load_pretrained_model
  File "/path-on-my-machine/deep-llava/llava/__init__.py", line 1, in <module>
    from .model import LlavaLlamaForCausalLM
ImportError: cannot import name 'LlavaLlamaForCausalLM' from 'llava.model' (/path-on-my-machine/deep-llava/llava/model/__init__.py)
@zhaohm14
Copy link

As discussed in issue #1101, I've tried the following package versions and they seem to work fine in my environment:

  • transformers==4.37.2
  • accelerate==0.28.0
  • torch==2.1.2

@Pompey21
Copy link
Author

Thank you, this was really helpful :)

@wentaoyuan
Copy link

As discussed in issue #1101, I've tried the following package versions and they seem to work fine in my environment:

  • transformers==4.37.2
  • accelerate==0.28.0
  • torch==2.1.2

I have exactly the same versions but still running into ImportError: cannot import name 'LlavaLlamaForCausalLM' from 'llava.model'

@zhaohm14
Copy link

@wentaoyuan Maybe you can comment out the try...except... block in llava/model/__init__.py

# try:
from .language_model.llava_llama import LlavaLlamaForCausalLM, LlavaConfig
from .language_model.llava_mpt import LlavaMptForCausalLM, LlavaMptConfig
from .language_model.llava_mistral import LlavaMistralForCausalLM, LlavaMistralConfig
# except:
#     pass

to find out more detailed error information.
#1101 (comment)

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