Views
No views yet
1pip install pythainlp
2pip install gensim=4.3.1
3pip install git+https://github.com/openai/CLIP.git1from transformers import AutoModel
2
3text = 'หมากำลังวิ่งในสนามหญ้า'
4model = AutoModel.from_pretrained("patomp/thai-light-multimodal-distill", trust_remote_code=True)
5
6embeddings = model(text)
7print("Text features shape:", embeddings.shape)
81import torch
2import clip
3import requests
4from PIL import Image
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7model, preprocess = clip.load("ViT-B/32", device=device)
8
9url = "http://images.cocodataset.org/val2017/000000039769.jpg"
10image = Image.open(requests.get(url, stream=True).raw)
11image = preprocess(image).unsqueeze(0).to(device)
12
13with torch.no_grad():
14 image_features = model.encode_image(image)
15
16print("Image features shape:", image_features.shape) | Model \ Metrics | text-find-image recall@1 | text-find-image recall@10 | image-find-text recall@1 | image-find-text recall@10 | # text samples per second* |
|---|---|---|---|---|---|
| Multilingual Encoder | |||||
| clip-ViT-B-32-multilingual-v1 | 0.075 | 0.242 | 0.096 | 0.286 | 251 |
| XLM-Roberta-Large-Vit-B-32 | 0.226 | 0.565 | 0.265 | 0.596 | 20 |
| Thai Encoder (WangchanBERTa-based) | |||||
| Thai-Cross-CLIP | 0.167 | 0.475 | 0.197 | 0.523 | 48 |
| Thai Encoder (Thai2Fit-based) | |||||
| thai-light-multimodal-clip-and-distill | 0.082 | 0.328 | 0.118 | 0.401 | 450 |
| thai-light-multimodal-distill | 0.084 | 0.319 | 0.122 | 0.401 | 450 |