Update test.py
Browse files
test.py
CHANGED
|
@@ -24,9 +24,21 @@ _URLS = {
|
|
| 24 |
"train": _URL + 'train1_dataset.csv',
|
| 25 |
"reg": _URL + 'reg1_dataset.csv',
|
| 26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
class imgdataset(datasets.GeneratorBasedBuilder):
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
def _info(self):
|
| 31 |
return datasets.DatasetInfo(
|
| 32 |
description=_DESCRIPTION,
|
|
@@ -45,40 +57,13 @@ class imgdataset(datasets.GeneratorBasedBuilder):
|
|
| 45 |
version=_VERSION,
|
| 46 |
citation=_CITATION,
|
| 47 |
)
|
| 48 |
-
|
| 49 |
-
# """This function returns the examples in the raw (text) form."""
|
| 50 |
-
# urls = _URLS[self.config.name]
|
| 51 |
-
# print(urls)
|
| 52 |
-
# downloaded_files = dl_manager.download_and_extract(urls)
|
| 53 |
-
# # downloaded_files['train']
|
| 54 |
-
# print(downloaded_files)
|
| 55 |
-
# return [
|
| 56 |
-
# datasets.SplitGenerator(
|
| 57 |
-
# name=datasets.Split.TRAIN,
|
| 58 |
-
# # These kwargs will be passed to _generate_examples
|
| 59 |
-
# gen_kwargs={
|
| 60 |
-
# "filepath": os.path.join(downloaded_files),
|
| 61 |
-
# "split": "img",
|
| 62 |
-
# },
|
| 63 |
-
# ),
|
| 64 |
-
# datasets.SplitGenerator(
|
| 65 |
-
# name=datasets.Split.TEST,
|
| 66 |
-
# # These kwargs will be passed to _generate_examples
|
| 67 |
-
# gen_kwargs={
|
| 68 |
-
# "filepath": os.path.join(downloaded_files),
|
| 69 |
-
# "split": "reg",
|
| 70 |
-
# },
|
| 71 |
-
# ),
|
| 72 |
-
# ]
|
| 73 |
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 74 |
downloaded_files = dl_manager.download_and_extract(_URLS)
|
| 75 |
-
|
| 76 |
return [
|
| 77 |
datasets.SplitGenerator(datasets.Split.TRAIN, {
|
| 78 |
-
"filepath": downloaded_files[
|
| 79 |
-
}),
|
| 80 |
-
datasets.SplitGenerator(datasets.Split.VALIDATION, {
|
| 81 |
-
"filepath": downloaded_files["reg"]
|
| 82 |
}),
|
| 83 |
]
|
| 84 |
def _generate_examples(self, filepath):
|
|
@@ -103,40 +88,3 @@ class imgdataset(datasets.GeneratorBasedBuilder):
|
|
| 103 |
os.makedirs(folder)
|
| 104 |
urllib.request.urlretrieve(url, path)
|
| 105 |
key += 1
|
| 106 |
-
# def _generate_examples(self, filepath, split):
|
| 107 |
-
|
| 108 |
-
# # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 109 |
-
# # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 110 |
-
# with open(filepath, encoding="utf-8") as f:
|
| 111 |
-
# data = csv.DictReader(f)
|
| 112 |
-
# key = 0
|
| 113 |
-
# for row in data:
|
| 114 |
-
# if self.config.name == "train":
|
| 115 |
-
# yield key, {
|
| 116 |
-
# "Class_name": row['Class_name'],
|
| 117 |
-
# "file_name": row['file_name'],
|
| 118 |
-
# "file_id": row['file_id']
|
| 119 |
-
# }
|
| 120 |
-
# class_name =row['Class_name']
|
| 121 |
-
# file_name = row['file_name']
|
| 122 |
-
# url =row['file_id']
|
| 123 |
-
# path = os.path.join('./image/',class_name,file_name)
|
| 124 |
-
# folder = os.path.join('./image/',class_name)
|
| 125 |
-
# if not os.path.isdir(folder): #ํด๋๊ฐ ์กด์ฌํ์ง ์๋๋ค๋ฉด ํด๋ ์์ฑ
|
| 126 |
-
# os.makedirs(folder)
|
| 127 |
-
# urllib.request.urlretrieve(url, path)
|
| 128 |
-
# else:
|
| 129 |
-
# yield key, {
|
| 130 |
-
# "Class_name": row['Class_name'],
|
| 131 |
-
# "file_name": row['file_name'],
|
| 132 |
-
# "file_id": row['file_id']
|
| 133 |
-
# }
|
| 134 |
-
# class_name =row['Class_name']
|
| 135 |
-
# file_name = row['file_name']
|
| 136 |
-
# url =row['file_id']
|
| 137 |
-
# path = os.path.join('./regu/',class_name,file_name)
|
| 138 |
-
# folder = os.path.join('./regu/',class_name)
|
| 139 |
-
# if not os.path.isdir(folder): #ํด๋๊ฐ ์กด์ฌํ์ง ์๋๋ค๋ฉด ํด๋ ์์ฑ
|
| 140 |
-
# os.makedirs(folder)
|
| 141 |
-
# urllib.request.urlretrieve(url, path)
|
| 142 |
-
# key +=1
|
|
|
|
| 24 |
"train": _URL + 'train1_dataset.csv',
|
| 25 |
"reg": _URL + 'reg1_dataset.csv',
|
| 26 |
}
|
| 27 |
+
task_list = [
|
| 28 |
+
"train",
|
| 29 |
+
"reg",
|
| 30 |
+
]
|
| 31 |
+
class taskConfig(datasets.BuilderConfig):
|
| 32 |
+
def __init__(self, **kwargs):
|
| 33 |
+
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
|
| 34 |
|
| 35 |
class imgdataset(datasets.GeneratorBasedBuilder):
|
| 36 |
+
BUILDER_CONFIGS = [
|
| 37 |
+
SampleConfig(
|
| 38 |
+
name=task_name,
|
| 39 |
+
)
|
| 40 |
+
for task_name in task_list
|
| 41 |
+
]
|
| 42 |
def _info(self):
|
| 43 |
return datasets.DatasetInfo(
|
| 44 |
description=_DESCRIPTION,
|
|
|
|
| 57 |
version=_VERSION,
|
| 58 |
citation=_CITATION,
|
| 59 |
)
|
| 60 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 62 |
downloaded_files = dl_manager.download_and_extract(_URLS)
|
| 63 |
+
task_name = self.config.name
|
| 64 |
return [
|
| 65 |
datasets.SplitGenerator(datasets.Split.TRAIN, {
|
| 66 |
+
"filepath": downloaded_files[task_name]
|
|
|
|
|
|
|
|
|
|
| 67 |
}),
|
| 68 |
]
|
| 69 |
def _generate_examples(self, filepath):
|
|
|
|
| 88 |
os.makedirs(folder)
|
| 89 |
urllib.request.urlretrieve(url, path)
|
| 90 |
key += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|