abinthomasonline commited on
Commit
61d6165
1 Parent(s): cd9a788

Update stained-glass.py

Browse files
Files changed (1) hide show
  1. stained-glass.py +4 -4
stained-glass.py CHANGED
@@ -28,7 +28,7 @@ class StainedGlass(datasets.GeneratorBasedBuilder):
28
  def _split_generators(self, dl_manager):
29
  captions_path = dl_manager.download("captions.csv")
30
  df = pd.read_csv(captions_path, header=None)
31
- image_paths = [os.path.join("images", row[0]) for _, row in df.iterrows()]
32
  image_paths = dl_manager.download(image_paths)
33
 
34
  return [
@@ -45,8 +45,8 @@ class StainedGlass(datasets.GeneratorBasedBuilder):
45
  df = pd.read_csv(captions_path, header=None)
46
  captions = {row[0]: row[1].replace('"', '') for _, row in df.iterrows()}
47
  for adjective in _ADJECTIVES:
48
- for i, image_path in enumerate(image_paths):
49
- yield i, {
50
  "image": image_path,
51
- "caption": captions[os.path.basename(image_path)].format(token='<token>', adjective=adjective),
52
  }
 
28
  def _split_generators(self, dl_manager):
29
  captions_path = dl_manager.download("captions.csv")
30
  df = pd.read_csv(captions_path, header=None)
31
+ image_paths = {row[0]: os.path.join("images", row[0]) for _, row in df.iterrows()}
32
  image_paths = dl_manager.download(image_paths)
33
 
34
  return [
 
45
  df = pd.read_csv(captions_path, header=None)
46
  captions = {row[0]: row[1].replace('"', '') for _, row in df.iterrows()}
47
  for adjective in _ADJECTIVES:
48
+ for key, image_path in image_paths.items():
49
+ yield {
50
  "image": image_path,
51
+ "caption": captions[key].format(token='<token>', adjective=adjective),
52
  }