Matthijs commited on
Commit
22b699f
1 Parent(s): eae3955

remove image files, add dataset builder

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. annotations/test.csv +0 -0
  2. annotations/train.csv +0 -0
  3. annotations/val.csv +0 -0
  4. snacks.py +87 -0
  5. test/apple/00341c3c5825fc7e.jpg +0 -0
  6. test/apple/004be96d7985d83e.jpg +0 -0
  7. test/apple/01ac2a42f2a22ee7.jpg +0 -0
  8. test/apple/03bfc0b1cc6bde63.jpg +0 -0
  9. test/apple/09ed54b36eaa5316.jpg +0 -0
  10. test/apple/0f8670e41c97c8cb.jpg +0 -0
  11. test/apple/137591bb5ac95a5e.jpg +0 -0
  12. test/apple/1382c47d4df56b77.jpg +0 -0
  13. test/apple/1acfd560a4424e04.jpg +0 -0
  14. test/apple/1db0cb75f37d6cba.jpg +0 -0
  15. test/apple/1e5a5b8fbd4ca698.jpg +0 -0
  16. test/apple/1ef79535f0645f1f.jpg +0 -0
  17. test/apple/2011d826e9ba42ac.jpg +0 -0
  18. test/apple/26170762a4777de6.jpg +0 -0
  19. test/apple/275f429194a6683a.jpg +0 -0
  20. test/apple/27706823aee8d883.jpg +0 -0
  21. test/apple/2c264be5e4d157bf.jpg +0 -0
  22. test/apple/332e03a2441a803b.jpg +0 -0
  23. test/apple/3485e0b69848c5b9.jpg +0 -0
  24. test/apple/358f229aa8895684.jpg +0 -0
  25. test/apple/3908a17d509bf36c.jpg +0 -0
  26. test/apple/3d29662970a70658.jpg +0 -0
  27. test/apple/4686e33b56653b9c.jpg +0 -0
  28. test/apple/4b3a282b7f4bdad1.jpg +0 -0
  29. test/apple/555f563b48ec9183.jpg +0 -0
  30. test/apple/671292276d92cee4.jpg +0 -0
  31. test/apple/70d4890ac04a702a.jpg +0 -0
  32. test/apple/72d180f7445b817c.jpg +0 -0
  33. test/apple/741462a3482a68b4.jpg +0 -0
  34. test/apple/79c8f1a27741eddb.jpg +0 -0
  35. test/apple/87e88ea71a9c8a71.jpg +0 -0
  36. test/apple/8c29e8a262805137.jpg +0 -0
  37. test/apple/8f2c0ef78304476b.jpg +0 -0
  38. test/apple/91bdc8cf6a190404.jpg +0 -0
  39. test/apple/94de58da0f25a821.jpg +0 -0
  40. test/apple/953a08e8cfa4dfce.jpg +0 -0
  41. test/apple/a53301ea630edba6.jpg +0 -0
  42. test/apple/a5c601a55c21ca46.jpg +0 -0
  43. test/apple/ae6be536a932a749.jpg +0 -0
  44. test/apple/af47707f6a316088.jpg +0 -0
  45. test/apple/b1ce6250dad71e9e.jpg +0 -0
  46. test/apple/b3c07c92bf698a4f.jpg +0 -0
  47. test/apple/b876d59ba12ccabc.jpg +0 -0
  48. test/apple/c1c62046befcff01.jpg +0 -0
  49. test/apple/c90f57a9d8fceb90.jpg +0 -0
  50. test/apple/cc30cf6b3a56cdd9.jpg +0 -0
annotations/test.csv DELETED
The diff for this file is too large to render. See raw diff
annotations/train.csv DELETED
The diff for this file is too large to render. See raw diff
annotations/val.csv DELETED
The diff for this file is too large to render. See raw diff
snacks.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ """Snacks Data Set"""
3
+
4
+ import os
5
+
6
+ import datasets
7
+ from datasets.tasks import ImageClassification
8
+
9
+
10
+ _CITATION = """
11
+ @article{OpenImages2,
12
+ title={OpenImages: A public dataset for large-scale multi-label and multi-class image classification.},
13
+ author={Krasin, Ivan and Duerig, Tom and Alldrin, Neil and Ferrari, Vittorio and Abu-El-Haija, Sami and Kuznetsova, Alina and Rom, Hassan and Uijlings, Jasper and Popov, Stefan and Kamali, Shahab and Malloci, Matteo and Pont-Tuset, Jordi and Veit, Andreas and Belongie, Serge and Gomes, Victor and Gupta, Abhinav and Sun, Chen and Chechik, Gal and Cai, David and Feng, Zheyun and Narayanan, Dhyanesh and Murphy, Kevin},
14
+ journal={Dataset available from https://storage.googleapis.com/openimages/web/index.html},
15
+ year={2017}
16
+ }
17
+ """
18
+
19
+ _DESCRIPTION = "This is a dataset of 20 different types of snack foods that accompanies the book Machine Learning by Tutorials, https://www.raywenderlich.com/books/machine-learning-by-tutorials/v2.0 — Based on images from Google Open Images dataset."
20
+
21
+ _HOMEPAGE = "https://huggingface.co/datasets/Matthijs/snacks/"
22
+
23
+ _LICENSE = "cc-by-4.0"
24
+
25
+ _IMAGES_URL = "https://huggingface.co/datasets/Matthijs/snacks/resolve/main/images.zip"
26
+ _ANNOTATIONS_URL = "https://huggingface.co/datasets/Matthijs/snacks/resolve/main/annotations.zip"
27
+
28
+ _NAMES = ["apple", "banana", "cake", "candy", "carrot", "cookie",
29
+ "doughnut", "grape", "hot dog", "ice cream", "juice",
30
+ "muffin", "orange", "pineapple", "popcorn", "pretzel",
31
+ "salad", "strawberry", "waffle", "watermelon"]
32
+
33
+
34
+ class Snacks(datasets.GeneratorBasedBuilder):
35
+ """Snacks Data Set"""
36
+
37
+ BUILDER_CONFIGS = [
38
+ datasets.BuilderConfig(
39
+ name="default",
40
+ version=datasets.Version("0.0.1", ""),
41
+ description="",
42
+ )
43
+ ]
44
+
45
+ def _info(self):
46
+ return datasets.DatasetInfo(
47
+ description=_DESCRIPTION,
48
+ features=datasets.Features(
49
+ {
50
+ "image_file_path": datasets.Value("string"),
51
+ "image": datasets.Image(),
52
+ "label": datasets.features.ClassLabel(names=_NAMES),
53
+ }
54
+ ),
55
+ supervised_keys=("image", "label"),
56
+ homepage=_HOMEPAGE,
57
+ citation=_CITATION,
58
+ license=_LICENSE,
59
+ task_templates=ImageClassification(image_column="img", label_column="label"),
60
+ )
61
+
62
+ def _split_generators(self, dl_manager):
63
+ archive = os.path.join(dl_manager.download_and_extract(_IMAGES_URL), "data")
64
+ train_path = os.path.join(archive, "train")
65
+ test_path = os.path.join(archive, "test")
66
+ val_path = os.path.join(archive, "val")
67
+
68
+ return [
69
+ datasets.SplitGenerator(
70
+ name=datasets.Split.TRAIN, gen_kwargs={"files": dl_manager.iter_files(train_path)}
71
+ ),
72
+ datasets.SplitGenerator(
73
+ name=datasets.Split.TEST, gen_kwargs={"files": dl_manager.iter_files(test_path)}
74
+ ),
75
+ datasets.SplitGenerator(
76
+ name=datasets.Split.VALIDATION, gen_kwargs={"files": dl_manager.iter_files(val_path)}
77
+ ),
78
+ ]
79
+
80
+ def _generate_examples(self, files):
81
+ for i, file in enumerate(files):
82
+ if os.path.basename(file).endswith(".jpg"):
83
+ yield str(i), {
84
+ "image_file_path": file,
85
+ "image": file,
86
+ "label": os.path.basename(os.path.dirname(file)).lower(),
87
+ }
test/apple/00341c3c5825fc7e.jpg DELETED
Binary file (13.1 kB)
test/apple/004be96d7985d83e.jpg DELETED
Binary file (17.4 kB)
test/apple/01ac2a42f2a22ee7.jpg DELETED
Binary file (13.1 kB)
test/apple/03bfc0b1cc6bde63.jpg DELETED
Binary file (13 kB)
test/apple/09ed54b36eaa5316.jpg DELETED
Binary file (16.8 kB)
test/apple/0f8670e41c97c8cb.jpg DELETED
Binary file (17.1 kB)
test/apple/137591bb5ac95a5e.jpg DELETED
Binary file (7.91 kB)
test/apple/1382c47d4df56b77.jpg DELETED
Binary file (7.32 kB)
test/apple/1acfd560a4424e04.jpg DELETED
Binary file (6.44 kB)
test/apple/1db0cb75f37d6cba.jpg DELETED
Binary file (12.2 kB)
test/apple/1e5a5b8fbd4ca698.jpg DELETED
Binary file (16.7 kB)
test/apple/1ef79535f0645f1f.jpg DELETED
Binary file (7.27 kB)
test/apple/2011d826e9ba42ac.jpg DELETED
Binary file (9.62 kB)
test/apple/26170762a4777de6.jpg DELETED
Binary file (14.2 kB)
test/apple/275f429194a6683a.jpg DELETED
Binary file (7.15 kB)
test/apple/27706823aee8d883.jpg DELETED
Binary file (18.9 kB)
test/apple/2c264be5e4d157bf.jpg DELETED
Binary file (8.91 kB)
test/apple/332e03a2441a803b.jpg DELETED
Binary file (10.4 kB)
test/apple/3485e0b69848c5b9.jpg DELETED
Binary file (17 kB)
test/apple/358f229aa8895684.jpg DELETED
Binary file (21.6 kB)
test/apple/3908a17d509bf36c.jpg DELETED
Binary file (7.17 kB)
test/apple/3d29662970a70658.jpg DELETED
Binary file (11.2 kB)
test/apple/4686e33b56653b9c.jpg DELETED
Binary file (15.1 kB)
test/apple/4b3a282b7f4bdad1.jpg DELETED
Binary file (18.7 kB)
test/apple/555f563b48ec9183.jpg DELETED
Binary file (6.45 kB)
test/apple/671292276d92cee4.jpg DELETED
Binary file (13.6 kB)
test/apple/70d4890ac04a702a.jpg DELETED
Binary file (10.3 kB)
test/apple/72d180f7445b817c.jpg DELETED
Binary file (10.3 kB)
test/apple/741462a3482a68b4.jpg DELETED
Binary file (8.63 kB)
test/apple/79c8f1a27741eddb.jpg DELETED
Binary file (17.7 kB)
test/apple/87e88ea71a9c8a71.jpg DELETED
Binary file (8.11 kB)
test/apple/8c29e8a262805137.jpg DELETED
Binary file (13.3 kB)
test/apple/8f2c0ef78304476b.jpg DELETED
Binary file (6.03 kB)
test/apple/91bdc8cf6a190404.jpg DELETED
Binary file (17.4 kB)
test/apple/94de58da0f25a821.jpg DELETED
Binary file (18.5 kB)
test/apple/953a08e8cfa4dfce.jpg DELETED
Binary file (19.9 kB)
test/apple/a53301ea630edba6.jpg DELETED
Binary file (8.11 kB)
test/apple/a5c601a55c21ca46.jpg DELETED
Binary file (17.8 kB)
test/apple/ae6be536a932a749.jpg DELETED
Binary file (15.9 kB)
test/apple/af47707f6a316088.jpg DELETED
Binary file (21.1 kB)
test/apple/b1ce6250dad71e9e.jpg DELETED
Binary file (13.5 kB)
test/apple/b3c07c92bf698a4f.jpg DELETED
Binary file (11.8 kB)
test/apple/b876d59ba12ccabc.jpg DELETED
Binary file (21 kB)
test/apple/c1c62046befcff01.jpg DELETED
Binary file (14.9 kB)
test/apple/c90f57a9d8fceb90.jpg DELETED
Binary file (14.6 kB)
test/apple/cc30cf6b3a56cdd9.jpg DELETED
Binary file (12.4 kB)