🚀 clip-vit-large-patch14-ko
這是一個韓語CLIP模型,通過Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation進行訓練,可用於圖像和文本的匹配任務。
🚀 快速開始
該韓語CLIP模型使用Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation進行訓練。
訓練代碼:https://github.com/Bing-su/KoCLIP_training_code
使用的數據:AIHUB中的所有韓語 - 英語平行數據
💻 使用示例
基礎用法
import requests
import torch
from PIL import Image
from transformers import AutoModel, AutoProcessor
repo = "Bingsu/clip-vit-large-patch14-ko"
model = AutoModel.from_pretrained(repo)
processor = AutoProcessor.from_pretrained(repo)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=["고양이 두 마리", "개 두 마리"], images=image, return_tensors="pt", padding=True)
with torch.inference_mode():
outputs = model(**inputs)
logits_per_image = outputs.logits_per_image
probs = logits_per_image.softmax(dim=1)
>>> probs
tensor([[0.9974, 0.0026]])
高級用法
from transformers import pipeline
repo = "Bingsu/clip-vit-large-patch14-ko"
pipe = pipeline("zero-shot-image-classification", model=repo)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
result = pipe(images=url, candidate_labels=["고양이 한 마리", "고양이 두 마리", "분홍색 소파에 드러누운 고양이 친구들"], hypothesis_template="{}")
>>> result
[{'score': 0.9907576441764832, 'label': '분홍색 소파에 드러누운 고양이 친구들'},
{'score': 0.009206341579556465, 'label': '고양이 두 마리'},
{'score': 3.606083555496298e-05, 'label': '고양이 한 마리'}]
📄 許可證
本項目採用MIT許可證。