wintercoming6 commited on
Commit
090a68a
1 Parent(s): f978564

Update artwork_for_sdxl.py

Browse files
Files changed (1) hide show
  1. artwork_for_sdxl.py +88 -0
artwork_for_sdxl.py CHANGED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 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
+ """ImageNet-Sketch data set for evaluating model's ability in learning (out-of-domain) semantics at ImageNet scale"""
16
+
17
+ import os
18
+
19
+ import pandas as pd
20
+ import datasets
21
+ from datasets.tasks import ImageClassification
22
+
23
+ # from .classes import IMAGENET2012_CLASSES
24
+
25
+
26
+ _HOMEPAGE = "https://huggingface.co/datasets/AIPI540/test2/tree/main"
27
+
28
+ _CITATION = """\
29
+ @inproceedings{wang2019learning,
30
+ title={Learning Robust Global Representations by Penalizing Local Predictive Power},
31
+ author={Wang, Haohan and Ge, Songwei and Lipton, Zachary and Xing, Eric P},
32
+ booktitle={Advances in Neural Information Processing Systems},
33
+ pages={10506--10518},
34
+ year={2019}
35
+ }
36
+ """
37
+
38
+ _DESCRIPTION = """\
39
+ Artwork Images, to predict the year of the artwork created.
40
+ """
41
+
42
+ _URL = "https://huggingface.co/datasets/AIPI540/Art2/resolve/main/final_art_data.parquet"
43
+
44
+ class Artwork(datasets.GeneratorBasedBuilder):
45
+ """Artwork Images - a dataset of centuries of Images classes"""
46
+
47
+ def _info(self):
48
+ return datasets.DatasetInfo(
49
+ description=_DESCRIPTION,
50
+ features=datasets.Features(
51
+ {
52
+ "label": datasets.features.ClassLabel(names=classes),
53
+ "image_data": datasets.Value("binary"),
54
+ }
55
+ ),
56
+ supervised_keys=("label","image_data"),
57
+ homepage=_HOMEPAGE,
58
+ citation=_CITATION,
59
+ task_templates=[ImageClassification(image_column="image_data", label_column="label")],
60
+ )
61
+
62
+ def _split_generators(self, dl_manager):
63
+ data_files = dl_manager.download_and_extract(_URL)
64
+ df = pd.read_parquet(data_files, engine='pyarrow')
65
+
66
+ return [
67
+ datasets.SplitGenerator(
68
+ name=datasets.Split.TRAIN,
69
+ gen_kwargs={
70
+ "files": df,
71
+ },
72
+ ),
73
+ ]
74
+
75
+ def _generate_examples(self, files):
76
+ cnt=0
77
+ for path in files.itertuples():
78
+ print(cnt)
79
+ cnt+=1
80
+ print(path)
81
+ print(path.label)
82
+ print(type(path.label))
83
+ print(path.image_data)
84
+ print(type(path.image_data))
85
+ yield {
86
+ "label": classes[(path.label)],
87
+ "image_data": path.image_data,
88
+ }