CLIP-Chinese icon indicating copy to clipboard operation
CLIP-Chinese copied to clipboard

TypeError: unsupported operand type(s) for *: 'dict' and 'int'

Open liuzmx opened this issue 2 years ago • 6 comments

I am a beginner in natural language processing.

When I clone the repository, install the environment dependencies, and try to run the quickstart code in README, the following error occurs, how should I solve it?

my python version is 3.8.15, other dependencies have the same version as the requirements.txt

Traceback (most recent call last):
  File "quickstart.py", line 15, in <module>
    inputs = processor(text=["一只小狗在摇尾巴", "一只小猪在吃饭"], images=image, return_tensors="pt", padding=True)
  File "/home/liuzhiming/.miniconda3/envs/clip-chinese/lib/python3.8/site-packages/transformers/models/clip/processing_clip.py", line 85, in __call__
    image_features = self.feature_extractor(images, return_tensors=return_tensors, **kwargs)
  File "/home/liuzhiming/.miniconda3/envs/clip-chinese/lib/python3.8/site-packages/transformers/models/clip/feature_extraction_clip.py", line 146, in __call__
    images = [self.resize(image=image, size=self.size, resample=self.resample) for image in images]
  File "/home/liuzhiming/.miniconda3/envs/clip-chinese/lib/python3.8/site-packages/transformers/models/clip/feature_extraction_clip.py", line 146, in <listcomp>
    images = [self.resize(image=image, size=self.size, resample=self.resample) for image in images]
  File "/home/liuzhiming/.miniconda3/envs/clip-chinese/lib/python3.8/site-packages/transformers/models/clip/feature_extraction_clip.py", line 207, in resize
    new_short, new_long = size, int(size * long / short)
TypeError: unsupported operand type(s) for *: 'dict' and 'int'

I tried to output the values of several parameters in transformers/models/clip/feature_extraction_clip.py", line 207, in resize and found that the type of size is dict, not int,The specific values are as follows:

size:  {'shortest_edge': 224}
long=960
short=600

liuzmx avatar Dec 07 '22 03:12 liuzmx

I have the same question, then I use the Transformers-4.25.1 and the question is solved. Hope help you~

mobi1019 avatar Dec 08 '22 08:12 mobi1019

I have the same question, then I use the Transformers-4.25.1 and the question is solved. Hope help you~

Thanks, when I updated the version of transformers from 4.18.0 to 4.25.1, the error problem was solved.

liuzmx avatar Dec 08 '22 10:12 liuzmx

TypeError: unsupported operand type(s) for *: 'dict' and 'int'

zbbwss avatar Apr 20 '23 16:04 zbbwss

same question

zbbwss avatar Apr 20 '23 16:04 zbbwss

I have the same question, then I use the Transformers-4.25.1 and the question is solved. Hope help you~

Thanks, when I updated the version of transformers from 4.18.0 to 4.25.1, the error problem was solved.

hello, I met the problem like "texts.append(data['text']) KeyError: 'text'" when I updated the version to 4.25.1, and I would like to ask if you encountered the same problem and how to solve it.

linwhitehat avatar Jun 25 '23 08:06 linwhitehat

I have the same question, then I use the Transformers-4.25.1 and the question is solved. Hope help you~

Thanks, when I updated the version of transformers from 4.18.0 to 4.25.1, the error problem was solved.

hello, I met the problem like "texts.append(data['text']) KeyError: 'text'" when I updated the version to 4.25.1, and I would like to ask if you encountered the same problem and how to solve it.

same question!!!

zhousteven avatar Sep 22 '23 08:09 zhousteven