wintercoming6 commited on
Commit
a6ae5cb
·
verified ·
1 Parent(s): 09d0125

Create test.py

Browse files
Files changed (1) hide show
  1. test.py +81 -0
test.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 datasets
20
+ from datasets.tasks import ImageClassification
21
+
22
+ from .classes import IMAGENET2012_CLASSES
23
+
24
+
25
+ _HOMEPAGE = "https://huggingface.co/datasets/AIPI540/test2/tree/main"
26
+
27
+ _CITATION = """\
28
+ @inproceedings{wang2019learning,
29
+ title={Learning Robust Global Representations by Penalizing Local Predictive Power},
30
+ author={Wang, Haohan and Ge, Songwei and Lipton, Zachary and Xing, Eric P},
31
+ booktitle={Advances in Neural Information Processing Systems},
32
+ pages={10506--10518},
33
+ year={2019}
34
+ }
35
+ """
36
+
37
+ _DESCRIPTION = """\
38
+ Artwork Images, to predict the year of the artwork created.
39
+ """
40
+
41
+ _URL = "https://huggingface.co/datasets/AIPI540/Art2/resolve/main/final_art_data.parquet"
42
+
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
+ "file_name": str,
53
+ "label": datasets.features.ClassLabel(names=[0,1,2,3,4,5,6]),
54
+ "image_data": bytes
55
+ }
56
+ ),
57
+ supervised_keys=("filename", "label","image_data"),
58
+ homepage=_HOMEPAGE,
59
+ citation=_CITATION,
60
+ task_templates=[ImageClassification(image_column="image_data", label_column="label")],
61
+ )
62
+
63
+ def _split_generators(self, dl_manager):
64
+ data_files = dl_manager.download_and_extract(_URL)
65
+
66
+ return [
67
+ datasets.SplitGenerator(
68
+ name=datasets.Split.TRAIN,
69
+ gen_kwargs={
70
+ "files": dl_manager.iter_files([data_files]),
71
+ },
72
+ ),
73
+ ]
74
+
75
+ def _generate_examples(self, files):
76
+ for i, path in enumerate(files):
77
+ yield i, {
78
+ "filename": path['file_name'],
79
+ "label": path['label'],
80
+ "image_data": path['image_data'],
81
+ }