vqa_benchmarking_backend.datasets.VQADataset¶
Module Contents¶
Classes¶
Class describing one data sample of the VQA2 dataset |
|
Class describing the VQA2 dataset |
Functions¶
|
Removes punctuation and make everything lower case |
|
Loads an image using module |
|
Loads a numpy array containing image features |
|
Removes punctuation |
|
Calculates VQA score in [0,1] depending on number of humans having given the same answer |
- vqa_benchmarking_backend.datasets.VQADataset.preprocess_question(question: str) List[str]¶
Removes punctuation and make everything lower case
- vqa_benchmarking_backend.datasets.VQADataset.load_img(path: str, transform=None) numpy.ndarray¶
Loads an image using module
cv2
- vqa_benchmarking_backend.datasets.VQADataset.load_img_feats(path: str) torch.FloatTensor¶
Loads a numpy array containing image features
- vqa_benchmarking_backend.datasets.VQADataset.preprocess_answer(answer: str) str¶
Removes punctuation
- vqa_benchmarking_backend.datasets.VQADataset.answer_score(num_humans) float¶
Calculates VQA score in [0,1] depending on number of humans having given the same answer
- class vqa_benchmarking_backend.datasets.VQADataset.VQADataSample(question_id: str, question: str, answers: Dict[str, float], image_id: str, image_path: str, image_feat_path: str, image_transform=None)¶
Bases:
vqa_benchmarking_backend.datasets.dataset.DataSampleClass describing one data sample of the VQA2 dataset Inheriting from
DataSample- property image(self) numpy.ndarray¶
Returns the image, if not present it loads it from
self._image_path
- property question_tokenized(self) List[str]¶
Returns tokenized question
- property question(self) str¶
Returns full question
- class vqa_benchmarking_backend.datasets.VQADataset.VQADataset(val_question_file: str, val_annotation_file: str, answer_file: str, img_dir, img_feat_dir, name: str, transform=None, load_img_features=False, dataset_fraction: float = 0.05, random_seed: int = 12345)¶
Bases:
vqa_benchmarking_backend.datasets.dataset.DiagnosticDatasetClass describing the VQA2 dataset Inheriting from
DiagnosticDataset- __len__(self)¶
- _load_data(self, question_file: str, annotation_file: str, dataset_fraction: float, random_seed: int) Tuple[List[vqa_benchmarking_backend.datasets.dataset.DataSample], Dict[str, vqa_benchmarking_backend.datasets.dataset.DataSample], vqa_benchmarking_backend.utils.vocab.Vocabulary, vqa_benchmarking_backend.utils.vocab.Vocabulary]¶
Loads data from VQA json files Returns:
data: list of
VQADataSampleqid_to_sample: mapping of question id to data sample
question_vocab:
Vocabularyof all unique words occuring in the dataanswer_vocab:
Vocabularyof all unique answers
- __getitem__(self, index) vqa_benchmarking_backend.datasets.dataset.DataSample¶
Returns a data sample
- get_name(self) str¶
Returns the name of the dataset, required for file caching
- class_idx_to_answer(self, class_idx: int) Union[str, None]¶
Get the answer string for a given class index from the
self.idx2ansdictionary