Skip to content

Question about the default setting of "ChineseCLIPTextModel " #411

@Harr7y

Description

@Harr7y

ChineseCLIPTextModel 默认值为 False (https://github.com/huggingface/transformers/blob/main/src/transformers/models/chinese_clip/modeling_chinese_clip.py Line 993) self.text_model = ChineseCLIPTextModel(text_config, add_pooling_layer=False)

在运行https://huggingface.co/OFA-Sys/chinese-clip-vit-huge-patch14中的代码text_features = model.get_text_features(**inputs)会报错:
File "/home/xxx/binxiao/TZTS/Filters/CN_CLIP.py", line 72, in
text_features = model.get_text_features(**inputs)
File "/home/xxx/miniconda3/envs/pt26/lib/python3.10/site-packages/transformers/utils/generic.py", line 809, in wrapper
return func(*args, **valid_kwargs)
File "/home/xxx/miniconda3/envs/pt26/lib/python3.10/site-packages/transformers/models/chinese_clip/modeling_chinese_clip.py", line 1075, in get_text_features
text_features = self.text_projection(pooled_output)
File "/home/xxx/miniconda3/envs/pt26/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/xxx/miniconda3/envs/pt26/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl
return forward_call(*args, **kwargs)
File "/home/xxx/miniconda3/envs/pt26/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 125, in forward
return F.linear(input, self.weight, self.bias)
TypeError: linear(): argument 'input' (position 1) must be Tensor, not NoneType

因为get_text_features需要 pooler_output, 这里设置为False就会导致pooler_output为None. 请问这个是意外还是有意为之?

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