Datasets:

Formats:
csv
Languages:
English
ArXiv:
Libraries:
Datasets
Dask
License:
File size: 6,062 Bytes
204f24f
 
 
 
 
 
 
 
 
 
dffabe7
204f24f
cf3797f
204f24f
 
 
 
 
0f8abab
204f24f
184f308
204f24f
184f308
204f24f
e8f3ece
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417e75a
 
 
 
e8f3ece
6a22b29
 
 
 
 
 
 
 
 
 
 
 
 
204f24f
 
184f308
204f24f
cf3797f
204f24f
6184529
978bb8b
 
 
 
 
 
417e75a
978bb8b
 
 
 
 
8ecad98
 
417e75a
 
978bb8b
 
417e75a
 
978bb8b
 
8ecad98
dffabe7
978bb8b
6184529
978bb8b
 
 
 
 
 
 
 
6184529
978bb8b
 
 
 
 
 
 
 
6184529
978bb8b
e8f3ece
 
dffabe7
e8f3ece
978bb8b
 
 
 
 
 
 
 
 
 
 
 
8ecad98
978bb8b
 
 
 
 
 
8ecad98
 
 
978bb8b
6184529
cf3797f
6184529
cf3797f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
license: apache-2.0
task_categories:
- feature-extraction
language:
- en
size_categories:
- 1M<n<10M
---

# `PD12M`

This is a curated PD12M dataset for use with the [II-Commons](https://github.com/Intelligent-Internet/II-Commons) project.

## Dataset Details

### Dataset Description

This dataset comprises a curated [Public Domain 12M](https://source.plus/pd12m) image collection, refined by filtering for active image links. EXIF data was extracted, and images underwent preprocessing and feature extraction using [SigLIP 2](https://huggingface.co/papers/2502.14786). All vector embeddings are normalized 16-bit half-precision vectors optimized for L2 indexing with [vectorchord](https://github.com/tensorchord/vectorchord).

### Dataset Sources

This dataset is derived and organized from [Spawning/PD12M](http://huggingface.co/datasets/Spawning/PD12M). The original license information for the image can be found in the corresponding entry of the original database.

## Dataset Structure

- id: A unique identifier for the image.
- url: The URL of the image.
- caption: A caption for the image.
- caption_long: A long caption for the image.
- origin_width: The width of the original image in pixels.
- origin_height: The height of the original image in pixels.
- processed_width: The width of the processed image in pixels.
- processed_height: The height of the processed image in pixels.
- aspect_ratio: The aspect ratio of the image.
- exif: The EXIF data of the image.
- meta: The metadata of the image.
- created_at: The creation time of the image.
- updated_at: The update time of the image.
- source: The source organization of the image.
- vector: The vector embedding of the image.
- origin_source: The origin source of the image.
- license: The license of the image.

## Prerequisite

PostgreSQL 17 with extensions: [vectorchord](https://github.com/tensorchord/VectorChord) and [pg_search](https://github.com/paradedb/paradedb/tree/dev/pg_search)

The easiest way is to use our [Docker image](https://github.com/Intelligent-Internet/II-Commons/tree/main/examples/db), or build your own. Then load the [psql_basebackup](https://huggingface.co/datasets/Intelligent-Internet/pd12m/tree/psql_basebackup) branch, following the [Quick Start](https://github.com/Intelligent-Internet/II-Commons?tab=readme-ov-file#quick-start) 

Ensure extensions are enabled, connect to the database using the psql, and run the following SQL:

```sql
CREATE EXTENSION IF NOT EXISTS vchord CASCADE;
CREATE EXTENSION IF NOT EXISTS pg_search CASCADE;
```

## Uses

This dataset is available for a wide range of applications.

Here is a demo of how to use the dataset with [II-Commons](https://github.com/Intelligent-Internet/II-Commons).

### Create a Table in PostgreSQL

```sql
CREATE TABLE IF NOT EXISTS is_pd12m (
    id BIGSERIAL PRIMARY KEY,
    url VARCHAR NOT NULL,
    caption VARCHAR NOT NULL DEFAULT '',
    caption_long VARCHAR DEFAULT '',
    origin_width BIGINT NOT NULL DEFAULT 0,
    origin_height BIGINT NOT NULL DEFAULT 0,
    processed_width BIGINT NOT NULL DEFAULT 0,
    processed_height BIGINT NOT NULL DEFAULT 0,
    aspect_ratio DOUBLE PRECISION NOT NULL DEFAULT 0,
    exif JSONB NOT NULL DEFAULT '{}',
    meta JSONB NOT NULL DEFAULT '{}',
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    source JSONB NOT NULL DEFAULT '[]',
    vector halfvec(1152) DEFAULT NULL,
    origin_source VARCHAR DEFAULT '',
    license VARCHAR DEFAULT ''
);
```

### Load csv files to database

1. Load the dataset from local file system to a remote PostgreSQL server:

```sql
\copy is_pd12m FROM 'data/0000000.csv' CSV HEADER;
\copy is_pd12m FROM 'data/0000001.csv' CSV HEADER;
\copy is_pd12m FROM 'data/0000002.csv' CSV HEADER;
...
```

2. Load the dataset from the PostgreSQL server's file system:

```sql
copy is_pd12m FROM 'data/0000000.csv' CSV HEADER;
copy is_pd12m FROM 'data/0000001.csv' CSV HEADER;
copy is_pd12m FROM 'data/0000002.csv' CSV HEADER;
...
```

### Create Indexes

You need to create the following indexes for the best performance.

The `vector` column is a halfvec(1152) column, which is a 16-bit half-precision vector optimized for `L2` indexing with [vectorchord](https://github.com/tensorchord/vectorchord). You can get more information about the vector index from the [vectorchord](https://docs.vectorchord.ai/vectorchord/usage/indexing.html) documentation.

```sql
CREATE UNIQUE INDEX IF NOT EXISTS is_pd12m_url_index ON is_pd12m (url);
CREATE INDEX IF NOT EXISTS is_pd12m_origin_width_index ON is_pd12m (origin_width);
CREATE INDEX IF NOT EXISTS is_pd12m_origin_height_index ON is_pd12m (origin_height);
CREATE INDEX IF NOT EXISTS is_pd12m_processed_width_index ON is_pd12m (processed_width);
CREATE INDEX IF NOT EXISTS is_pd12m_processed_height_index ON is_pd12m (processed_height);
CREATE INDEX IF NOT EXISTS is_pd12m_aspect_ratio_index ON is_pd12m (aspect_ratio);
CREATE INDEX IF NOT EXISTS is_pd12m_exif_index ON is_pd12m USING gin(exif);
CREATE INDEX IF NOT EXISTS is_pd12m_meta_index ON is_pd12m USING gin(meta);
CREATE INDEX IF NOT EXISTS is_pd12m_source_index ON is_pd12m USING gin(source);
CREATE INDEX IF NOT EXISTS is_pd12m_created_at_index ON is_pd12m (created_at);
CREATE INDEX IF NOT EXISTS is_pd12m_updated_at_index ON is_pd12m (updated_at);
CREATE INDEX IF NOT EXISTS is_pd12m_vector_index ON is_pd12m USING vchordrq (vector halfvec_l2_ops)  WITH (options = $$
    residual_quantization = true
    [build.internal]
    lists = [20000]
    build_threads = 6
    spherical_centroids = false
$$);
CREATE INDEX IF NOT EXISTS is_pd12m_caption_index ON is_pd12m (caption) WHERE caption = '';
CREATE INDEX IF NOT EXISTS is_pd12m_caption_long_index ON is_pd12m (caption_long) WHERE caption_long = '';
CREATE INDEX IF NOT EXISTS is_pd12m_vector_null_index ON is_pd12m (vector) WHERE vector IS NULL;
```

### Query with II-Commons

Click this link to learn how to query the dataset with [II-Commons](https://github.com/Intelligent-Internet/II-Commons).