File size: 5,270 Bytes
b29b2d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: cc-by-4.0
---
# MapPool

This large corpus contains URLs, textual descriptions, embeddings of 75 million potential maps. It has been derived from the [CommonPool  dataset](https://huggingface.co/datasets/mlfoundations/datacomp_xlarge) from [DataComp](https://www.datacomp.ai/). The MapPool dataset may help to train resource-intensive architectures like Transformers or Diffusion Models in order to establish foundation models specialized on maps.

## How is the data structured?

| Key                              | Meaning 
|----------------------------------|----------
| uid                              | Unique identifier       
| url                              | Link to the image   
| text                             | Textual description of the image    
| original_width / original_height | Dimensions of the image     
| sha256                           | Hash of the image (to verify if the image is the same as the one in the URL) 
| l14_img                          | Embedding of the image (768 dimensions)  
| l14_txt                          | Embedding of the textual description (768 dimensions) 
| clip_l14_similarity_score        | Similarity between the image and text (higher values indicate higher similarity) 


## How can the parquet files be read?

You can read parquet files with [pandas](https://pandas.pydata.org/):
```
import pandas as pd

df = pd.read_parquet("<file_name>.parquet")
```
The pyarrow or fastparquet library is required additionally.

## How can the images be downloaded?

You can download the images with [img2dataset](https://github.com/rom1504/img2dataset).
```
from img2dataset import download

download(
    thread_count=64,
    url_list="<file_name>.parquet",
    output_folder="<folder_path>",
    resize_mode="no",
    output_format="files",
    input_format="parquet",
    url_col="url",
    caption_col="text",
    verify_hash=("sha256", "sha256"),
)
```
Windows users:

```
import multiprocessing as mp
from img2dataset import download

def main():
    download(...)

if __name__ == "__main__":
    multiprocessing.freeze_support()
    main()
```

## How was this dataset created?

The dataset is a subset of the [CommonPool  dataset (xlarge)](https://huggingface.co/datasets/mlfoundations/datacomp_xlarge), which consists of 10,000,000,000 images. To filter the data, a classifier was established based on the embeddings of 1,860 maps and 1,860 non-maps and evaluated on 1,240 maps and 1,240 non-maps. This map dataset has been collected by [Schnürer et al. 2021](https://doi.org/10.1080/00087041.2020.1738112). The embeddings were generated by a pre-trained vision transformer on OpenAI data ([OpenCLIP](https://github.com/mlfoundations/open_clip)). Afterwards, different methods were tested to classify the embeddings:

| Model                                         | Accuracy 
|-----------------------------------------------|----------
| Xception / InceptionResNetV2 (= Baseline)     | 96.7     
| ViT-L/14 + L2 distance to averaged embeddings | 96.7     
| ViT-L/14 + Logistic Regression                | 97.9     
| ViT-L/14 + MLP (3x256 units)                  | 98.2     
| ViT-L/14 + SVM (polynomial, degree 3)         | 98.5     

Merely averaging the embeddings and calculating the nearest distance already reached the same accuracy as the two classification networks in [Schnürer et al. 2021](https://doi.org/10.1080/00087041.2020.1738112). Training models from [scikit](https://scikit-learn.org/) to distinguish maps and non-maps increased the validation accuracy even further. The highest accuracy has been achieved with a Support Vector Machine (SVM) with a polynomial kernel. 

Overall, downloading the CommonPool dataset, separating non-maps and uploading the maps took about 50h for 10 CPUs and 120GB RAM on average as well as caused incoming network traffic of 500MB/s. SVMs are computationally the most demanding model; luckily, the inference speed could be improved by using an [Intel Extension](https://intel.github.io/scikit-learn-intelex). Classifying 500,000 embeddings took about 10 secs. 

## What are the limitations?

A qualitative inspection of the detected maps in the CommonPool dataset looks promising, however, it is not known what the actual accuracy is. Especially the false negative rate is hard to estimate due to the high number of non-maps among the CommonPool images. Mixtures between natural images and maps (e.g. a map printed on a bag, a map in a park) have not been further examined - ideally, those cases would be also classified as maps.

Textual embeddings have not been considered in the separation process so far. The training dataset has a quite large variety of images, however, the textual descriptions may be too specific since the dataset originates only from Pinterest. Also, simply filtering by the word 'map' may lead to false positives as it has many meanings. Nevertheless, the textual embedding space may be explored in the future and possibly help to refine the visual classifier. 

It is planned to republish the training data and deploy the classification model.

### Citation

```
@inproceedings{Schnürer_2024, title={MapPool - Diving deep to bubble up a huge dataset for MapAI}, author={Schnürer, Raimund}, year={2024}}
```