Datasets:
Languages:
English
Size:
10K<n<100K
File size: 1,921 Bytes
d583a77 8d72b47 d583a77 8d72b47 d583a77 8d72b47 d583a77 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import datasets
_CITATION = """\
@InProceedings{huggingface:dataset,
title = {Unsplash 25K Photos},
author={James Briggs},
year={2022}
}
"""
_DESCRIPTION = """\
This is a dataset that streams photos data from the Unsplash 25K servers.
"""
_HOMEPAGE = "https://github.com/unsplash/datasets/"
_LICENSE = ""
_URL = "https://unsplash.com/data/lite/latest"
class Unsplash(datasets.GeneratorBasedBuilder):
"""The Unsplash 25K dataset for photos"""
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"imdb_id": datasets.Value("string"),
"movie_id": datasets.Value("int32"),
"user_id": datasets.Value("int32"),
"rating": datasets.Value("float32"),
"title": datasets.Value("string"),
"year": datasets.Value("int32"),
}
),
supervised_keys=None,
homepage="https://grouplens.org/datasets/movielens/",
citation=_CITATION,
)
def _split_generators(self, dl_manager):
new_url = dl_manager.download_and_extract(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"filepath": new_url+"/photos.tsv000"}
),
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
with open(filepath, "r") as f:
id_ = 0
for line in f:
if id_ == 0:
cols = line.split("\t")
id_ += 1
else:
values = line.split("\t")
print(id_, {cols[i]: values[i] for i in range(len(cols))})
id_ += 1
if id_ > 5: break |