CC6204-Hackaton-Cub-Dataset / CC6204-Hackaton-Cub-Dataset.py
alkzar90's picture
Update CC6204-Hackaton-Cub-Dataset.py
1ba6734
raw
history blame
948 Bytes
"""CC6204-Hackaton-Cub-Dataset: Multimodal"""
import os
import re
import datasets
import pandas as pd
from requests import get
datasets.logging.set_verbosity_info()
logger = datasets.logging.get_logger(__name__)
_REPO = "https://huggingface.co/datasets/alkzar90/CC6204-Hackaton-Cub-Dataset/resolve/main/data"
_URLS = {
"train_test_split": f"{_REPO}/train_test_split.txt",
"classes": f"{_REPO}/classes.txt",
"image_class_labels": f"{_REPO}/image_class_labels.txt",
"images": f"{_REPO}/images.txt",
"image_url": f"{_REPO}/images.zip",
"text_url": f"{_REPO}/text.zip",
}
# Create id-to-label dictionary using the classes file
classes = get(_URLS['classes']).iter_lines()
logger.info(f"classes: {classes}")
_ID2LABEL = {}
for row in classes:
if row != '':
idx, label = row.split(" ")
classes[int(idx)] = re.search("[^\d\.\_+].+", label).group(0).replace("_", " ")
logger.info(f"_ID2LABEL: {_ID2LABEL}")