Datasets:
Stavros Niafas
commited on
Commit
·
a3e2a44
1
Parent(s):
4a47bc9
add data builder
Browse files
README.md
CHANGED
|
@@ -22,8 +22,24 @@ dataset_info:
|
|
| 22 |
dtype:
|
| 23 |
class_label:
|
| 24 |
names:
|
| 25 |
-
0:
|
| 26 |
-
1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
---
|
| 28 |
## Dataset Summary
|
| 29 |
|
|
@@ -44,4 +60,4 @@ Depth-of-Field(DoF) dataset is comprised of 1200 annotated images, binary annota
|
|
| 44 |
year={2021}
|
| 45 |
}
|
| 46 |
Note that each DoF dataset has its own citation. Please see the source to
|
| 47 |
-
get the correct citation for each contained dataset.
|
|
|
|
| 22 |
dtype:
|
| 23 |
class_label:
|
| 24 |
names:
|
| 25 |
+
0: bokeh
|
| 26 |
+
1: no-bokeh
|
| 27 |
+
- config_name: default
|
| 28 |
+
features:
|
| 29 |
+
- name: image
|
| 30 |
+
dtype: image
|
| 31 |
+
- name: label
|
| 32 |
+
dtype:
|
| 33 |
+
class_label:
|
| 34 |
+
names:
|
| 35 |
+
0: '0'
|
| 36 |
+
1: '1'
|
| 37 |
+
splits:
|
| 38 |
+
- name: train
|
| 39 |
+
num_bytes: 38833123
|
| 40 |
+
num_examples: 1200
|
| 41 |
+
download_size: 39731200
|
| 42 |
+
dataset_size: 38833123
|
| 43 |
---
|
| 44 |
## Dataset Summary
|
| 45 |
|
|
|
|
| 60 |
year={2021}
|
| 61 |
}
|
| 62 |
Note that each DoF dataset has its own citation. Please see the source to
|
| 63 |
+
get the correct citation for each contained dataset.
|
dof.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"""The depth-of-field dataset"""
|
| 16 |
+
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
from datasets.tasks import ImageClassification
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
logger = datasets.logging.get_logger(__name__)
|
| 24 |
+
|
| 25 |
+
_URL = (
|
| 26 |
+
"https://drive.google.com/uc?export=download&id=1baxZd7X_pSZ7e9_15s5weFY5AH_sPSNi"
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
_HOMEPAGE = "https://github.com/sniafas/photography-style-analysis"
|
| 30 |
+
|
| 31 |
+
_DESCRIPTION = "A set of annotated images in shallow and deep depth of field"
|
| 32 |
+
|
| 33 |
+
_CITATION = """\
|
| 34 |
+
@article{sniafas2021,
|
| 35 |
+
title={DoF: An image dataset for depth of field classification},
|
| 36 |
+
author={Niafas, Stavros},
|
| 37 |
+
doi= {10.13140/RG.2.2.29880.62722},
|
| 38 |
+
url= {https://www.researchgate.net/publication/364356051_DoF_depth_of_field_datase}
|
| 39 |
+
year={2021}
|
| 40 |
+
}
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class DoF(datasets.GeneratorBasedBuilder):
|
| 45 |
+
VERSION = datasets.Version("1.0.0")
|
| 46 |
+
|
| 47 |
+
def _info(self):
|
| 48 |
+
return datasets.DatasetInfo(
|
| 49 |
+
description=_DESCRIPTION,
|
| 50 |
+
features=datasets.Features(
|
| 51 |
+
{
|
| 52 |
+
"image": datasets.Image(),
|
| 53 |
+
"label": datasets.features.ClassLabel(names=["0", "1"]),
|
| 54 |
+
}
|
| 55 |
+
),
|
| 56 |
+
supervised_keys=("image", "label"),
|
| 57 |
+
task_templates=[
|
| 58 |
+
ImageClassification(image_column="image", label_column="label")
|
| 59 |
+
],
|
| 60 |
+
homepage=_HOMEPAGE,
|
| 61 |
+
citation=_CITATION,
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
def _split_generators(self, dl_manager):
|
| 65 |
+
archive_path = dl_manager.download(_URL)
|
| 66 |
+
return [
|
| 67 |
+
datasets.SplitGenerator(
|
| 68 |
+
name=datasets.Split.TRAIN,
|
| 69 |
+
gen_kwargs={
|
| 70 |
+
"images": dl_manager.iter_archive(archive_path),
|
| 71 |
+
},
|
| 72 |
+
)
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
def _generate_examples(self, images):
|
| 76 |
+
"""Generate images and labels for splits."""
|
| 77 |
+
for file_path, file_obj in images:
|
| 78 |
+
print(file_path)
|
| 79 |
+
label = file_path.split("/")[0]
|
| 80 |
+
yield file_path, {
|
| 81 |
+
"image": {"path": file_path, "bytes": file_obj.read()},
|
| 82 |
+
"label": label,
|
| 83 |
+
}
|