Вот соответствующий код:
Код: Выделить всё
import open_clip
model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:laion/CLIP-ViT-H-14-laion2B-s32B-b79K')
tokenizer = open_clip.get_tokenizer('hf-hub:laion/CLIP-ViT-H-14-laion2B-s32B-b79K')
text_inputs = ["cat"]
tokenized_inputs = tokenizer(text_inputs)
print(len(tokenized_inputs)) # This prints 77
text_embeddings = model.encode_text(tokenized_inputs)
print(text_embeddings.shape) # This prints [1, 1024]
Подробнее здесь: https://stackoverflow.com/questions/769 ... -77-tokens
Мобильная версия