huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
132.87k stars 26.5k forks source link

ValueError: The checkpoint you are trying to load has model type `florence2` but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date. #33790

Open Romanio1997 opened 3 days ago

Romanio1997 commented 3 days ago

System Info

Windows 10x64 pytorch version: 2.4.0+cu124 Python 3.11.8 transformers-4.46.0. dev0

Who can help?

No response

Information

Tasks

Reproduction

ComfyUI Error Report

Error Details

Expected behavior

DownloadAndLoadFlorence2Model The checkpoint you are trying to load has model type florence2 but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date.

cct1018 commented 2 days ago

I meet the same issue on linux with transformers v4.45.1

LysandreJik commented 2 days ago

Hmmm florence2 should be using remote code, and I see it's set to True in there.

@Rocketknight1, could you take a look at this please?

Rocketknight1 commented 1 day ago

Hi @Romanio1997 @cct1018, can you tell me which checkpoint you're trying to load so I can investigate?

Rocketknight1 commented 1 day ago

I checked microsoft/Florence-2-base and microsoft/Florence-2-large and could not reproduce the issue.

andrewstoliarov commented 1 day ago

@Rocketknight1 try MiaoshouAI/Florence-2-base-PromptGen-v1.5

Rocketknight1 commented 1 day ago

@andrewstoliarov I can reproduce the issue there - the cause is the model is misconfigured. Specifically, config.json is missing the auto_map key that is needed to load remote code correctly.

If you open a PR to that model repo to copy the auto_map key from a working florence2 model like microsoft/Florence-2-large, that should fix the issue!

Romanio1997 commented 1 day ago

Hi @Romanio1997 @cct1018, can you tell me which checkpoint you're trying to load so I can investigate?

I used this workflow:

https://openart.ai/workflows/myaiforce/svOEmbK8C4zyJsCYmqnx

Rocketknight1 commented 1 day ago

@Romanio1997 I'm afraid we can't really debug third-party tools like that if we don't know which checkpoints they're using! My suspicion is that it's loading a florence2 checkpoint on the Hub somewhere that is misconfigured, and this is not a bug in transformers.

andrewstoliarov commented 1 day ago

@Romanio1997 Here the question is about the checkpoint, not the workflow. In fact, you can use any other checkpoint from the list, as it won't significantly affect the result in this workflow.

Romanio1997 commented 1 day ago

@Romanio1997 I'm afraid we can't really debug third-party tools like that if we don't know which checkpoints they're using! My suspicion is that it's loading a florence2 checkpoint on the Hub somewhere that is misconfigured, and this is not a bug in transformers.

The model florence2 was downloaded automatically from huggingface.

Possible causes of the error: Unsupported architecture: The checkpoint refers to a model architecture that is not supported by the version of the Transformers library you have installed. In this case, it is the Florence2 architecture, which may not yet be integrated into the library.

Older version of Transformers: The error may occur because your version of the Transformers library is out of date and does not support newer architectures such as Florence2.

Romanio1997 commented 1 day ago

@Romanio1997 Here the question is about the checkpoint, not the workflow. In fact, you can use any other checkpoint from the list, as it won't significantly affect the result in this workflow.

I know. I just wanted to give you all the data related to the error.