Datasets:
Tasks:
Image Classification
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
1K<n<10K
License:
Commit ·
7dbae13
1
Parent(s): be2f547
Upload FaceMask.py
Browse files- FaceMask.py +108 -0
FaceMask.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""Untitled9.ipynb
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colaboratory.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1qRAN4BBFZkzQKFec3qaXZ_obxuWQa6c6
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
# coding=utf-8
|
| 11 |
+
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 12 |
+
#
|
| 13 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 14 |
+
# you may not use this file except in compliance with the License.
|
| 15 |
+
# You may obtain a copy of the License at
|
| 16 |
+
#
|
| 17 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 18 |
+
#
|
| 19 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 20 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 21 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 22 |
+
# See the License for the specific language governing permissions and
|
| 23 |
+
# limitations under the License.
|
| 24 |
+
"""Beans leaf dataset with images of diseased and health leaves."""
|
| 25 |
+
|
| 26 |
+
import os
|
| 27 |
+
|
| 28 |
+
import datasets
|
| 29 |
+
from datasets.tasks import ImageClassification
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
_HOMEPAGE = "https://github.com/poolrf2001/maskFace"
|
| 33 |
+
|
| 34 |
+
_CITATION = """\
|
| 35 |
+
@ONLINE {masksdata,
|
| 36 |
+
author="Pool_rf",
|
| 37 |
+
title="Mask face dataset",
|
| 38 |
+
month="January",
|
| 39 |
+
year="2023",
|
| 40 |
+
url="https://github.com/poolrf2001/maskFace"
|
| 41 |
+
}
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
_DESCRIPTION = """\
|
| 45 |
+
MaskFace es un conjunto de datos de imágenes de personas con y sin mascarillas Consta de 3 clases: 1 clase de si la persona está puesta la mascarilla,
|
| 46 |
+
otra clase si la persona no esta puesta la mascarilla y una clase donde la persona está puesta la mascarilla incorrectamente.
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
_URLS = {
|
| 50 |
+
"train": "https://huggingface.co/datasets/poolrf2001/Face_Mask/tree/main/train.zip",
|
| 51 |
+
"validation": "https://huggingface.co/datasets/poolrf2001/Face_Mask/tree/main/validation.zip",
|
| 52 |
+
"test": "https://huggingface.co/datasets/poolrf2001/Face_Mask/tree/main/test.zip",
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
_NAMES = ["mask_weared_incorrect", "width_mask", "without_mask"]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class Beans(datasets.GeneratorBasedBuilder):
|
| 59 |
+
"""MaskFace images dataset."""
|
| 60 |
+
|
| 61 |
+
def _info(self):
|
| 62 |
+
return datasets.DatasetInfo(
|
| 63 |
+
description=_DESCRIPTION,
|
| 64 |
+
features=datasets.Features(
|
| 65 |
+
{
|
| 66 |
+
|
| 67 |
+
"image": datasets.Image(),
|
| 68 |
+
"labels": datasets.features.ClassLabel(names=_NAMES),
|
| 69 |
+
}
|
| 70 |
+
),
|
| 71 |
+
supervised_keys=("image", "labels"),
|
| 72 |
+
homepage=_HOMEPAGE,
|
| 73 |
+
citation=_CITATION,
|
| 74 |
+
task_templates=[ImageClassification(image_column="image", label_column="labels")],
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
def _split_generators(self, dl_manager):
|
| 78 |
+
data_files = dl_manager.download_and_extract(_URLS)
|
| 79 |
+
return [
|
| 80 |
+
datasets.SplitGenerator(
|
| 81 |
+
name=datasets.Split.TRAIN,
|
| 82 |
+
gen_kwargs={
|
| 83 |
+
"files": dl_manager.iter_files([data_files["train"]]),
|
| 84 |
+
},
|
| 85 |
+
),
|
| 86 |
+
datasets.SplitGenerator(
|
| 87 |
+
name=datasets.Split.VALIDATION,
|
| 88 |
+
gen_kwargs={
|
| 89 |
+
"files": dl_manager.iter_files([data_files["validation"]]),
|
| 90 |
+
},
|
| 91 |
+
),
|
| 92 |
+
datasets.SplitGenerator(
|
| 93 |
+
name=datasets.Split.TEST,
|
| 94 |
+
gen_kwargs={
|
| 95 |
+
"files": dl_manager.iter_files([data_files["test"]]),
|
| 96 |
+
},
|
| 97 |
+
),
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
def _generate_examples(self, files):
|
| 101 |
+
for i, path in enumerate(files):
|
| 102 |
+
file_name = os.path.basename(path)
|
| 103 |
+
if file_name.endswith(".png"):
|
| 104 |
+
yield i, {
|
| 105 |
+
|
| 106 |
+
"image": path,
|
| 107 |
+
"labels": os.path.basename(os.path.dirname(path)).lower(),
|
| 108 |
+
}
|