File size: 6,396 Bytes
b29b2d8 a7a244e b29b2d8 a7a244e b29b2d8 90f5495 b29b2d8 37d5576 244a9c4 b29b2d8 5921897 b29b2d8 6febe62 b29b2d8 6febe62 5921897 b29b2d8 5921897 b29b2d8 a7a244e b29b2d8 90f5495 b29b2d8 2541fd9 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 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 |
---
license: cc-by-4.0
---
# MapPool - Bubbling up an extremely large corpus of maps for AI
This repository contains URLs, textual descriptions, embeddings of 50 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 this repository be downloaded?
Simply use Git (or TortoiseGit):
```
git clone https://huggingface.co/datasets/sraimund/MapPool/
```
Alternatively use the HuggingFace API:
```python
import json
import os
from huggingface_hub import hf_hub_download
download_folder = "<your-download-folder>"
repo_id = "sraimund/MapPool"
# this file is given at the root of this repository
with open("file_list.json") as f:
file_list = json.load(f)
for part, files in file_list.items():
for file in files:
file_path = f"{download_folder}/{part}/{file}.parquet"
if os.path.exists(file_path):
continue
hf_hub_download(repo_type="dataset",
repo_id=repo_id,
filename=f"{part}/{file}.parquet",
local_dir=download_folder,
token=read_token)
```
About 225 GB of space are required. The amount doubles when using Git since the files are duplicated in the .git folder.
## How can the parquet files be read?
You can read parquet files with [pandas](https://pandas.pydata.org/):
```python
import pandas as pd
df = pd.read_parquet("<file_name>.parquet")
```
The pyarrow or fastparquet library is required additionally.
## How can the map images be downloaded?
You can download the map images with [img2dataset](https://github.com/rom1504/img2dataset).
```python
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:
```python
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 among the examined ones; 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. Also, duplicates or very similar map images have not been detected.
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_MapPool_2024, title={MapPool - Bubbling up an extremely large corpus of maps for AI}, author={Schnürer, Raimund}, year={2024}}
``` |