nielsr HF staff commited on
Commit
3526e52
1 Parent(s): ba37f72

Update cats-image.py

Browse files
Files changed (1) hide show
  1. cats-image.py +8 -8
cats-image.py CHANGED
@@ -1,5 +1,5 @@
1
  # coding=utf-8
2
- # Copyright 2021 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,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
- "id": datasets.Value("string"),
65
- "file": datasets.Value("string"),
66
  }
67
  ),
68
- supervised_keys=("file",),
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
- key = str(i)
90
  example = {
91
- "id": key,
92
- "file": filename,
93
  }
94
- yield key, example
 
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