Datasets:
Update horse2zebra.py
Browse files- horse2zebra.py +10 -12
horse2zebra.py
CHANGED
@@ -20,12 +20,10 @@ class Horse2Zebra(datasets.GeneratorBasedBuilder):
|
|
20 |
VERSION = datasets.Version("1.0.0")
|
21 |
|
22 |
BUILDER_CONFIGS = [
|
23 |
-
datasets.BuilderConfig(name="
|
24 |
-
datasets.BuilderConfig(name="
|
25 |
]
|
26 |
|
27 |
-
DEFAULT_CONFIG_NAME = "train"
|
28 |
-
|
29 |
def _info(self):
|
30 |
features = datasets.Features(
|
31 |
{
|
@@ -45,26 +43,26 @@ class Horse2Zebra(datasets.GeneratorBasedBuilder):
|
|
45 |
data_dir = dl_manager.download_and_extract(urls)
|
46 |
return [
|
47 |
datasets.SplitGenerator(
|
48 |
-
name=
|
49 |
gen_kwargs={
|
50 |
"datapath": os.path.join(data_dir, "horse2zebra"),
|
51 |
-
"split":"
|
52 |
},
|
53 |
),
|
54 |
datasets.SplitGenerator(
|
55 |
-
name=
|
56 |
gen_kwargs={
|
57 |
"datapath": os.path.join(data_dir, "horse2zebra"),
|
58 |
-
"split":"
|
59 |
},
|
60 |
),
|
61 |
]
|
62 |
|
63 |
def _generate_examples(self, datapath, split):
|
64 |
-
if split=="
|
65 |
-
dir = "trainA" if self.config.name == "
|
66 |
-
elif split=="
|
67 |
-
dir = "
|
68 |
image_dir = os.path.join(datapath, dir)
|
69 |
for idx, image_file in enumerate(os.listdir(image_dir)):
|
70 |
image_id = image_file.split(".")[0]
|
|
|
20 |
VERSION = datasets.Version("1.0.0")
|
21 |
|
22 |
BUILDER_CONFIGS = [
|
23 |
+
datasets.BuilderConfig(name="horse", version=VERSION, description="Images of horses"),
|
24 |
+
datasets.BuilderConfig(name="zebra", version=VERSION, description="Images of zebras"),
|
25 |
]
|
26 |
|
|
|
|
|
27 |
def _info(self):
|
28 |
features = datasets.Features(
|
29 |
{
|
|
|
43 |
data_dir = dl_manager.download_and_extract(urls)
|
44 |
return [
|
45 |
datasets.SplitGenerator(
|
46 |
+
name=datasets.Split.TRAIN,
|
47 |
gen_kwargs={
|
48 |
"datapath": os.path.join(data_dir, "horse2zebra"),
|
49 |
+
"split":"train"
|
50 |
},
|
51 |
),
|
52 |
datasets.SplitGenerator(
|
53 |
+
name=datasets.Split.TEST,
|
54 |
gen_kwargs={
|
55 |
"datapath": os.path.join(data_dir, "horse2zebra"),
|
56 |
+
"split":"test"
|
57 |
},
|
58 |
),
|
59 |
]
|
60 |
|
61 |
def _generate_examples(self, datapath, split):
|
62 |
+
if split=="train":
|
63 |
+
dir = "trainA" if self.config.name == "horse" else "trainB"
|
64 |
+
elif split=="test":
|
65 |
+
dir = "testA" if self.config.name == "horse" else "testB"
|
66 |
image_dir = os.path.join(datapath, dir)
|
67 |
for idx, image_file in enumerate(os.listdir(image_dir)):
|
68 |
image_id = image_file.split(".")[0]
|