Views
No views yet
ALIGN 1.8B image-text dataset which is a collection of "noisy" alt-text and image pairs from webpages, but open-source. COYO-700M and ALIGN 1.8B are "noisy" because minimal filtering was applied. COYO is similar to the other open-source image-text dataset, LAION but with the following differences. While LAION 2B is a much larger dataset of 2 billion English pairs, compared to COYO’s 700 million pairs, COYO pairs come with more metadata that give users more flexibility and finer-grained control over usage. The following table shows the differences: COYO comes equipped with aesthetic scores for all pairs, more robust watermark scores, and face count data.| COYO | LAION 2B | ALIGN 1.8B |
|---|---|---|
| Image-text similarity score calculated with CLIP ViT-B/32 and ViT-L/14 models, they are provided as metadata but nothing is filtered out so as to avoid possible elimination bias | Image-text similarity score provided with CLIP (ViT-B/32) - only examples above threshold 0.28 | Minimal, Frequency based filtering |
| NSFW filtering on images and text | NSFW filtering on images | Google Cloud API |
| Face recognition (face count) data provided as meta-data | No face recognition data | NA |
| 700 million pairs all English | 2 billion English | 1.8 billion |
| From CC 2020 Oct - 2021 Aug | From CC 2014-2020 | NA |
| Aesthetic Score | Aesthetic Score Partial | NA |
| More robust Watermark score | Watermark Score | NA |
| Hugging Face Hub | Hugging Face Hub | Not made public |
| English | English | English? |
1import requests
2import torch
3from PIL import Image
4from transformers import AlignProcessor, AlignModel
5
6processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
7model = AlignModel.from_pretrained("kakaobrain/align-base")
8
9url = "http://images.cocodataset.org/val2017/000000039769.jpg"
10image = Image.open(requests.get(url, stream=True).raw)
11candidate_labels = ["an image of a cat", "an image of a dog"]
12
13inputs = processor(text=candidate_labels, images=image, return_tensors="pt")
14
15with torch.no_grad():
16 outputs = model(**inputs)
17
18# this is the image-text similarity score
19logits_per_image = outputs.logits_per_image
20# we can take the softmax to get the label probabilities
21probs = logits_per_image.softmax(dim=1)
22print(probs)1import requests
2import torch
3from PIL import Image
4from transformers import AlignProcessor, AlignModel
5
6processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
7model = AlignModel.from_pretrained("kakaobrain/align-base")
8
9url = "http://images.cocodataset.org/val2017/000000039769.jpg"
10image = Image.open(requests.get(url, stream=True).raw)
11text = "an image of a cat"
12
13inputs = processor(text=text, images=image, return_tensors="pt")
14
15with torch.no_grad():
16 outputs = model(**inputs)
17
18# multi-modal text embedding
19text_embeds = outputs.text_embeds
20
21# multi-modal image embedding
22image_embeds = outputs.image_embeds1import requests
2import torch
3from PIL import Image
4from transformers import AlignProcessor, AlignModel
5
6processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
7model = AlignModel.from_pretrained("kakaobrain/align-base")
8
9# image embeddings
10url = "http://images.cocodataset.org/val2017/000000039769.jpg"
11image = Image.open(requests.get(url, stream=True).raw)
12inputs = processor(images=image, return_tensors="pt")
13
14image_embeds = model.get_image_features(
15 pixel_values=inputs['pixel_values'],
16)
17
18# text embeddings
19text = "an image of a cat"
20inputs = processor(text=text, return_tensors="pt")
21
22text_embeds = model.get_text_features(
23 input_ids=inputs['input_ids'],
24 attention_mask=inputs['attention_mask'],
25 token_type_ids=inputs['token_type_ids'],
26)