AutoModelForCausalLM.from_pretrained dont' work with MiaoshouAI/Florence-2-base-PromptGen-v1.5 !!!

#4
by MousKitos - opened

Hello I have one issue with transformers 4.45.1 under Windows

Work with:
model_Name = "MiaoshouAI/Florence-2-base-PromptGen"

Don't work with:
model_Name = "MiaoshouAI/Florence-2-base-PromptGen-v1.5"
model_Name = "MiaoshouAI/Florence-2-large-PromptGen-v1.5"

model = AutoModelForCausalLM.from_pretrained(model_Name, torch_dtype=torch_dtype, trust_remote_code=True).to(device)

I have : The checkpoint you are trying to load has model type florence2 but Transformers does not recognize this architecture.

Something missing in config.json like for MiaoshouAI/Florence-2-base-PromptGen

Can you add it please πŸ™

"auto_map": {
"AutoConfig": "microsoft/Florence-2-base-ft--configuration_florence2.Florence2Config",
"AutoModelForCausalLM": "microsoft/Florence-2-base-ft--modeling_florence2.Florence2ForConditionalGeneration"
},

Thanks πŸ™

Hiya,

I've made this change in a copy of the repo that includes additional changes, primarily because my code using this stopped working.

createveai/Florence-2-base-PromptGen-v1.5

If you don't want to use my copy of the repo, you can

{
  "_name_or_path": "microsoft/Florence-2-base-ft",
  "architectures": [
    "Florence2ForConditionalGeneration"
  ],
  "auto_map": {
    "AutoConfig": "configuration_florence2.Florence2Config",
    "AutoModelForCausalLM": "modeling_florence2.Florence2ForConditionalGeneration"
  },
  "bos_token_id": 0,
  • update your python script to use the path to the cloned copy i.e.
model = AutoModelForCausalLM.from_pretrained("./Florence-2-base-PromptGen-v1.5", trust_remote_code=True)
processor = AutoProcessor.from_pretrained("./Florence-2-base-PromptGen-v1.5", trust_remote_code=True)

As the Florence2 base modeling_florence2.py was generating a warning about an upcoming transformers change, I updated the class definition in advance to avoid the warning, and thought it might be useful to share.

Hope this helps,

Steve

model has been updated to solve this problem. also update comfyui node to 1.31

Thanks @MiaoshouAI ! Most appreciated

upgrade the transfomers

Sign up or log in to comment