Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -4,6 +4,7 @@ task_categories:
|
|
| 4 |
- feature-extraction
|
| 5 |
- image-classification
|
| 6 |
- zero-shot-classification
|
|
|
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
tags:
|
|
@@ -12,85 +13,171 @@ tags:
|
|
| 12 |
- laion
|
| 13 |
- image-embeddings
|
| 14 |
- natural-images
|
|
|
|
| 15 |
size_categories:
|
| 16 |
- 100M<n<1B
|
| 17 |
---
|
| 18 |
|
| 19 |
# ReLAION-2B Natural Embeddings
|
| 20 |
|
| 21 |
-
CLIP ViT-H/14 embeddings for ~
|
| 22 |
|
| 23 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
| | |
|
| 28 |
|---|---|
|
| 29 |
-
| **
|
| 30 |
| **Embedding model** | [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K) |
|
| 31 |
| **Embedding dimensions** | 768 |
|
| 32 |
-
| **
|
| 33 |
-
| **Natural score threshold** | > 0.7 |
|
| 34 |
| **Format** | Parquet (Snappy compressed) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Dataset Structure
|
| 37 |
|
| 38 |
| Column | Type | Description |
|
| 39 |
|--------|------|-------------|
|
| 40 |
| `url` | string | Image URL from ReLAION-2B |
|
| 41 |
-
| `natural_score` | float32 | Naturalness prediction (0.7-1.0
|
| 42 |
| `feature_row_id` | int64 | Row index in original LAION-2B embeddings |
|
| 43 |
-
| `embedding` | float32[768] | CLIP ViT-H/14 embedding |
|
| 44 |
|
| 45 |
-
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
```python
|
| 49 |
import pyarrow.parquet as pq
|
|
|
|
| 50 |
|
| 51 |
# Load a single file
|
| 52 |
-
table = pq.read_table("relaion2b_features_00000.parquet")
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
import numpy as np
|
| 56 |
embeddings = np.array([e.as_py() for e in table['embedding']])
|
| 57 |
urls = table['url'].to_pylist()
|
|
|
|
|
|
|
|
|
|
| 58 |
```
|
| 59 |
|
| 60 |
-
**
|
| 61 |
```python
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
-
**
|
| 68 |
```python
|
| 69 |
from datasets import load_dataset
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
```
|
| 77 |
|
| 78 |
## Use Cases
|
| 79 |
|
| 80 |
-
- Image similarity search
|
| 81 |
-
- Zero-shot
|
| 82 |
-
-
|
| 83 |
-
-
|
| 84 |
-
-
|
| 85 |
|
| 86 |
## Related Datasets
|
| 87 |
|
| 88 |
-
- [andropar/relaion2b-natural](https://huggingface.co/datasets/andropar/relaion2b-natural) - Natural scores for all 2.1B ReLAION-2B images
|
| 89 |
|
| 90 |
## Attribution
|
| 91 |
|
| 92 |
- **Source dataset:** [ReLAION-2B-en-research-safe](https://huggingface.co/datasets/laion/relaion2B-en-research-safe) by LAION
|
| 93 |
-
- **Embedding model:** [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
## Citation
|
| 96 |
|
|
@@ -107,7 +194,11 @@ for example in dataset['train']:
|
|
| 107 |
|
| 108 |
## Limitations
|
| 109 |
|
| 110 |
-
- Embeddings are from CLIP ViT-H/14, which was trained on web data and may
|
| 111 |
- "Naturalness" is based on a learned classifier - see [relaion2b-natural](https://huggingface.co/datasets/andropar/relaion2b-natural) for methodology
|
| 112 |
-
- Some URLs may be broken or point to different/removed images
|
| 113 |
- Intended for research use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
- feature-extraction
|
| 5 |
- image-classification
|
| 6 |
- zero-shot-classification
|
| 7 |
+
- image-to-image
|
| 8 |
language:
|
| 9 |
- en
|
| 10 |
tags:
|
|
|
|
| 13 |
- laion
|
| 14 |
- image-embeddings
|
| 15 |
- natural-images
|
| 16 |
+
- image-retrieval
|
| 17 |
size_categories:
|
| 18 |
- 100M<n<1B
|
| 19 |
---
|
| 20 |
|
| 21 |
# ReLAION-2B Natural Embeddings
|
| 22 |
|
| 23 |
+
Pre-computed **CLIP ViT-H/14 embeddings** for ~500 million natural photographs from ReLAION-2B.
|
| 24 |
|
| 25 |
+
## Quick Start
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from datasets import load_dataset
|
| 29 |
+
import numpy as np
|
| 30 |
|
| 31 |
+
# Load with streaming (recommended for this size)
|
| 32 |
+
ds = load_dataset("andropar/relaion2b-natural-embeddings", streaming=True)
|
| 33 |
+
|
| 34 |
+
for row in ds['train']:
|
| 35 |
+
url = row['url']
|
| 36 |
+
embedding = np.array(row['embedding']) # 768-dim CLIP embedding
|
| 37 |
+
score = row['natural_score'] # 0.7 - 1.0
|
| 38 |
+
break
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
## Overview
|
| 42 |
|
| 43 |
| | |
|
| 44 |
|---|---|
|
| 45 |
+
| **Total embeddings** | ~514 million |
|
| 46 |
| **Embedding model** | [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K) |
|
| 47 |
| **Embedding dimensions** | 768 |
|
| 48 |
+
| **Natural score range** | 0.7 - 1.0 (filtered for natural photographs) |
|
|
|
|
| 49 |
| **Format** | Parquet (Snappy compressed) |
|
| 50 |
+
| **Total size** | ~711 GB |
|
| 51 |
+
|
| 52 |
+
## Example Images
|
| 53 |
+
|
| 54 |
+
All images in this dataset have natural scores > 0.7. Examples from different score ranges:
|
| 55 |
+
|
| 56 |
+
**Natural score 0.7 - 0.8:**
|
| 57 |
+

|
| 58 |
+
|
| 59 |
+
**Natural score 0.8 - 0.9:**
|
| 60 |
+

|
| 61 |
+
|
| 62 |
+
**Natural score 0.9 - 1.0:**
|
| 63 |
+

|
| 64 |
+
|
| 65 |
+
*Thumbnails shown solely to illustrate dataset characteristics. Source: ReLAION-2B-en-research-safe (Apache 2.0). Underlying images remain under the copyright of their original creators.*
|
| 66 |
|
| 67 |
## Dataset Structure
|
| 68 |
|
| 69 |
| Column | Type | Description |
|
| 70 |
|--------|------|-------------|
|
| 71 |
| `url` | string | Image URL from ReLAION-2B |
|
| 72 |
+
| `natural_score` | float32 | Naturalness prediction (0.7 - 1.0) |
|
| 73 |
| `feature_row_id` | int64 | Row index in original LAION-2B embeddings |
|
| 74 |
+
| `embedding` | float32[768] | CLIP ViT-H/14 image embedding |
|
| 75 |
|
| 76 |
+
Files are named `relaion2b_features_*.parquet` (2,298 files total).
|
| 77 |
|
| 78 |
+
## Usage Examples
|
| 79 |
+
|
| 80 |
+
**Load embeddings with PyArrow:**
|
| 81 |
```python
|
| 82 |
import pyarrow.parquet as pq
|
| 83 |
+
import numpy as np
|
| 84 |
|
| 85 |
# Load a single file
|
| 86 |
+
table = pq.read_table("data/relaion2b_features_00000.parquet")
|
| 87 |
|
| 88 |
+
# Convert to numpy
|
|
|
|
| 89 |
embeddings = np.array([e.as_py() for e in table['embedding']])
|
| 90 |
urls = table['url'].to_pylist()
|
| 91 |
+
scores = table['natural_score'].to_pylist()
|
| 92 |
+
|
| 93 |
+
print(f"Loaded {len(embeddings)} embeddings, shape: {embeddings.shape}")
|
| 94 |
```
|
| 95 |
|
| 96 |
+
**Image similarity search:**
|
| 97 |
```python
|
| 98 |
+
import numpy as np
|
| 99 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
| 100 |
+
|
| 101 |
+
# Assuming you have a query embedding from CLIP
|
| 102 |
+
query_embedding = ... # Your 768-dim CLIP embedding
|
| 103 |
+
|
| 104 |
+
# Find most similar images
|
| 105 |
+
similarities = cosine_similarity([query_embedding], embeddings)[0]
|
| 106 |
+
top_k = np.argsort(similarities)[-10:][::-1]
|
| 107 |
+
|
| 108 |
+
for idx in top_k:
|
| 109 |
+
print(f"Score: {similarities[idx]:.3f}, URL: {urls[idx]}")
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
**Build a FAISS index for fast search:**
|
| 113 |
+
```python
|
| 114 |
+
import faiss
|
| 115 |
+
import numpy as np
|
| 116 |
|
| 117 |
+
# Load embeddings from multiple files
|
| 118 |
+
all_embeddings = []
|
| 119 |
+
for i in range(10): # First 10 files
|
| 120 |
+
table = pq.read_table(f"data/relaion2b_features_{i:05d}.parquet")
|
| 121 |
+
embs = np.array([e.as_py() for e in table['embedding']], dtype=np.float32)
|
| 122 |
+
all_embeddings.append(embs)
|
| 123 |
+
|
| 124 |
+
embeddings = np.vstack(all_embeddings)
|
| 125 |
+
|
| 126 |
+
# Build index
|
| 127 |
+
index = faiss.IndexFlatIP(768) # Inner product (for normalized vectors)
|
| 128 |
+
faiss.normalize_L2(embeddings)
|
| 129 |
+
index.add(embeddings)
|
| 130 |
+
|
| 131 |
+
# Search
|
| 132 |
+
query = np.random.randn(1, 768).astype(np.float32)
|
| 133 |
+
faiss.normalize_L2(query)
|
| 134 |
+
distances, indices = index.search(query, k=10)
|
| 135 |
```
|
| 136 |
|
| 137 |
+
**Stream with HuggingFace datasets:**
|
| 138 |
```python
|
| 139 |
from datasets import load_dataset
|
| 140 |
|
| 141 |
+
ds = load_dataset("andropar/relaion2b-natural-embeddings", streaming=True)
|
| 142 |
+
|
| 143 |
+
# Process in batches
|
| 144 |
+
batch = []
|
| 145 |
+
for i, row in enumerate(ds['train']):
|
| 146 |
+
batch.append(row['embedding'])
|
| 147 |
+
if len(batch) >= 1000:
|
| 148 |
+
# Process batch
|
| 149 |
+
embeddings = np.array(batch)
|
| 150 |
+
# ... your processing ...
|
| 151 |
+
batch = []
|
| 152 |
+
if i >= 10000:
|
| 153 |
+
break
|
| 154 |
```
|
| 155 |
|
| 156 |
## Use Cases
|
| 157 |
|
| 158 |
+
- **Image similarity search:** Find visually similar images in a large corpus
|
| 159 |
+
- **Zero-shot classification:** Use CLIP embeddings for classification without training
|
| 160 |
+
- **Clustering:** Discover visual themes and patterns in natural photographs
|
| 161 |
+
- **Training data:** Use as features for downstream models
|
| 162 |
+
- **Research:** Study visual representations at scale
|
| 163 |
|
| 164 |
## Related Datasets
|
| 165 |
|
| 166 |
+
- **[andropar/relaion2b-natural](https://huggingface.co/datasets/andropar/relaion2b-natural)** - Natural scores for all 2.1B ReLAION-2B images (use this to get URLs for images with any score threshold)
|
| 167 |
|
| 168 |
## Attribution
|
| 169 |
|
| 170 |
- **Source dataset:** [ReLAION-2B-en-research-safe](https://huggingface.co/datasets/laion/relaion2B-en-research-safe) by LAION
|
| 171 |
+
- **Embedding model:** [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K) trained on LAION-2B
|
| 172 |
+
|
| 173 |
+
## Licensing / Content
|
| 174 |
+
|
| 175 |
+
This repository contains only **metadata and derived features** (URLs, natural scores, embeddings). No images are distributed.
|
| 176 |
+
|
| 177 |
+
- The underlying images are hosted by third-party websites and remain under their original copyrights and terms of use.
|
| 178 |
+
- Our additions (embeddings, documentation) are released under **CC-BY 4.0**.
|
| 179 |
+
- This dataset is based on [ReLAION-2B-en-research-safe](https://huggingface.co/datasets/laion/relaion2B-en-research-safe), which is licensed under **Apache 2.0**.
|
| 180 |
+
- Please check license compatibility for any commercial usage.
|
| 181 |
|
| 182 |
## Citation
|
| 183 |
|
|
|
|
| 194 |
|
| 195 |
## Limitations
|
| 196 |
|
| 197 |
+
- Embeddings are from CLIP ViT-H/14, which was trained on web data and may reflect its biases
|
| 198 |
- "Naturalness" is based on a learned classifier - see [relaion2b-natural](https://huggingface.co/datasets/andropar/relaion2b-natural) for methodology
|
| 199 |
+
- Some URLs may be broken or point to different/removed images over time
|
| 200 |
- Intended for research use
|
| 201 |
+
|
| 202 |
+
---
|
| 203 |
+
|
| 204 |
+
Questions or issues? Open a discussion!
|