Delete cats-image.py
Browse files- cats-image.py +0 -94
cats-image.py
DELETED
|
@@ -1,94 +0,0 @@
|
|
| 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.
|
| 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 |
-
|
| 16 |
-
|
| 17 |
-
import textwrap
|
| 18 |
-
|
| 19 |
-
import datasets
|
| 20 |
-
|
| 21 |
-
from PIL import Image
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
_CITATION = """\\n"""
|
| 25 |
-
|
| 26 |
-
_DESCRIPTION = """\\n"""
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
class CatsImageConfig(datasets.BuilderConfig):
|
| 30 |
-
"""BuilderConfig for COCO cats image."""
|
| 31 |
-
|
| 32 |
-
def __init__(
|
| 33 |
-
self,
|
| 34 |
-
data_url,
|
| 35 |
-
url,
|
| 36 |
-
task_templates=None,
|
| 37 |
-
**kwargs,
|
| 38 |
-
):
|
| 39 |
-
super(CatsImageConfig, self).__init__(
|
| 40 |
-
version=datasets.Version("1.9.0", ""), **kwargs
|
| 41 |
-
)
|
| 42 |
-
self.data_url = data_url
|
| 43 |
-
self.url = url
|
| 44 |
-
self.task_templates = task_templates
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
class CatsImage(datasets.GeneratorBasedBuilder):
|
| 48 |
-
"""Cats image. You know, THE cats image from the COCO dataset."""
|
| 49 |
-
|
| 50 |
-
BUILDER_CONFIGS = [
|
| 51 |
-
CatsImageConfig(
|
| 52 |
-
name="image",
|
| 53 |
-
description=textwrap.dedent(""),
|
| 54 |
-
url="",
|
| 55 |
-
data_url="",
|
| 56 |
-
)
|
| 57 |
-
]
|
| 58 |
-
|
| 59 |
-
DEFAULT_CONFIG_NAME = "image"
|
| 60 |
-
|
| 61 |
-
def _info(self):
|
| 62 |
-
return datasets.DatasetInfo(
|
| 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 |
-
)
|
| 73 |
-
|
| 74 |
-
def _split_generators(self, dl_manager):
|
| 75 |
-
DL_URLS = [
|
| 76 |
-
f"https://huggingface.co/datasets/huggingface/cats-image/raw/main/{name}"
|
| 77 |
-
for name in ["cats_image.jpeg"]
|
| 78 |
-
]
|
| 79 |
-
archive_path = dl_manager.download_and_extract(DL_URLS)
|
| 80 |
-
return [
|
| 81 |
-
datasets.SplitGenerator(
|
| 82 |
-
name=datasets.Split.TEST,
|
| 83 |
-
gen_kwargs={"archive_path": archive_path},
|
| 84 |
-
),
|
| 85 |
-
]
|
| 86 |
-
|
| 87 |
-
def _generate_examples(self, archive_path):
|
| 88 |
-
"""Generate examples."""
|
| 89 |
-
for idx, filename in enumerate(archive_path):
|
| 90 |
-
image = Image.open(filename)
|
| 91 |
-
example = {
|
| 92 |
-
"image": image,
|
| 93 |
-
}
|
| 94 |
-
yield idx, example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|