|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""ImageNet-Sketch data set for evaluating model's ability in learning (out-of-domain) semantics at ImageNet scale""" |
|
|
|
import os |
|
|
|
import pandas as pd |
|
import datasets |
|
from datasets.tasks import ImageClassification |
|
|
|
|
|
|
|
|
|
_HOMEPAGE = "https://huggingface.co./datasets/AIPI540/test2/tree/main" |
|
|
|
_CITATION = """\ |
|
@inproceedings{wang2019learning, |
|
title={Learning Robust Global Representations by Penalizing Local Predictive Power}, |
|
author={Wang, Haohan and Ge, Songwei and Lipton, Zachary and Xing, Eric P}, |
|
booktitle={Advances in Neural Information Processing Systems}, |
|
pages={10506--10518}, |
|
year={2019} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Artwork Images, to predict the year of the artwork created. |
|
""" |
|
|
|
_URL = "https://huggingface.co./datasets/wintercoming6/artwork_for_sdxl/resolve/main/metadata.jsonl" |
|
|
|
class Artwork(datasets.GeneratorBasedBuilder): |
|
"""Artwork Images - a dataset of centuries of Images classes""" |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"prompt": str, |
|
"image_data": Image, |
|
} |
|
), |
|
supervised_keys=("label","image_data"), |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
task_templates=[ImageClassification(image_column="image_data", label_column="prompt")], |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
data_files = dl_manager.download_and_extract(_URL) |
|
df = pd.read_json(data_files, lines=True) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"files": df, |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, files): |
|
cnt=0 |
|
for path in files.itertuples(): |
|
print(cnt) |
|
cnt+=1 |
|
print(path) |
|
print(path.prompt) |
|
print(type(path.prompt)) |
|
print(path.image_data) |
|
print(type(path.image_data)) |
|
yield { |
|
"prompt": path.prompt, |
|
"image_data": Image.open(path.image_data), |
|
} |