MapPool / README.md
sraimund's picture
Update README.md
37d5576 verified
|
raw
history blame
No virus
6.4 kB
metadata
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 from DataComp. 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:

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:

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.

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), 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. The embeddings were generated by a pre-trained vision transformer on OpenAI data (OpenCLIP). 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. Training models from scikit 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. 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}}