mrdbourke commited on
Commit
b5ed5dc
1 Parent(s): 7a8e3b7

update data loading script

Browse files
Files changed (1) hide show
  1. food_vision_199_classes.py +6 -5
food_vision_199_classes.py CHANGED
@@ -243,8 +243,7 @@ class Food199(datasets.GeneratorBasedBuilder):
243
  supervised_keys=("image", "label"),
244
  homepage=_HOMEPAGE,
245
  citation=_CITATION,
246
- license=_LICENSE,
247
- task_templates=[ImageClassification(image_column="image", label_column="label")],
248
  )
249
 
250
  def _split_generators(self, dl_manager):
@@ -252,9 +251,10 @@ class Food199(datasets.GeneratorBasedBuilder):
252
  This function returns the logic to split the dataset into different splits as well as labels.
253
  """
254
  csv = dl_manager.download("annotations_with_links.csv")
255
- df = pd.read_csv(csv)
256
  print("Downloaded annotations.csv")
257
- df_train_annotations = df[["image", "class_name"]][df["split"] == "train"].to_dict(orient="records")
 
258
  # df_test_annotations = df[["filename", "label"]][df["split"] == "test"].to_dict(orient="records")
259
 
260
  return [
@@ -277,6 +277,7 @@ class Food199(datasets.GeneratorBasedBuilder):
277
  """
278
  for id_, row in enumerate(annotations):
279
  row["image"] = str(row.pop("image"))
280
- row["label"] = row.pop("class_name")
 
281
  yield id_, row
282
 
 
243
  supervised_keys=("image", "label"),
244
  homepage=_HOMEPAGE,
245
  citation=_CITATION,
246
+ license=_LICENSE
 
247
  )
248
 
249
  def _split_generators(self, dl_manager):
 
251
  This function returns the logic to split the dataset into different splits as well as labels.
252
  """
253
  csv = dl_manager.download("annotations_with_links.csv")
254
+ df = pd.read_csv(csv, low_memory=False)
255
  print("Downloaded annotations.csv")
256
+ df_train_annotations = df[["image", "label"]][df["split"] == "train"].to_dict(orient="records")
257
+ print(df_train_annotations[:5])
258
  # df_test_annotations = df[["filename", "label"]][df["split"] == "test"].to_dict(orient="records")
259
 
260
  return [
 
277
  """
278
  for id_, row in enumerate(annotations):
279
  row["image"] = str(row.pop("image"))
280
+ row["label"] = row.pop("label")
281
+ print(id_, row)
282
  yield id_, row
283