Make the dataset deterministic
Browse filesThe order of the files returned by `glob` depends on the filesystem and may change from one location/machine to another.
This should fix flakiness in the `transformers` tests relying on this dataset.
cc
@ydshieh
- cats_vs_dogs_sample.py +1 -1
cats_vs_dogs_sample.py
CHANGED
@@ -70,7 +70,7 @@ class CatsVsDogs(datasets.GeneratorBasedBuilder):
|
|
70 |
|
71 |
def _generate_examples(self, images_path):
|
72 |
logger.info("generating examples from = %s", images_path)
|
73 |
-
for i, filepath in enumerate(images_path.glob("**/*.jpg")):
|
74 |
yield str(i), {
|
75 |
"image": str(filepath),
|
76 |
"labels": filepath.parent.name.lower(),
|
|
|
70 |
|
71 |
def _generate_examples(self, images_path):
|
72 |
logger.info("generating examples from = %s", images_path)
|
73 |
+
for i, filepath in enumerate(sorted(images_path.glob("**/*.jpg"))):
|
74 |
yield str(i), {
|
75 |
"image": str(filepath),
|
76 |
"labels": filepath.parent.name.lower(),
|