docstr: image_root (string): Root directory of images (e.g. flickr30k/)
  ann_root (string): directory to store the annotation file
  split (string): val or test
docstr_tok: ["image_root","(","string",")",":","Root","directory","of","images","(","e.g",".","flickr30k\/",")","ann_root","(","string",")",":","directory","to","store","the","annotation","file","split","(","string",")",":","val","or","test"]
code: def __init__(
      self, transform, image_root, ann_root, split, max_words=30
  ):
      """
      image_root (string): Root directory of images (e.g. flickr30k/)
      ann_root (string): directory to store the annotation file
      split (string): val or test
      """
      urls = {
          "val": "https://storage.googleapis.com/sfr-vision-language-research/datasets/flickr30k_val.json",
          "test": "https://storage.googleapis.com/sfr-vision-language-research/datasets/flickr30k_test.json",
      }
      filenames = {
          "val": "flickr30k_val.json",
          "test": "flickr30k_test.json",
      }
  
      download_url(urls[split], ann_root)
  
      self.annotation = json.load(
          open(os.path.join(ann_root, filenames[split]), "r")
      )
      self.transform = transform
      self.image_root = image_root
  
      self.text = []
      self.image = []
      self.txt2img = {}
      self.img2txt = {}
  
      txt_id = 0
      for img_id, ann in enumerate(self.annotation):
          self.image.append(ann["image"])
          self.img2txt[img_id] = []
          for i, caption in enumerate(ann["caption"]):
              self.text.append(pre_caption(caption, max_words))
              self.img2txt[img_id].append(txt_id)
              self.txt2img[txt_id] = img_id
              txt_id += 1
  
file_path: blip/data/flickr30k_dataset.py
imports: import os
  import json
  from torch.utils.data import Dataset
  from torchvision.datasets.utils import download_url
  from PIL import Image
  from data.utils import pre_caption
label_desc: Use image node_id 1 to create a new flickr30k_retrieval_eval object from inherited base classes: Dataset with example: obj = flickr30k_retrieval_eval(transform, image_root, ann_root, split, max_words)