zmao commited on
Commit
70cdb6a
·
1 Parent(s): f61e01e

Update food_img_caption.py

Browse files
Files changed (1) hide show
  1. food_img_caption.py +8 -1
food_img_caption.py CHANGED
@@ -3,6 +3,7 @@ import json
3
 
4
  import datasets
5
  from datasets.tasks import QuestionAnsweringExtractive
 
6
 
7
 
8
  logger = datasets.logging.get_logger(__name__)
@@ -67,9 +68,15 @@ class FoodCaption(datasets.GeneratorBasedBuilder):
67
 
68
  #iterate through images:
69
  for filepath, image in images:
 
 
 
 
 
 
70
  yield idx, {
71
  "image" : {"path": filepath, "bytes":image.read()},
72
- "text": filepath
73
  }
74
  idx += 1
75
 
 
3
 
4
  import datasets
5
  from datasets.tasks import QuestionAnsweringExtractive
6
+ import re
7
 
8
 
9
  logger = datasets.logging.get_logger(__name__)
 
68
 
69
  #iterate through images:
70
  for filepath, image in images:
71
+
72
+ text = filepath[14:-4]
73
+ text = text.replace('-',' ')
74
+ text = re.sub("^\d+\s|\s\d+\s|\s\d+$", " ", text)
75
+ text = text.strip()
76
+
77
  yield idx, {
78
  "image" : {"path": filepath, "bytes":image.read()},
79
+ "text": text
80
  }
81
  idx += 1
82