class_docstr: Dataset loader for Flickr-30k and Flickr-8k datasets.
  
  For more info see:
      http://hockenmaier.cs.illinois.edu/8k-pictures.html
      https://shannon.cs.illinois.edu/DenotationGraph/
  
  Splits: train, val, and test
      Also known in literature as Karpathy splits
      https://cs.stanford.edu/people/karpathy/deepimagesent/
  
  Tracking license info:
      Captions have CC BY 3.0 license (see links above).
      Splits are under BSD License (see Github of NeuralTalk by Karpathy et. al.).
      Images are from Flickr. We do not own them and are only used for research purposes.
  
  Args:
      opts: command-line arguments
      is_training (Optional[bool]): A flag used to indicate training or
          validation mode. Default: True
      is_evaluation (Optional[bool]): A flag used to indicate evaluation (or
          inference) mode. Default: False
class_docstr_tok: ["Dataset","loader","for","Flickr-30k","and","Flickr-8k","datasets",".","For","more","info","see",":","http",":","\/\/hockenmaier.cs.illinois.edu\/8k-pictures.html","https",":","\/\/shannon.cs.illinois.edu\/DenotationGraph\/","Splits",":","train",",","val",",","and","test","Also","known","in","literature","as","Karpathy","splits","https",":","\/\/cs.stanford.edu\/people\/karpathy\/deepimagesent\/","Tracking","license","info",":","Captions","have","CC","BY","3.0","license","(","see","links","above",")",".","Splits","are","under","BSD","License","(","see","Github","of","NeuralTalk","by","Karpathy","et",".","al.",")",".","Images","are","from","Flickr",".","We","do","not","own","them","and","are","only","used","for","research","purposes",".","Args",":","opts",":","command-line","arguments","is_training","(","Optional","[","bool","]",")",":","A","flag","used","to","indicate","training","or","validation","mode",".","Default",":","True","is_evaluation","(","Optional","[","bool","]",")",":","A","flag","used","to","indicate","evaluation","(","or","inference",")","mode",".","Default",":","False"]
docstr: The data under `self.root` is expected to consist of:
  
      dataset.json   # Karpathy splits + captions
      images/        # Raw images
  
  The metdatadata cap be downloaded from:
      https://cs.stanford.edu/people/karpathy/deepimagesent/flickr30k.zip
  
  Images can be obtained from:
      Flickr-8k:  http://hockenmaier.cs.illinois.edu/8k-pictures.html
      Flickr-30k: https://shannon.cs.illinois.edu/DenotationGraph/
docstr_tok: ["The","data","under","`","self.root","`","is","expected","to","consist","of",":","dataset.json","#","Karpathy","splits","+","captions","images\/","#","Raw","images","The","metdatadata","cap","be","downloaded","from",":","https",":","\/\/cs.stanford.edu\/people\/karpathy\/deepimagesent\/flickr30k.zip","Images","can","be","obtained","from",":","Flickr-8k",":","http",":","\/\/hockenmaier.cs.illinois.edu\/8k-pictures.html","Flickr-30k",":","https",":","\/\/shannon.cs.illinois.edu\/DenotationGraph\/"]
code: def get_dataset(self, *args, **kwargs) -> None:
      """
      The data under `self.root` is expected to consist of:
  
          dataset.json   # Karpathy splits + captions
          images/        # Raw images
  
      The metdatadata cap be downloaded from:
          https://cs.stanford.edu/people/karpathy/deepimagesent/flickr30k.zip
  
      Images can be obtained from:
          Flickr-8k:  http://hockenmaier.cs.illinois.edu/8k-pictures.html
          Flickr-30k: https://shannon.cs.illinois.edu/DenotationGraph/
      """
      metadata_path = os.path.join(self.root, "dataset.json")
      with open(metadata_path, "r") as metadata_file:
          metadata = json.load(metadata_file)["images"]
  
      split = self.mode
  
      self.samples = [
          {
              "image_name": sample["filename"],
              "captions": [x["raw"] for x in sample["sentences"]],
          }
          for sample in metadata
          if sample["split"] == split
      ]
  
      if self.is_training:
          # For training, flatten the captions by copying each image multiple times
          # This way at each epoch, each caption will be seen 1 time but each image
          # will be seen #num_captions (= 5) times.
          self.samples = [
              {"image_name": sample["image_name"], "captions": caption}
              for sample in self.samples
              for caption in sample["captions"]
          ]
  
file_path: ml-cvnets/data/datasets/multi_modal_img_text/flickr.py
imports: import argparse
  import json
  import os
  from typing import Dict, List, Optional, Tuple
  import torch
  from data.datasets import DATASET_REGISTRY
  from data.datasets.multi_modal_img_text.base_multi_modal_img_text import BaseMultiModalImgText
  from utils import logger
  from utils.ddp_utils import is_master
label_desc: Use image node_id 1 for calling the FlickrDataset obj's underlying member method code with example usage: obj.get_dataset() without return types