AlhitawiMohammed22 commited on
Commit
9adbb12
1 Parent(s): 180fdae

Function Enhancement

Browse files

Reducing lines of code in (_generate_examples) funcion

Files changed (1) hide show
  1. image-text-demo.py +3 -4
image-text-demo.py CHANGED
@@ -47,13 +47,12 @@ class ImageSet(datasets.GeneratorBasedBuilder):
47
  ]
48
 
49
  def _generate_examples(self, images):
50
- """This function returns the examples in the raw (text) form."""
51
- idx = 0
52
- for filepath, image in images:
53
  description = filepath.split('/')[-1][:-4]
54
  description = description.replace('_', ' ')
55
  yield idx, {
56
  "image": {"path": filepath, "bytes": image.read()},
57
  "text": description,
58
  }
59
- idx += 1
 
47
  ]
48
 
49
  def _generate_examples(self, images):
50
+ """ This function returns the examples in the raw (text) form."""
51
+
52
+ for idx, (filepath, image) in enumerate(images):
53
  description = filepath.split('/')[-1][:-4]
54
  description = description.replace('_', ' ')
55
  yield idx, {
56
  "image": {"path": filepath, "bytes": image.read()},
57
  "text": description,
58
  }