mrdbourke commited on
Commit
e345d5d
1 Parent(s): bb43d96

update data loading script

Browse files
Files changed (1) hide show
  1. food_vision_199_classes.py +7 -3
food_vision_199_classes.py CHANGED
@@ -8,6 +8,8 @@ See another example: https://huggingface.co/datasets/davanstrien/encyclopedia_br
8
 
9
  import datasets
10
  import os
 
 
11
  import pandas as pd
12
 
13
  from datasets.tasks import ImageClassification
@@ -17,9 +19,11 @@ _LICENSE = "TODO"
17
  _CITATION = "TODO"
18
  _DESCRIPTION = "Images of 199 food classes from the Nutrify app."
19
 
20
- # Read lines of class_names.txt
21
- class_names = datasets.DownloadManager().download("class_names.txt")
22
- with open(class_names, "r") as f:
 
 
23
  _NAMES = f.read().splitlines()
24
 
25
  # Create Food199 class
 
8
 
9
  import datasets
10
  import os
11
+ import requests
12
+
13
  import pandas as pd
14
 
15
  from datasets.tasks import ImageClassification
 
19
  _CITATION = "TODO"
20
  _DESCRIPTION = "Images of 199 food classes from the Nutrify app."
21
 
22
+ # Download class_names.txt and read it
23
+ url = "https://huggingface.co/datasets/mrdbourke/food_vision_199_classes/blob/main/class_names.txt"
24
+ r = requests.get(url, allow_redirects=True)
25
+ open("class_names.txt', 'wb").write(r.content)
26
+ with open("class_names.txt", "r") as f:
27
  _NAMES = f.read().splitlines()
28
 
29
  # Create Food199 class