RF100-VL Dataset Interface

1.1.0 · active · verified Fri Apr 17

`rf100vl` is a Python library that provides a convenient interface for the RF100-VL dataset, specifically designed for research in multi-modal learning and understanding. It handles the downloading, caching, and access of the dataset's image-caption pairs, allowing users to easily integrate it into their machine learning pipelines. The current stable version is 1.1.0, and the project appears to be in maintenance with occasional minor updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `RF100VL` dataset, automatically downloading it to a specified `root_dir` if it's not already present. It then shows how to access an individual item, which provides a PIL Image and its corresponding text caption.

import os
from rf100vl.rf100vl import RF100VL

# Define a directory for the dataset; it will be created if it doesn't exist.
# Using an environment variable or a default path for flexibility.
data_root = os.environ.get('RF100VL_DATA_ROOT', './rf100vl_data')
os.makedirs(data_root, exist_ok=True)

try:
    # Initialize the dataset. Set download=True to fetch if not present.
    # This can take significant time and disk space.
    dataset = RF100VL(root_dir=data_root, split='train', download=True)

    print(f"\nSuccessfully loaded RF100VL dataset with {len(dataset)} items in '{data_root}'.")

    # Access a sample item (e.g., the first one)
    sample_item = dataset[0]
    image = sample_item['image'] # A PIL Image object
    caption = sample_item['caption'] # A string caption

    print(f"\nFirst item details:")
    print(f"  Caption: '{caption[:100]}...' ")
    print(f"  Image type: {type(image)}, size: {image.size}, mode: {image.mode}")

    # Further processing (e.g., transforming image, tokenizing caption) would go here.

except Exception as e:
    print(f"\nAn error occurred during dataset initialization or access: {e}")
    print("Please ensure you have network access, sufficient disk space, and correct permissions for the data_root directory.")

view raw JSON →