import datasets from datasets.tasks import ImageClassification import os from collections import defaultdict _CITATION = """\ @misc{https://doi.org/10.48550/arxiv.2301.11932, doi = {10.48550/ARXIV.2301.11932}, url = {https://arxiv.org/abs/2301.11932}, author = {Al-Barham, Muhammad and Alsharkawi, Adham and Al-Yaman, Musa and Al-Fetyani, Mohammad and Elnagar, Ashraf and SaAleek, Ahmad Abu and Al-Odat, Mohammad}, keywords = {Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences}, title = {RGB Arabic Alphabets Sign Language Dataset}, publisher = {arXiv}, year = {2023}, copyright = {Creative Commons Attribution 4.0 International} } """ _DESCRIPTION = "RGB Arabic Alphabet Sign Language (AASL) dataset comprises 7,857 raw and fully labelled RGB images of the Arabic sign language alphabets, which to our best knowledge is the first publicly available RGB dataset. The dataset is aimed to help those interested in developing real-life Arabic sign language classification models. AASL was collected from more than 200 participants and with different settings such as lighting, background, image orientation, image size, and image resolution. Experts in the field supervised, validated and filtered the collected images to ensure a high-quality dataset." _URL = "https://huggingface.co/datasets/pain/AASL/resolve/main/images.zip" _HOMEPAGE = "https://www.kaggle.com/datasets/muhammadalbrham/rgb-arabic-alphabets-sign-language-dataset" _LICENSE = "CC BY-SA 4.0" class AASL(datasets.GeneratorBasedBuilder): def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "image": datasets.Image(), "label": datasets.features.ClassLabel(names=['Ain','Al','Alef','Beh','Dad','Dal','Feh','Ghain','Hah','Heh','Jeem','Kaf','Khah','Laa','Lam','Meem','Noon','Qaf','Reh','Sad','Seen','Sheen','Tah','Teh','Teh_Marbuta','Theh','Waw','Yeh','Zah','Zain', 'thal']) } ), supervised_keys=("image", "label"), homepage=_HOMEPAGE, citation=_CITATION, task_templates=[ ImageClassification( image_column="image", label_column="label" ) ], license=_LICENSE ) def _split_generators(self, dl_manager): images_path = dl_manager.download_and_extract(_URL) return [datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"images":dl_manager.iter_files([images_path])} )] def _generate_examples(self, images): two_exp = defaultdict(int) for i, file in enumerate(images): class_name = os.path.basename(file).split('.')[0].split('_')[0] two_exp[class_name] += 1 if two_exp[class_name]>2: continue else: with open(file, "rb"): yield str(i), { "image": file, "label": class_name, }