ChineseCLIPVisionModel in huggingface can used?
(cropa) root@v3-custom-667bbc1c8454e110f8bda977-7ldhs:/# python /data/codes/test.py
Downloading config.json: 3.01kB [00:00, 215kB/s]
Downloading pytorch_model.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 753M/753M [00:58<00:00, 12.9MB/s]
Downloading (…)rocessor_config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 342/342 [00:00<00:00, 130kB/s]
Traceback (most recent call last):
File "/data/codes/test.py", line 6, in
或者说,有什么办法能直只下载ChineseCLIP的image encoder。 我可以只针对image endcoder 进行微调
好像是tokenizer的问题,换成AutoProcessor好使了
from PIL import Image import requests from transformers import CLIPProcessor, ChineseCLIPVisionModel, AutoProcessor
model = ChineseCLIPVisionModel.from_pretrained("OFA-Sys/chinese-clip-vit-base-patch16")
processor = AutoProcessor.from_pretrained("OFA-Sys/chinese-clip-vit-base-patch16")
url = "https://clip-cn-beijing.oss-cn-beijing.aliyuncs.com/pokemon.jpeg" image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs) last_hidden_state = outputs.last_hidden_state pooled_output = outputs.pooler_output # pooled CLS states print(len(pooled_output))