Update cats-image.py
Browse files- cats-image.py +8 -8
cats-image.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# coding=utf-8
|
2 |
-
# Copyright
|
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.
|
@@ -18,6 +18,8 @@ import textwrap
|
|
18 |
|
19 |
import datasets
|
20 |
|
|
|
|
|
21 |
|
22 |
_CITATION = """\\n"""
|
23 |
|
@@ -61,11 +63,10 @@ class CatsImage(datasets.GeneratorBasedBuilder):
|
|
61 |
description=_DESCRIPTION,
|
62 |
features=datasets.Features(
|
63 |
{
|
64 |
-
"
|
65 |
-
"file": datasets.Value("string"),
|
66 |
}
|
67 |
),
|
68 |
-
supervised_keys=("
|
69 |
homepage=self.config.url,
|
70 |
citation=_CITATION,
|
71 |
)
|
@@ -86,9 +87,8 @@ class CatsImage(datasets.GeneratorBasedBuilder):
|
|
86 |
def _generate_examples(self, archive_path):
|
87 |
"""Generate examples."""
|
88 |
for i, filename in enumerate(archive_path):
|
89 |
-
|
90 |
example = {
|
91 |
-
"
|
92 |
-
"file": filename,
|
93 |
}
|
94 |
-
yield
|
|
|
1 |
# coding=utf-8
|
2 |
+
# Copyright 2022 The HuggingFace Team.
|
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.
|
|
|
18 |
|
19 |
import datasets
|
20 |
|
21 |
+
from PIL import Image
|
22 |
+
|
23 |
|
24 |
_CITATION = """\\n"""
|
25 |
|
|
|
63 |
description=_DESCRIPTION,
|
64 |
features=datasets.Features(
|
65 |
{
|
66 |
+
"image": datasets.Image(),
|
|
|
67 |
}
|
68 |
),
|
69 |
+
supervised_keys=("image",),
|
70 |
homepage=self.config.url,
|
71 |
citation=_CITATION,
|
72 |
)
|
|
|
87 |
def _generate_examples(self, archive_path):
|
88 |
"""Generate examples."""
|
89 |
for i, filename in enumerate(archive_path):
|
90 |
+
image = Image.open(filename)
|
91 |
example = {
|
92 |
+
"image": image,
|
|
|
93 |
}
|
94 |
+
yield example
|