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

AutoProcessor loading error #36194

Closed
3 of 4 tasks
JJJYmmm opened this issue Feb 14, 2025 · 1 comment
Closed
3 of 4 tasks

AutoProcessor loading error #36194

JJJYmmm opened this issue Feb 14, 2025 · 1 comment
Labels

Comments

@JJJYmmm
Copy link

JJJYmmm commented Feb 14, 2025

System Info

Related Issues and PR: #34307 #36184

  • transformers version: 4.49.0.dev0
  • Platform: Linux-5.15.0-131-generic-x86_64-with-glibc2.35
  • Python version: 3.10.16
  • Huggingface_hub version: 0.27.1
  • Safetensors version: 0.5.2
  • Accelerate version: 1.0.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.6.0+cu126 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?:
  • Using GPU in script?:
  • GPU type: NVIDIA H100 80GB HBM3

Who can help?

@Rocketknight1

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Here are the reprodution steps

  1. choose a mllm like qwen2.5vl, and download it's config file
  2. derive its images processor, processor and model
  3. modify the config file and try to use AutoProcessor to load_from_pretrain
  4. and the error occurs like Initializing via AutoImageProcessor before AutoProcessor is imported causes AttributeError #34307
from transformers import Qwen2_5_VLProcessor, Qwen2_5_VLImageProcessor, Qwen2_5_VLForConditionalGeneration, Qwen2_5_VLConfig

class NewProcessor(Qwen2_5_VLProcessor):

    image_processor_class = "NewImageProcessor"

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

class NewImageProcessor(Qwen2_5_VLImageProcessor):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

class NewConfig(Qwen2_5_VLConfig):
    model_type = "new_model"

class NewModel(Qwen2_5_VLForConditionalGeneration):

    config_class = NewConfig

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)



from transformers import AutoModel, AutoImageProcessor, AutoProcessor

AutoImageProcessor.register(NewModel.config_class, NewImageProcessor)
AutoProcessor.register(NewModel.config_class, NewProcessor)
AutoModel.register(NewModel.config_class, NewModel)


if __name__ == "__main__":
    processor = NewProcessor.from_pretrained("path/to/NewModel_config/")

modified config

config.json:

"architectures": [
    "NewModel"
],
"model_type": "new_model",

preprocessor_config.json:

"image_processor_type": "NewImageProcessor",
"processor_class": "NewProcessor"

I also check the pr #36184, it didn't work, because the func _get_class_from_class_name use mapping but the key is string rather than Config class

Expected behavior

None

@JJJYmmm JJJYmmm added the bug label Feb 14, 2025
JJJYmmm added a commit to JJJYmmm/transformers that referenced this issue Feb 14, 2025
@JJJYmmm
Copy link
Author

JJJYmmm commented Feb 17, 2025

fix by #36184

@JJJYmmm JJJYmmm closed this as completed Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant