Update dataset_viewer.py
Browse files- dataset_viewer.py +2 -20
dataset_viewer.py
CHANGED
|
@@ -36,24 +36,6 @@ class SyntheticImageCaptionPairDataset(datasets.GeneratorBasedBuilder):
|
|
| 36 |
citation=_CITATION,
|
| 37 |
)
|
| 38 |
|
| 39 |
-
# def _split_generators(self, dl_manager):
|
| 40 |
-
# images_archive = dl_manager.download(f"{_REPO}/images.tgz")
|
| 41 |
-
# image_iters = dl_manager.iter_archive(images_archive)
|
| 42 |
-
# # Download and load the JSON file containing descriptions
|
| 43 |
-
# descriptions_file = dl_manager.download(f"{_REPO}/sampled_blip_captions.json")
|
| 44 |
-
# with open(descriptions_file, "r") as f:
|
| 45 |
-
# descriptions = json.load(f)
|
| 46 |
-
#
|
| 47 |
-
# return [
|
| 48 |
-
# datasets.SplitGenerator(
|
| 49 |
-
# name=datasets.Split.TRAIN,
|
| 50 |
-
# gen_kwargs={
|
| 51 |
-
# "images": image_iters,
|
| 52 |
-
# "descriptions": descriptions
|
| 53 |
-
# }
|
| 54 |
-
# ),
|
| 55 |
-
# ]
|
| 56 |
-
|
| 57 |
def _generate_examples(self, **kwargs):
|
| 58 |
"""This function returns the examples in the raw (text) form."""
|
| 59 |
images_archive = kwargs['dl_manager'].download(f"{_REPO}/images.tgz")
|
|
@@ -67,8 +49,8 @@ class SyntheticImageCaptionPairDataset(datasets.GeneratorBasedBuilder):
|
|
| 67 |
image_id = os.path.splitext(os.path.basename(filepath))[0]
|
| 68 |
|
| 69 |
# Get caption corresponding to image ID
|
| 70 |
-
|
| 71 |
yield idx, {
|
| 72 |
-
"
|
| 73 |
"blip-2 caption": descriptions[image_id],
|
| 74 |
}
|
|
|
|
| 36 |
citation=_CITATION,
|
| 37 |
)
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
def _generate_examples(self, **kwargs):
|
| 40 |
"""This function returns the examples in the raw (text) form."""
|
| 41 |
images_archive = kwargs['dl_manager'].download(f"{_REPO}/images.tgz")
|
|
|
|
| 49 |
image_id = os.path.splitext(os.path.basename(filepath))[0]
|
| 50 |
|
| 51 |
# Get caption corresponding to image ID
|
| 52 |
+
caption = descriptions.get(image_id, "No description available")
|
| 53 |
yield idx, {
|
| 54 |
+
"image_id": image_id,
|
| 55 |
"blip-2 caption": descriptions[image_id],
|
| 56 |
}
|