Delete loading script auxiliary file
Browse files- cppe_5_backup.py +0 -118
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|