loading script, readme, gitignore
Browse files- .gitignore +2 -0
- README.md +26 -0
- interior-cgi.py +134 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
setup.cfg
|
2 |
+
bin/
|
README.md
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
dataset_info:
|
3 |
+
features:
|
4 |
+
- name: image
|
5 |
+
dtype: image
|
6 |
+
- name: label_id
|
7 |
+
dtype:
|
8 |
+
class_label:
|
9 |
+
names:
|
10 |
+
'0': bathroom
|
11 |
+
'1': bedroom
|
12 |
+
'2': dining_room
|
13 |
+
'3': kitchen
|
14 |
+
'4': living_room
|
15 |
+
- name: label_name
|
16 |
+
dtype: string
|
17 |
+
splits:
|
18 |
+
- name: train
|
19 |
+
num_bytes: 810900
|
20 |
+
num_examples: 4000
|
21 |
+
- name: test
|
22 |
+
num_bytes: 201725
|
23 |
+
num_examples: 1000
|
24 |
+
download_size: 1888811124
|
25 |
+
dataset_size: 1012625
|
26 |
+
---
|
interior-cgi.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
|
15 |
+
"""This dataset contains interior images created using DALL-E.
|
16 |
+
The dataset contains 512x512 images split into 5 classes:
|
17 |
+
* bathroom: 1000 images
|
18 |
+
* bedroom: 1000 images
|
19 |
+
* dining_room: 1000 images
|
20 |
+
* kitchen: 1000 images
|
21 |
+
* living_room: 1000 images
|
22 |
+
"""
|
23 |
+
|
24 |
+
import datasets
|
25 |
+
from datasets.download.download_manager import DownloadManager
|
26 |
+
from datasets.tasks import ImageClassification
|
27 |
+
from pathlib import Path
|
28 |
+
from typing import List, Iterator
|
29 |
+
|
30 |
+
_ALLOWED_IMG_EXT = {".png", ".jpg"}
|
31 |
+
|
32 |
+
_CITATION = """\
|
33 |
+
@InProceedings{huggingface:dataset,
|
34 |
+
title = {Computer Generated interior images},
|
35 |
+
author={Padilla, Rafael},
|
36 |
+
year={2023}
|
37 |
+
}
|
38 |
+
"""
|
39 |
+
|
40 |
+
_DESCRIPTION = """\
|
41 |
+
This new dataset contains CG interior images representing interior of houses in 5 classes, with \
|
42 |
+
1000 images per class.
|
43 |
+
"""
|
44 |
+
|
45 |
+
_HOMEPAGE = "https://huggingface.co/datasets/rafaelpadilla/interior-cgi/"
|
46 |
+
|
47 |
+
_LICENSE = ""
|
48 |
+
|
49 |
+
_URLS = {
|
50 |
+
"test": "https://huggingface.co/datasets/rafaelpadilla/interior-cgi/resolve/main/data/test.zip",
|
51 |
+
"train": "https://huggingface.co/datasets/rafaelpadilla/interior-cgi/resolve/main/data/train.zip",
|
52 |
+
}
|
53 |
+
|
54 |
+
_NAMES = ["bathroom", "bedroom", "dining_room", "kitchen", "living_room"]
|
55 |
+
|
56 |
+
|
57 |
+
class CGInteriorDataset(datasets.GeneratorBasedBuilder):
|
58 |
+
"""CGInterior: Computer Generated Interior images dataset"""
|
59 |
+
|
60 |
+
VERSION = datasets.Version("1.1.0")
|
61 |
+
|
62 |
+
def _info(self) -> datasets.DatasetInfo:
|
63 |
+
"""
|
64 |
+
Returns the dataset metadata and features.
|
65 |
+
|
66 |
+
Returns:
|
67 |
+
DatasetInfo: Metadata and features of the dataset.
|
68 |
+
"""
|
69 |
+
|
70 |
+
return datasets.DatasetInfo(
|
71 |
+
description=_DESCRIPTION,
|
72 |
+
features=datasets.Features(
|
73 |
+
{
|
74 |
+
"image": datasets.Image(),
|
75 |
+
"label_id": datasets.features.ClassLabel(names=_NAMES),
|
76 |
+
"label_name": datasets.Value("string"),
|
77 |
+
}
|
78 |
+
),
|
79 |
+
supervised_keys=("image", "label_id"),
|
80 |
+
homepage=_HOMEPAGE,
|
81 |
+
license=_LICENSE,
|
82 |
+
citation=_CITATION,
|
83 |
+
task_templates=[
|
84 |
+
ImageClassification(image_column="image", label_column="label_id")
|
85 |
+
],
|
86 |
+
)
|
87 |
+
|
88 |
+
def _split_generators(
|
89 |
+
self, dl_manager: DownloadManager
|
90 |
+
) -> List[datasets.SplitGenerator]:
|
91 |
+
"""
|
92 |
+
Provides the split information and downloads the data.
|
93 |
+
|
94 |
+
Args:
|
95 |
+
dl_manager (DownloadManager): The DownloadManager to use for downloading and extracting data.
|
96 |
+
|
97 |
+
Returns:
|
98 |
+
List[SplitGenerator]: List of SplitGenerator objects representing the data splits.
|
99 |
+
"""
|
100 |
+
data_files = dl_manager.download_and_extract(_URLS)
|
101 |
+
return [
|
102 |
+
datasets.SplitGenerator(
|
103 |
+
name=datasets.Split.TRAIN,
|
104 |
+
gen_kwargs={
|
105 |
+
"files": dl_manager.iter_files(data_files["train"]),
|
106 |
+
},
|
107 |
+
),
|
108 |
+
datasets.SplitGenerator(
|
109 |
+
name=datasets.Split.TEST,
|
110 |
+
gen_kwargs={
|
111 |
+
"files": dl_manager.iter_files(data_files["test"]),
|
112 |
+
},
|
113 |
+
),
|
114 |
+
]
|
115 |
+
|
116 |
+
def _generate_examples(self, files: List[str]) -> Iterator:
|
117 |
+
"""
|
118 |
+
Generates examples for the dataset.
|
119 |
+
|
120 |
+
Args:
|
121 |
+
files (List[str]): List of image paths.
|
122 |
+
|
123 |
+
Yields:
|
124 |
+
Dict[str, Union[str, Image]]: A dictionary containing the generated examples.
|
125 |
+
"""
|
126 |
+
|
127 |
+
for idx, img_path in enumerate(files):
|
128 |
+
path = Path(img_path)
|
129 |
+
if path.suffix in _ALLOWED_IMG_EXT:
|
130 |
+
yield idx, {
|
131 |
+
"image": img_path,
|
132 |
+
"label_id": path.parent.name,
|
133 |
+
"label_name": path.parent.name,
|
134 |
+
}
|