Upload images-targz.py
Browse files- images-targz.py +80 -0
images-targz.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Residential Floorplans and City Scapes dataset for Urban planning"""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import datasets
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
logger = datasets.logging.get_logger(__name__)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
_CITATION = """\
|
| 12 |
+
@article{2016arXiv160605250R,
|
| 13 |
+
author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
|
| 14 |
+
Konstantin and {Liang}, Percy},
|
| 15 |
+
title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
|
| 16 |
+
journal = {arXiv e-prints},
|
| 17 |
+
year = 2016,
|
| 18 |
+
eid = {arXiv:1606.05250},
|
| 19 |
+
pages = {arXiv:1606.05250},
|
| 20 |
+
archivePrefix = {arXiv},
|
| 21 |
+
eprint = {1606.05250},
|
| 22 |
+
}
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
_DESCRIPTION = """\
|
| 26 |
+
Text-to-image model to build an AI architect
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
_URL = "https://huggingface.co/datasets/wheres-my-python/image-trial/resolve/main/images.tar.gz"
|
| 30 |
+
|
| 31 |
+
# descriptions = [] #optional text data
|
| 32 |
+
|
| 33 |
+
class ImagesTrial(datasets.GeneratorBasedBuilder):
|
| 34 |
+
"""SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
|
| 35 |
+
|
| 36 |
+
def _info(self):
|
| 37 |
+
return datasets.DatasetInfo(
|
| 38 |
+
description=_DESCRIPTION,
|
| 39 |
+
features=datasets.Features(
|
| 40 |
+
# Option to use any Apache arrow feature other than "string"
|
| 41 |
+
{
|
| 42 |
+
"text": datasets.Value("string"),
|
| 43 |
+
"image": datasets.Image(),
|
| 44 |
+
# "prompt": datasets.Value("string"), (optional)
|
| 45 |
+
}
|
| 46 |
+
),
|
| 47 |
+
# No default supervised_keys (as we have to pass both question
|
| 48 |
+
# and context as input).
|
| 49 |
+
supervised_keys=None,
|
| 50 |
+
homepage="https://huggingface.co/datasets/wheres-my-python/floorplans-cityscapes",
|
| 51 |
+
citation=_CITATION,
|
| 52 |
+
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
def _split_generators(self, dl_manager):
|
| 56 |
+
#download manager - hf utility
|
| 57 |
+
path = dl_manager.download_and_extract(_URL)
|
| 58 |
+
image_iters = dl_manager.iter_archive(path)
|
| 59 |
+
|
| 60 |
+
return [
|
| 61 |
+
datasets.SplitGenerator(
|
| 62 |
+
name=datasets.Split.TRAIN
|
| 63 |
+
, gen_kwargs={
|
| 64 |
+
"images": image_iters
|
| 65 |
+
}
|
| 66 |
+
),
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
def _generate_examples(self, images):
|
| 70 |
+
"""This function returns the examples in the raw (text) form."""
|
| 71 |
+
idx = 0
|
| 72 |
+
#iteratre through images
|
| 73 |
+
for filepath, image in images:
|
| 74 |
+
yield idx, {
|
| 75 |
+
"image": {"filepath":filepath, "image":image.read()},
|
| 76 |
+
#Option to map text
|
| 77 |
+
|
| 78 |
+
# "text": descriptions[idx],
|
| 79 |
+
}
|
| 80 |
+
idx +=1
|