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

Inference error after fine-tuning the model #19

Open
Neo9061 opened this issue Sep 10, 2024 · 1 comment
Open

Inference error after fine-tuning the model #19

Neo9061 opened this issue Sep 10, 2024 · 1 comment

Comments

@Neo9061
Copy link

Neo9061 commented Sep 10, 2024

Hello, i have followed the distributed_train.py and finished training a florence base ft model. However, I tried to use it for inference. I hit error during model loading stage using the following code, same code used in training.

model = AutoModelForCausalLM.from_pretrained(fine_tuned_path, torch_dtype=torch_dtype, trust_remote_code=True).to("cuda:0")

The error is that following.

  File "/opt/conda/envs/myenv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3832, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
  File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/epoch_10/modeling_florence2.py", line 2535, in __init__
    assert config.vision_config.model_type == 'davit', 'only DaViT is supported for now'
AssertionError: only DaViT is supported for now

I looked at the checkpoints that are saved. Its architecture config.json is a different from the original downloaded config.json.

More importantly, I tried to modified the scripts modeling_florence2.py to remove the assertion check. However, it seems the code always try to look at the ./cache dir with /home/ubuntu/.cache/huggingface/modules/transformers_modules/epoch_10/modeling_florence2.py

Do you know what might happen? THX

@Neo9061
Copy link
Author

Neo9061 commented Sep 11, 2024

Figured out. When we use trust_remote=True, we need modfiy the script path in the config.json to point to the local

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

1 participant