fix latest `PretrainedModel` compat

#1
by kavorite - opened
No description provided.

got this weird traceback when I ran on the main HEAD:

Traceback (most recent call last):
  File "/home/ubuntu/Furrence-2-Large-Demo/app.py", line 197, in <module>
    model = Florence2ForConditionalGeneration.from_pretrained(model_id,).eval()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 309, in _wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 4574, in from_pretrained
    ) = cls._load_pretrained_model(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 4884, in _load_pretrained_model
    model._initialize_missing_keys(checkpoint_keys, ignore_mismatched_sizes, is_quantized)
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 5477, in _initialize_missing_keys
    self.initialize_weights()
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2556, in initialize_weights
    self.smart_apply(self._initialize_weights)
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2547, in smart_apply
    module.smart_apply(module._initialize_weights)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Furrence-2-Large-Demo/.venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1940, in __getattr__
    raise AttributeError(
AttributeError: 'DaViT' object has no attribute '_initialize_weights'

suspect it was caused by transformer version not being pinned, resulting in a minor change in API surface breaking things. fixed

kavorite changed pull request status to open
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment