nateraw commited on
Commit
5fbd24c
·
1 Parent(s): be8b342

:beers: Update extensions.

Browse files
Files changed (1) hide show
  1. image-folder.py +5 -3
image-folder.py CHANGED
@@ -19,7 +19,7 @@ class CatsAndDogs(datasets.GeneratorBasedBuilder):
19
 
20
  if folder is None:
21
  raise RuntimeError()
22
-
23
  classes = sorted([x.name.lower() for x in Path(folder).glob('*/**')])
24
 
25
  return datasets.DatasetInfo(
@@ -48,5 +48,7 @@ class CatsAndDogs(datasets.GeneratorBasedBuilder):
48
  def _generate_examples(self, archive_path):
49
  labels = self.info.features['labels']
50
  logger.info("generating examples from = %s", archive_path)
51
- for i, path in enumerate(Path(archive_path).glob('**/*.jpg')):
52
- yield i, {'file': path.as_posix(), 'labels': labels.encode_example(path.parent.name.lower())}
 
 
 
19
 
20
  if folder is None:
21
  raise RuntimeError()
22
+
23
  classes = sorted([x.name.lower() for x in Path(folder).glob('*/**')])
24
 
25
  return datasets.DatasetInfo(
 
48
  def _generate_examples(self, archive_path):
49
  labels = self.info.features['labels']
50
  logger.info("generating examples from = %s", archive_path)
51
+ extensions = {'.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp'}
52
+ for i, path in enumerate(Path(archive_path).glob('**/*')):
53
+ if path.suffix in extensions:
54
+ yield i, {'file': path.as_posix(), 'labels': labels.encode_example(path.parent.name.lower())}