image image | image_id string | language string |
|---|---|---|
Not supported with pagination yet | 1.jpg | amharic |
Not supported with pagination yet | 10.jpg | amharic |
Not supported with pagination yet | 100.jpg | amharic |
Not supported with pagination yet | 1000.jpg | amharic |
Not supported with pagination yet | 1001.jpg | amharic |
Not supported with pagination yet | 1002.jpg | amharic |
Not supported with pagination yet | 1003.jpg | amharic |
Not supported with pagination yet | 1004.jpg | amharic |
Not supported with pagination yet | 1005.jpg | amharic |
Not supported with pagination yet | 1006.jpg | amharic |
Not supported with pagination yet | 1007.jpg | amharic |
Not supported with pagination yet | 1008.jpg | amharic |
Not supported with pagination yet | 1009.jpg | amharic |
Not supported with pagination yet | 101.jpg | amharic |
Not supported with pagination yet | 1010.jpg | amharic |
Not supported with pagination yet | 1011.jpg | amharic |
Not supported with pagination yet | 1012.jpg | amharic |
Not supported with pagination yet | 1013.jpg | amharic |
Not supported with pagination yet | 1014.jpg | amharic |
Not supported with pagination yet | 1015.jpg | amharic |
Not supported with pagination yet | 1016.jpg | amharic |
Not supported with pagination yet | 1017.jpg | amharic |
Not supported with pagination yet | 1018.jpg | amharic |
Not supported with pagination yet | 1019.jpg | amharic |
Not supported with pagination yet | 102.jpg | amharic |
Not supported with pagination yet | 1020.jpg | amharic |
Not supported with pagination yet | 1021.jpg | amharic |
Not supported with pagination yet | 1022.jpg | amharic |
Not supported with pagination yet | 1023.jpg | amharic |
Not supported with pagination yet | 1024.jpg | amharic |
Not supported with pagination yet | 1025.jpg | amharic |
Not supported with pagination yet | 1026.jpg | amharic |
Not supported with pagination yet | 1027.jpg | amharic |
Not supported with pagination yet | 1028.jpg | amharic |
Not supported with pagination yet | 1029.jpg | amharic |
Not supported with pagination yet | 103.jpg | amharic |
Not supported with pagination yet | 1030.jpg | amharic |
Not supported with pagination yet | 1031.jpg | amharic |
Not supported with pagination yet | 1032.jpg | amharic |
Not supported with pagination yet | 1033.jpg | amharic |
Not supported with pagination yet | 1034.jpg | amharic |
Not supported with pagination yet | 1035.jpg | amharic |
Not supported with pagination yet | 1036.jpg | amharic |
Not supported with pagination yet | 1037.jpg | amharic |
Not supported with pagination yet | 1038.jpg | amharic |
Not supported with pagination yet | 1039.jpg | amharic |
Not supported with pagination yet | 104.jpg | amharic |
Not supported with pagination yet | 1040.jpg | amharic |
Not supported with pagination yet | 1041.jpg | amharic |
Not supported with pagination yet | 1042.jpg | amharic |
Not supported with pagination yet | 1043.jpg | amharic |
Not supported with pagination yet | 1044.jpg | amharic |
Not supported with pagination yet | 1045.jpg | amharic |
Not supported with pagination yet | 1046.jpg | amharic |
Not supported with pagination yet | 1047.jpg | amharic |
Not supported with pagination yet | 1048.jpg | amharic |
Not supported with pagination yet | 1049.jpg | amharic |
Not supported with pagination yet | 105.jpg | amharic |
Not supported with pagination yet | 1050.jpg | amharic |
Not supported with pagination yet | 1051.jpg | amharic |
Not supported with pagination yet | 1052.jpg | amharic |
Not supported with pagination yet | 1053.jpg | amharic |
Not supported with pagination yet | 1054.jpg | amharic |
Not supported with pagination yet | 1055.jpg | amharic |
Not supported with pagination yet | 1056.jpg | amharic |
Not supported with pagination yet | 1057.jpg | amharic |
Not supported with pagination yet | 1058.jpg | amharic |
Not supported with pagination yet | 1059.jpg | amharic |
Not supported with pagination yet | 106.jpg | amharic |
Not supported with pagination yet | 1060.jpg | amharic |
Not supported with pagination yet | 1061.jpg | amharic |
Not supported with pagination yet | 1062.jpg | amharic |
Not supported with pagination yet | 1063.jpg | amharic |
Not supported with pagination yet | 1064.jpg | amharic |
Not supported with pagination yet | 1065.jpg | amharic |
Not supported with pagination yet | 1066.jpg | amharic |
Not supported with pagination yet | 1067.jpg | amharic |
Not supported with pagination yet | 1068.jpg | amharic |
Not supported with pagination yet | 1069.jpg | amharic |
Not supported with pagination yet | 107.jpg | amharic |
Not supported with pagination yet | 1070.jpg | amharic |
Not supported with pagination yet | 1071.jpg | amharic |
Not supported with pagination yet | 1072.jpg | amharic |
Not supported with pagination yet | 1073.jpg | amharic |
Not supported with pagination yet | 1074.jpg | amharic |
Not supported with pagination yet | 1075.jpg | amharic |
Not supported with pagination yet | 1076.jpg | amharic |
Not supported with pagination yet | 1077.jpg | amharic |
Not supported with pagination yet | 1078.jpg | amharic |
Not supported with pagination yet | 1079.jpg | amharic |
Not supported with pagination yet | 108.jpg | amharic |
Not supported with pagination yet | 1080.jpg | amharic |
Not supported with pagination yet | 1081.jpg | amharic |
Not supported with pagination yet | 1082.jpg | amharic |
Not supported with pagination yet | 1083.jpg | amharic |
Not supported with pagination yet | 1084.jpg | amharic |
Not supported with pagination yet | 1085.jpg | amharic |
Not supported with pagination yet | 1086.jpg | amharic |
Not supported with pagination yet | 1087.jpg | amharic |
Not supported with pagination yet | 1088.jpg | amharic |
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
license: mit language: ["en", "hi", "ru", "am"]
COSMOS
Dataset Overview
COSMOS is a multilingual image dataset containing images in four languages: English, Hindi, Russian, and Amharic.
The dataset is organized into language-specific Parquet files. Each Parquet file contains the corresponding image data together with the image identifier and language metadata.
Dataset Structure
COSMOS/
├── amharic/
│ └── data.parquet
├── english/
│ └── data.parquet
├── hindi/
│ └── data.parquet
└── russian/
└── data.parquet
Languages
The dataset contains images in the following languages:
- English (
en) - Hindi (
hi) - Russian (
ru) - Amharic (
am)
Data Format
Each language-specific Parquet file contains the following fields:
| Field | Description |
|---|---|
image |
Image associated with the sample |
image_id |
Original image identifier or filename |
language |
Language associated with the image |
The image field contains the image associated with each sample.
The image_id field preserves the original image identifier, while the language field specifies the language associated with each sample.
Loading the Dataset
The dataset can be loaded using the Hugging Face datasets library:
from datasets import load_dataset
dataset = load_dataset("swainsubhankar/COSMOS")
You can inspect the available splits using:
print(dataset)
Individual samples can be accessed as follows:
sample = dataset["train"][0]
image = sample["image"]
image_id = sample["image_id"]
language = sample["language"]
print(image)
print(image_id)
print(language)
The image field can be directly used with standard image-processing and multimodal learning pipelines.
Extracting Individual Image Files
The images can be extracted from the dataset and saved as individual image files.
First, install the required libraries:
pip install datasets pillow
Then use the following Python script:
import os
from datasets import load_dataset
# Load the COSMOS dataset
dataset = load_dataset("swainsubhankar/COSMOS")
# Directory where extracted images will be stored
output_dir = "COSMOS_images"
os.makedirs(output_dir, exist_ok=True)
for split in dataset:
split_dir = os.path.join(output_dir, split)
os.makedirs(split_dir, exist_ok=True)
for idx, sample in enumerate(dataset[split]):
image = sample["image"]
image_id = str(sample["image_id"])
# Extract only the filename
image_name = os.path.basename(image_id)
# Add .jpg if no extension is present
if not os.path.splitext(image_name)[1]:
image_name = f"{image_name}.jpg"
output_path = os.path.join(
split_dir,
image_name
)
# Save the image
image.save(output_path)
if (idx + 1) % 100 == 0:
print(
f"Extracted {idx + 1} images from {split}"
)
print("Image extraction completed.")
The extracted images will be organized as:
COSMOS_images/
├── train/
│ ├── 1.jpg
│ ├── 2.jpg
│ ├── 3.jpg
│ └── ...
└── ...
Extracting Images from a Specific Parquet File
If you want to extract images directly from one of the language-specific Parquet files, you can use:
import os
import pandas as pd
from PIL import Image
# Path to the Parquet file
parquet_path = "english/data.parquet"
# Directory for extracted images
output_dir = "english_images"
os.makedirs(output_dir, exist_ok=True)
# Read the Parquet file
df = pd.read_parquet(parquet_path)
for _, row in df.iterrows():
image = row["image"]
image_id = os.path.basename(
str(row["image_id"])
)
if not os.path.splitext(image_id)[1]:
image_id += ".jpg"
output_path = os.path.join(
output_dir,
image_id
)
# Handle Hugging Face Image objects
if isinstance(image, Image.Image):
image.save(output_path)
# Handle image dictionaries
elif isinstance(image, dict):
if image.get("bytes") is not None:
from io import BytesIO
image_obj = Image.open(
BytesIO(image["bytes"])
)
image_obj.save(output_path)
elif image.get("path") is not None:
image_path = image["path"]
if os.path.exists(image_path):
image_obj = Image.open(image_path)
image_obj.save(output_path)
print("Images extracted successfully.")
Extracting Images for All Languages
The following script can be used to extract images from all four language-specific Parquet files:
import os
import pandas as pd
from PIL import Image
from io import BytesIO
BASE_DIR = "COSMOS"
LANGUAGES = [
"amharic",
"english",
"hindi",
"russian"
]
for language in LANGUAGES:
parquet_path = os.path.join(
BASE_DIR,
language,
"data.parquet"
)
output_dir = os.path.join(
BASE_DIR,
language,
"img"
)
os.makedirs(output_dir, exist_ok=True)
print(f"\nProcessing {language}...")
df = pd.read_parquet(parquet_path)
for idx, row in df.iterrows():
image_data = row["image"]
image_id = os.path.basename(
str(row["image_id"])
)
output_path = os.path.join(
output_dir,
image_id
)
# Case 1: PIL Image
if isinstance(image_data, Image.Image):
image_data.save(output_path)
# Case 2: Dictionary representation
elif isinstance(image_data, dict):
# Image bytes are available
if image_data.get("bytes") is not None:
image = Image.open(
BytesIO(image_data["bytes"])
)
image.save(output_path)
# Image is referenced by a path
elif image_data.get("path") is not None:
source_path = image_data["path"]
if os.path.exists(source_path):
image = Image.open(source_path)
image.save(output_path)
else:
print(
f"Image not found: {source_path}"
)
if (idx + 1) % 100 == 0:
print(
f"Processed {idx + 1}/{len(df)} images"
)
print(
f"Finished extracting {language} images."
)
print("\nAll images extracted successfully.")
After extraction, the directory will look like:
COSMOS/
├── amharic/
│ ├── data.parquet
│ └── img/
│ ├── 1.jpg
│ ├── 2.jpg
│ └── ...
│
├── english/
│ ├── data.parquet
│ └── img/
│ ├── 1.jpg
│ ├── 2.jpg
│ └── ...
│
├── hindi/
│ ├── data.parquet
│ └── img/
│ ├── 1.jpg
│ ├── 2.jpg
│ └── ...
│
└── russian/
├── data.parquet
└── img/
├── 1.jpg
├── 2.jpg
└── ...
Intended Use
COSMOS is intended to support research in:
- Multilingual image understanding
- Multimodal learning
- Multilingual visual analysis
- Vision-language modeling
- Multilingual computer vision research
License
This dataset is released under the MIT License.
- Downloads last month
- 46