Convert dataset to Parquet
#3
by
qgyd2021
- opened
This view is limited to 50 files because it contains too many changes.
See the raw diff here.
- .gitignore +0 -9
- README.md +46 -2
- cppe-5.py +0 -135
- cppe_5_backup.py +0 -118
- data/annotations/test.jsonl +0 -3
- data/images/1.png +0 -3
- data/images/10.png +0 -3
- data/images/100.png +0 -3
- data/images/1000.png +0 -3
- data/images/1001.png +0 -3
- data/images/1002.png +0 -3
- data/images/1003.png +0 -3
- data/images/1004.png +0 -3
- data/images/1005.png +0 -3
- data/images/1006.png +0 -3
- data/images/1007.png +0 -3
- data/images/1008.png +0 -3
- data/images/1009.png +0 -3
- data/images/101.png +0 -3
- data/images/1010.png +0 -3
- data/images/1011.png +0 -3
- data/images/1012.png +0 -3
- data/images/1013.png +0 -3
- data/images/1014.png +0 -3
- data/images/1015.png +0 -3
- data/images/1016.png +0 -3
- data/images/1017.png +0 -3
- data/images/1018.png +0 -3
- data/images/1019.png +0 -3
- data/images/102.png +0 -3
- data/images/1020.png +0 -3
- data/images/1021.png +0 -3
- data/images/1022.png +0 -3
- data/images/1023.png +0 -3
- data/images/1024.png +0 -3
- data/images/1025.png +0 -3
- data/images/1026.png +0 -3
- data/images/1027.png +0 -3
- data/images/1028.png +0 -3
- data/images/1029.png +0 -3
- data/images/103.png +0 -3
- data/images/104.png +0 -3
- data/images/105.png +0 -3
- data/images/106.png +0 -3
- data/images/107.png +0 -3
- data/images/108.png +0 -3
- data/images/109.png +0 -3
- data/images/11.png +0 -3
- data/images/110.png +0 -3
- data/images/111.png +0 -3
.gitignore
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
|
2 |
-
.git/
|
3 |
-
.idea/
|
4 |
-
|
5 |
-
hub_datasets/
|
6 |
-
|
7 |
-
**/__pycache__/
|
8 |
-
|
9 |
-
222dataset_infos.json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -1,11 +1,55 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
3 |
task_categories:
|
4 |
- object-detection
|
5 |
tags:
|
6 |
- object detection
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
---
|
10 |
## cppe-5
|
11 |
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
size_categories:
|
4 |
+
- 100M<n<1B
|
5 |
task_categories:
|
6 |
- object-detection
|
7 |
tags:
|
8 |
- object detection
|
9 |
+
dataset_info:
|
10 |
+
features:
|
11 |
+
- name: image_id
|
12 |
+
dtype: int64
|
13 |
+
- name: image
|
14 |
+
dtype: image
|
15 |
+
- name: width
|
16 |
+
dtype: int32
|
17 |
+
- name: height
|
18 |
+
dtype: int32
|
19 |
+
- name: objects
|
20 |
+
sequence:
|
21 |
+
- name: id
|
22 |
+
dtype: int64
|
23 |
+
- name: area
|
24 |
+
dtype: int64
|
25 |
+
- name: bbox
|
26 |
+
sequence: float32
|
27 |
+
length: 4
|
28 |
+
- name: category
|
29 |
+
dtype:
|
30 |
+
class_label:
|
31 |
+
names:
|
32 |
+
'0': Coverall
|
33 |
+
'1': Face_Shield
|
34 |
+
'2': Gloves
|
35 |
+
'3': Goggles
|
36 |
+
'4': Mask
|
37 |
+
splits:
|
38 |
+
- name: train
|
39 |
+
num_bytes: 240463364.0
|
40 |
+
num_examples: 1000
|
41 |
+
- name: test
|
42 |
+
num_bytes: 4172164.0
|
43 |
+
num_examples: 29
|
44 |
+
download_size: 241152991
|
45 |
+
dataset_size: 244635528.0
|
46 |
+
configs:
|
47 |
+
- config_name: default
|
48 |
+
data_files:
|
49 |
+
- split: train
|
50 |
+
path: data/train-*
|
51 |
+
- split: test
|
52 |
+
path: data/test-*
|
53 |
---
|
54 |
## cppe-5
|
55 |
|
cppe-5.py
DELETED
@@ -1,135 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
-
#
|
4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
# you may not use this file except in compliance with the License.
|
6 |
-
# You may obtain a copy of the License at
|
7 |
-
#
|
8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
#
|
10 |
-
# Unless required by applicable law or agreed to in writing, software
|
11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
# See the License for the specific language governing permissions and
|
14 |
-
# limitations under the License.
|
15 |
-
"""CPPE-5 dataset."""
|
16 |
-
|
17 |
-
|
18 |
-
import collections
|
19 |
-
import json
|
20 |
-
import os
|
21 |
-
|
22 |
-
import datasets
|
23 |
-
|
24 |
-
|
25 |
-
_CITATION = """\
|
26 |
-
@misc{dagli2021cppe5,
|
27 |
-
title={CPPE-5: Medical Personal Protective Equipment Dataset},
|
28 |
-
author={Rishit Dagli and Ali Mustufa Shaikh},
|
29 |
-
year={2021},
|
30 |
-
eprint={2112.09569},
|
31 |
-
archivePrefix={arXiv},
|
32 |
-
primaryClass={cs.CV}
|
33 |
-
}
|
34 |
-
"""
|
35 |
-
|
36 |
-
_DESCRIPTION = """\
|
37 |
-
CPPE - 5 (Medical Personal Protective Equipment) is a new challenging dataset with the goal
|
38 |
-
to allow the study of subordinate categorization of medical personal protective equipments,
|
39 |
-
which is not possible with other popular data sets that focus on broad level categories.
|
40 |
-
"""
|
41 |
-
|
42 |
-
_HOMEPAGE = "https://sites.google.com/view/cppe5"
|
43 |
-
|
44 |
-
_LICENSE = "Unknown"
|
45 |
-
|
46 |
-
# _URL = "https://drive.google.com/uc?id=1MGnaAfbckUmigGUvihz7uiHGC6rBIbvr"
|
47 |
-
_URL = "data/dataset.tar.gz"
|
48 |
-
|
49 |
-
_CATEGORIES = ["Coverall", "Face_Shield", "Gloves", "Goggles", "Mask"]
|
50 |
-
|
51 |
-
|
52 |
-
class CPPE5(datasets.GeneratorBasedBuilder):
|
53 |
-
"""CPPE - 5 dataset."""
|
54 |
-
|
55 |
-
VERSION = datasets.Version("1.0.0")
|
56 |
-
|
57 |
-
def _info(self):
|
58 |
-
features = datasets.Features(
|
59 |
-
{
|
60 |
-
"image_id": datasets.Value("int64"),
|
61 |
-
"image": datasets.Image(),
|
62 |
-
"width": datasets.Value("int32"),
|
63 |
-
"height": datasets.Value("int32"),
|
64 |
-
"objects": datasets.Sequence(
|
65 |
-
{
|
66 |
-
"id": datasets.Value("int64"),
|
67 |
-
"area": datasets.Value("int64"),
|
68 |
-
"bbox": datasets.Sequence(datasets.Value("float32"), length=4),
|
69 |
-
"category": datasets.ClassLabel(names=_CATEGORIES),
|
70 |
-
}
|
71 |
-
),
|
72 |
-
}
|
73 |
-
)
|
74 |
-
return datasets.DatasetInfo(
|
75 |
-
description=_DESCRIPTION,
|
76 |
-
features=features,
|
77 |
-
homepage=_HOMEPAGE,
|
78 |
-
license=_LICENSE,
|
79 |
-
citation=_CITATION,
|
80 |
-
)
|
81 |
-
|
82 |
-
def _split_generators(self, dl_manager):
|
83 |
-
archive = dl_manager.download(_URL)
|
84 |
-
return [
|
85 |
-
datasets.SplitGenerator(
|
86 |
-
name=datasets.Split.TRAIN,
|
87 |
-
gen_kwargs={
|
88 |
-
"annotation_file_path": "annotations/train.json",
|
89 |
-
"files": dl_manager.iter_archive(archive),
|
90 |
-
},
|
91 |
-
),
|
92 |
-
datasets.SplitGenerator(
|
93 |
-
name=datasets.Split.TEST,
|
94 |
-
gen_kwargs={
|
95 |
-
"annotation_file_path": "annotations/test.json",
|
96 |
-
"files": dl_manager.iter_archive(archive),
|
97 |
-
},
|
98 |
-
),
|
99 |
-
]
|
100 |
-
|
101 |
-
def _generate_examples(self, annotation_file_path, files):
|
102 |
-
def process_annot(annot, category_id_to_category):
|
103 |
-
return {
|
104 |
-
"id": annot["id"],
|
105 |
-
"area": annot["area"],
|
106 |
-
"bbox": annot["bbox"],
|
107 |
-
"category": category_id_to_category[annot["category_id"]],
|
108 |
-
}
|
109 |
-
|
110 |
-
image_id_to_image = {}
|
111 |
-
idx = 0
|
112 |
-
# This loop relies on the ordering of the files in the archive:
|
113 |
-
# Annotation files come first, then the images.
|
114 |
-
for path, f in files:
|
115 |
-
file_name = os.path.basename(path)
|
116 |
-
if path == annotation_file_path:
|
117 |
-
annotations = json.load(f)
|
118 |
-
category_id_to_category = {category["id"]: category["name"] for category in annotations["categories"]}
|
119 |
-
image_id_to_annotations = collections.defaultdict(list)
|
120 |
-
for annot in annotations["annotations"]:
|
121 |
-
image_id_to_annotations[annot["image_id"]].append(annot)
|
122 |
-
image_id_to_image = {annot["file_name"]: annot for annot in annotations["images"]}
|
123 |
-
elif file_name in image_id_to_image:
|
124 |
-
image = image_id_to_image[file_name]
|
125 |
-
objects = [
|
126 |
-
process_annot(annot, category_id_to_category) for annot in image_id_to_annotations[image["id"]]
|
127 |
-
]
|
128 |
-
yield idx, {
|
129 |
-
"image_id": image["id"],
|
130 |
-
"image": {"path": path, "bytes": f.read()},
|
131 |
-
"width": image["width"],
|
132 |
-
"height": image["height"],
|
133 |
-
"objects": objects,
|
134 |
-
}
|
135 |
-
idx += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cppe_5_backup.py
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
#!/usr/bin/python3
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
from glob import glob
|
4 |
-
import json
|
5 |
-
import os
|
6 |
-
from pathlib import Path
|
7 |
-
|
8 |
-
import datasets
|
9 |
-
from PIL import Image
|
10 |
-
|
11 |
-
# _URL = "https://drive.google.com/uc?id=1MGnaAfbckUmigGUvihz7uiHGC6rBIbvr"
|
12 |
-
|
13 |
-
_HOMEPAGE = "https://sites.google.com/view/cppe5"
|
14 |
-
|
15 |
-
_LICENSE = "Unknown"
|
16 |
-
|
17 |
-
_CATEGORIES = ["Coverall", "Face_Shield", "Gloves", "Goggles", "Mask"]
|
18 |
-
|
19 |
-
_CITATION = """\
|
20 |
-
@misc{dagli2021cppe5,
|
21 |
-
title={CPPE-5: Medical Personal Protective Equipment Dataset},
|
22 |
-
author={Rishit Dagli and Ali Mustufa Shaikh},
|
23 |
-
year={2021},
|
24 |
-
eprint={2112.09569},
|
25 |
-
archivePrefix={arXiv},
|
26 |
-
primaryClass={cs.CV}
|
27 |
-
}
|
28 |
-
"""
|
29 |
-
|
30 |
-
_DESCRIPTION = """\
|
31 |
-
CPPE - 5 (Medical Personal Protective Equipment) is a new challenging dataset with the goal
|
32 |
-
to allow the study of subordinate categorization of medical personal protective equipments,
|
33 |
-
which is not possible with other popular data sets that focus on broad level categories.
|
34 |
-
"""
|
35 |
-
|
36 |
-
|
37 |
-
class CPPE5(datasets.GeneratorBasedBuilder):
|
38 |
-
"""CPPE - 5 dataset."""
|
39 |
-
|
40 |
-
VERSION = datasets.Version("1.0.0")
|
41 |
-
|
42 |
-
def _info(self):
|
43 |
-
features = datasets.Features(
|
44 |
-
{
|
45 |
-
"image_id": datasets.Value("int64"),
|
46 |
-
"image": datasets.Image(),
|
47 |
-
"width": datasets.Value("int32"),
|
48 |
-
"height": datasets.Value("int32"),
|
49 |
-
"objects": datasets.Sequence(
|
50 |
-
feature=datasets.Features({
|
51 |
-
"id": datasets.Value("int64"),
|
52 |
-
"area": datasets.Value("int64"),
|
53 |
-
"bbox": datasets.Sequence(datasets.Value("float32"), length=4),
|
54 |
-
"category": datasets.ClassLabel(names=_CATEGORIES),
|
55 |
-
})
|
56 |
-
),
|
57 |
-
}
|
58 |
-
)
|
59 |
-
return datasets.DatasetInfo(
|
60 |
-
description=_DESCRIPTION,
|
61 |
-
features=features,
|
62 |
-
homepage=_HOMEPAGE,
|
63 |
-
license=_LICENSE,
|
64 |
-
citation=_CITATION,
|
65 |
-
)
|
66 |
-
|
67 |
-
def _split_generators(self, dl_manager):
|
68 |
-
"""Returns SplitGenerators."""
|
69 |
-
train_json = dl_manager.download("data/annotations/train.jsonl")
|
70 |
-
test_json = dl_manager.download("data/annotations/test.jsonl")
|
71 |
-
|
72 |
-
return [
|
73 |
-
datasets.SplitGenerator(
|
74 |
-
name=datasets.Split.TRAIN,
|
75 |
-
gen_kwargs={
|
76 |
-
"archive_path": train_json,
|
77 |
-
"dl_manager": dl_manager,
|
78 |
-
},
|
79 |
-
),
|
80 |
-
datasets.SplitGenerator(
|
81 |
-
name=datasets.Split.TEST,
|
82 |
-
gen_kwargs={
|
83 |
-
"archive_path": test_json,
|
84 |
-
"dl_manager": dl_manager,
|
85 |
-
},
|
86 |
-
),
|
87 |
-
]
|
88 |
-
|
89 |
-
def _generate_examples(self, archive_path, dl_manager):
|
90 |
-
"""Yields examples."""
|
91 |
-
archive_path = Path(archive_path)
|
92 |
-
|
93 |
-
idx = 0
|
94 |
-
|
95 |
-
with open(archive_path, "r", encoding="utf-8") as f:
|
96 |
-
for row in f:
|
97 |
-
sample = json.loads(row)
|
98 |
-
|
99 |
-
file_path = sample["image"]
|
100 |
-
file_path = dl_manager.download(file_path)
|
101 |
-
|
102 |
-
with open(file_path, "rb") as image_f:
|
103 |
-
image_bytes = image_f.read()
|
104 |
-
# image = Image.open(image_f)
|
105 |
-
|
106 |
-
yield idx, {
|
107 |
-
"image_id": sample["image_id"],
|
108 |
-
"image": {"path": file_path, "bytes": image_bytes},
|
109 |
-
# "image": image,
|
110 |
-
"width": sample["width"],
|
111 |
-
"height": sample["height"],
|
112 |
-
"objects": sample["objects"],
|
113 |
-
}
|
114 |
-
idx += 1
|
115 |
-
|
116 |
-
|
117 |
-
if __name__ == '__main__':
|
118 |
-
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/annotations/test.jsonl
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:2dd85c9919bcd33ab761b7ff40024a8bdc81dc936cb30007de267d712c6fd448
|
3 |
-
size 18910
|
|
|
|
|
|
|
|
data/images/1.png
DELETED
Git LFS Details
|
data/images/10.png
DELETED
Git LFS Details
|
data/images/100.png
DELETED
Git LFS Details
|
data/images/1000.png
DELETED
Git LFS Details
|
data/images/1001.png
DELETED
Git LFS Details
|
data/images/1002.png
DELETED
Git LFS Details
|
data/images/1003.png
DELETED
Git LFS Details
|
data/images/1004.png
DELETED
Git LFS Details
|
data/images/1005.png
DELETED
Git LFS Details
|
data/images/1006.png
DELETED
Git LFS Details
|
data/images/1007.png
DELETED
Git LFS Details
|
data/images/1008.png
DELETED
Git LFS Details
|
data/images/1009.png
DELETED
Git LFS Details
|
data/images/101.png
DELETED
Git LFS Details
|
data/images/1010.png
DELETED
Git LFS Details
|
data/images/1011.png
DELETED
Git LFS Details
|
data/images/1012.png
DELETED
Git LFS Details
|
data/images/1013.png
DELETED
Git LFS Details
|
data/images/1014.png
DELETED
Git LFS Details
|
data/images/1015.png
DELETED
Git LFS Details
|
data/images/1016.png
DELETED
Git LFS Details
|
data/images/1017.png
DELETED
Git LFS Details
|
data/images/1018.png
DELETED
Git LFS Details
|
data/images/1019.png
DELETED
Git LFS Details
|
data/images/102.png
DELETED
Git LFS Details
|
data/images/1020.png
DELETED
Git LFS Details
|
data/images/1021.png
DELETED
Git LFS Details
|
data/images/1022.png
DELETED
Git LFS Details
|
data/images/1023.png
DELETED
Git LFS Details
|
data/images/1024.png
DELETED
Git LFS Details
|
data/images/1025.png
DELETED
Git LFS Details
|
data/images/1026.png
DELETED
Git LFS Details
|
data/images/1027.png
DELETED
Git LFS Details
|
data/images/1028.png
DELETED
Git LFS Details
|
data/images/1029.png
DELETED
Git LFS Details
|
data/images/103.png
DELETED
Git LFS Details
|
data/images/104.png
DELETED
Git LFS Details
|
data/images/105.png
DELETED
Git LFS Details
|
data/images/106.png
DELETED
Git LFS Details
|
data/images/107.png
DELETED
Git LFS Details
|
data/images/108.png
DELETED
Git LFS Details
|
data/images/109.png
DELETED
Git LFS Details
|
data/images/11.png
DELETED
Git LFS Details
|
data/images/110.png
DELETED
Git LFS Details
|
data/images/111.png
DELETED
Git LFS Details
|