imregis / README.md
Geologi's picture
add README.md file
a81e639 verified
|
Raw
History Blame Contribute Delete
3.46 kB
metadata
language:
  - pt
size_categories:
  - 100K<n<1M
task_categories:
  - image-to-text
tags:
  - image-captioning
  - multimodal
  - oil-and-gas
  - geosciences
  - portuguese
configs:
  - config_name: images
    data_files:
      - split: train
        path: data/images/train-*.parquet
  - config_name: annotations
    data_files:
      - split: train
        path: data/annotations/train-*.parquet

ImREGIS

ImREGIS (Image-REGIS) is a Portuguese multimodal image-text dataset, automatically extracted from the REGIS collection — a set of technical documents, theses, and reports from the Oil & Gas (O&G) and Geosciences domain.

The dataset contains over 439,000 unique images and 581,000 image-text pairs, extracted from more than 20,000 PDF documents, combining captions (descriptive text placed near the image) and descriptions (textual references to the image scattered throughout the document body).

Structure

The dataset is split into two tables (configs) linked by the image_id column.

A single doc_id may have more than one image associated with it (documents with multiple figures/pages).

images

One row per unique image (deduplicated by image_id).

column type description
image_id string unique image identifier (join key)
doc_id string source document identifier
width int32 width in pixels
height int32 height in pixels
format string original format
image binary (bytes) raw image content

annotations

One or more text rows per image.

column type description
row_id string unique annotation row identifier
doc_id string source document identifier
image_id string identifier of the associated image (key for images)
type string caption or description
text string text content
lang string language

How to load

from datasets import load_dataset

images = load_dataset("Geologi/imregis", "images", split="train")
annotations = load_dataset("Geologi/imregis", "annotations", split="train")

Given the dataset size (250GB+), streaming is recommended instead of loading everything into memory:

images = load_dataset("Geologi/imregis", "images", split="train", streaming=True)
annotations = load_dataset("Geologi/imregis", "annotations", split="train", streaming=True)

Joining images and text

For local use (if it fits in memory/disk), via pandas, always join on image_id:

import pandas as pd

df_images = images.to_pandas()
df_annot = annotations.to_pandas()

df = df_annot.merge(df_images, on="image_id", how="left", suffixes=("", "_img"))

For streaming use, perform the join on demand, for example by building an in-memory index of images (if the images table fits) and iterating over annotations:

from datasets import load_dataset

images_index = {
    row["image_id"]: row["image"]
    for row in load_dataset("Geologi/imregis", "images", split="train", streaming=True)
}

for row in load_dataset("Geologi/imregis", "annotations", split="train", streaming=True):
    image_bytes = images_index.get(row["image_id"])
    # use row["text"], row["type"], row["lang"], and image_bytes

Decoding the image bytes

The image column contains the raw bytes of the original file. To open it as an image:

from PIL import Image
import io

img = Image.open(io.BytesIO(images[0]["image"]))
img.show()