All Projects → cdancette → detect-shortcuts

cdancette / detect-shortcuts

Licence: other
Repo for ICCV 2021 paper: Beyond Question-Based Biases: Assessing Multimodal Shortcut Learning in Visual Question Answering

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to detect-shortcuts

VCML
PyTorch implementation of paper "Visual Concept-Metaconcept Learner", NeruIPS 2019
Stars: ✭ 45 (+164.71%)
Mutual labels:  visual-question-answering
TRAR-VQA
[ICCV 2021] TRAR: Routing the Attention Spans in Transformers for Visual Question Answering -- Official Implementation
Stars: ✭ 49 (+188.24%)
Mutual labels:  visual-question-answering
hexia
Mid-level PyTorch Based Framework for Visual Question Answering.
Stars: ✭ 24 (+41.18%)
Mutual labels:  visual-question-answering
RelationNetworks-CLEVR
A pytorch implementation for "A simple neural network module for relational reasoning", working on the CLEVR dataset
Stars: ✭ 83 (+388.24%)
Mutual labels:  visual-question-answering
self critical vqa
Code for NeurIPS 2019 paper ``Self-Critical Reasoning for Robust Visual Question Answering''
Stars: ✭ 39 (+129.41%)
Mutual labels:  visual-question-answering
convolutional-vqa
No description or website provided.
Stars: ✭ 39 (+129.41%)
Mutual labels:  visual-question-answering
bottom-up-features
Bottom-up features extractor implemented in PyTorch.
Stars: ✭ 62 (+264.71%)
Mutual labels:  visual-question-answering
KVQA
Korean Visual Question Answering
Stars: ✭ 44 (+158.82%)
Mutual labels:  visual-question-answering
FigureQA-baseline
TensorFlow implementation of the CNN-LSTM, Relation Network and text-only baselines for the paper "FigureQA: An Annotated Figure Dataset for Visual Reasoning"
Stars: ✭ 28 (+64.71%)
Mutual labels:  visual-question-answering
just-ask
[TPAMI Special Issue on ICCV 2021 Best Papers, Oral] Just Ask: Learning to Answer Questions from Millions of Narrated Videos
Stars: ✭ 57 (+235.29%)
Mutual labels:  visual-question-answering
AoA-pytorch
A Pytorch implementation of Attention on Attention module (both self and guided variants), for Visual Question Answering
Stars: ✭ 33 (+94.12%)
Mutual labels:  visual-question-answering

Rule-Mining for shortcut discovery (VQA-CE)

vqa-ce

This repo contains the rule mining pipeline described in the article : Beyond Question-Based Biases: Assessing Multimodal Shortcut Learning in Visual Question Answering by Corentin Dancette, Rémi Cadène, Damien Teney and Matthieu Cord (https://arxiv.org/abs/2104.03149). It also provides the VQA-CE dataset.

Website here: https://cdancette.fr/projects/vqa-ce/

This code was developped with python 3.7 and pytorch 1.7.0.

VQA-CE

The VQA-CE counterexamples subset can be downloaded here :

The "easy" subset can be obtained by substracting counterexamples and hard from all question_ids.

Usage

Installing requirements

First, you need to install gminer. Follow instructions at https://github.com/cdancette/GMiner.

For python requirements, run pip install -r requirements.txt. This will install pytorch, numpy and tqdm.

Visual Question Answering (VQA)

Download VQA and COCO data

First, run ./download.sh. Data will be downloaded in the ./data directory.

Run the rule mining pipeline

Then run python vqa.py --gminer_path <path_to_gminer> to run our pipeline on the VQA v2 dataset. You can change the parameters, see the end of the vqa.py file or run python vqa.py --help.

This will save in logs/vqa2 various files containing the rules found in the dataset, the question_ids for easy and counterexamples splits, and the predictions made by the rule model.

To evaluate predictions, you can use the multimodal library:

pip install multimodal
python -m multimodal vqa2-eval -p logs/vqa2/rules_predictions.json --split val

Other task

fit

You can use our library to extract rule for any other dataset.

To do so, you can use the fit function in our rule_mining.py It takes the following arguments : fit(dataset, answer_ids, gminer_support=0.01, gminer_max_length=0, gminer_path=None), where :

  • dataset is a list of transactions. Each transaction is a list of integers describing tokens.
  • answer_ids is a list of integers, describing answer ids. They should be contained between 0 and max answer id.
  • gminer_support is the minimum support used to mine frequent itemset.
  • gminer_max_length: minimum length of an itemset. By default no minimum length
  • gminer_path: path to the gminer binary you compiled (see top of the readme).

The function returns a list of rules, contained in namedtuples: Rule = namedtuple("Rule", ["itemset", "ans", "sup", "conf"]).

The itemset contains the input token ids, ans is the answer id, sup and conf are the support and the confidence of this rule.

match_rules

We provide a function to get, for each example in your dataset, all rules matching its input.

match_rules(dataset, rules, answers=None, bsize=500)

This will return (matching_rules, correct_rules), where matching_rules is a list of the same length as the dataset, giving for each example, the matching rules.

You can use this to build your counterexamples subset (examples where all rules are incorrect), or your easy subset (where at least one rule is correct).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].