Skip to content

[ViT] 'str' object cannot be interpreted as an integer #20383

Description

@younesbelkada

System Info

using transformers==4.24.0, the snippet:

import requests
from PIL import Image
from transformers import AutoProcessor

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

# Use the same feature extractor for everyone
feature_extractor = AutoProcessor.from_pretrained("hf-internal-testing/tiny-random-ViTModel")
inputs = feature_extractor(images=image, return_tensors="pt")

fails with the error:

2022-11-22 13:06:49.965720: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-11-22 13:06:50.154832: E tensorflow/stream_executor/cuda/cuda_blas.cc:2981] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2022-11-22 13:06:50.732918: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib64:/usr/local/nccl2/lib:/usr/local/cuda/extras/CUPTI/lib64
2022-11-22 13:06:50.733007: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib64:/usr/local/nccl2/lib:/usr/local/cuda/extras/CUPTI/lib64
2022-11-22 13:06:50.733017: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Traceback (most recent call last):
  File "/home/younes_huggingface_co/scratch/test_processor.py", line 10, in <module>
    inputs = feature_extractor(images=image, return_tensors="pt")
  File "/home/younes_huggingface_co/miniconda3/envs/fix-bnb-test/lib/python3.10/site-packages/transformers/models/vit/feature_extraction_vit.py", line 144, in __call__
    images = [self.resize(image=image, size=self.size, resample=self.resample) for image in images]
  File "/home/younes_huggingface_co/miniconda3/envs/fix-bnb-test/lib/python3.10/site-packages/transformers/models/vit/feature_extraction_vit.py", line 144, in <listcomp>
    images = [self.resize(image=image, size=self.size, resample=self.resample) for image in images]
  File "/home/younes_huggingface_co/miniconda3/envs/fix-bnb-test/lib/python3.10/site-packages/transformers/image_utils.py", line 418, in resize
    return image.resize(size, resample=resample)
  File "/home/younes_huggingface_co/miniconda3/envs/fix-bnb-test/lib/python3.10/site-packages/PIL/Image.py", line 2082, in resize
    return self._new(self.im.resize(size, resample, box))
TypeError: 'str' object cannot be interpreted as an integer

However, using the main branch fixes the issue, so just flagging it!

cc @sgugger

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions