Modelling class mistakenly requires tensorflow

#44
by merlerm - opened

I'm using Molmo through AutoModelForCausalLM (and AutoProcessor) and up until transformers version 4.50.3 it works fine. When updating to 4.51.x, the processor randomly starts requiring tensorflow:

  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/models/auto/processing_auto.py", line 343, in from_pretrained
    return processor_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/processing_utils.py", line 1079, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/processing_utils.py", line 1143, in _get_arguments_from_pretrained
    args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/models/auto/image_processing_auto.py", line 553, in from_pretrained
    image_processor_class = get_class_from_dynamic_module(class_ref, pretrained_model_name_or_path, **kwargs)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/dynamic_module_utils.py", line 558, in get_class_from_dynamic_module
    final_module = get_cached_module_file(
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/dynamic_module_utils.py", line 383, in get_cached_module_file
    modules_needed = check_imports(resolved_module_file)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/scratch/work/merlerm1/.conda_envs/vllm/lib/python3.12/site-packages/transformers/dynamic_module_utils.py", line 215, in check_imports
    raise ImportError(
ImportError: This modeling file requires the following packages that were not found in your environment: tensorflow. Run `pip install tensorflow`
Cache dir: /scratch/cs/world-models/hf_models

I looked at the source code but couldn't find a reference to tensorflow anywhere, so I don't believe this is correct. Do you know where this comes from and how it can be fixed? For now, the only solution to run Molmo is to downgrade to 4.50.3

the source is here: https://huggingface.co/allenai/Molmo-7B-D-0924/blob/main/image_preprocessing_molmo.py#L68

Although the resize_method is not tensorflow, as your error message suggests, there seems to be a check to see if all imported modules are available. I wasn't sure how to fix it either, so I've commented out the line that imports tensorflow for now.

Sign up or log in to comment