Visual Question Answering
Transformers
Safetensors
fga
visual-dialog
visdial
multimodal
attention
factor-graph-attention
Eval Results (legacy)
Instructions to use Idan/fga with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Idan/fga with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "visual-question-answering" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("visual-question-answering", model="Idan/fga")# pip install -U transformers accelerate # Load model directly from transformers import FGAForVisualDialog model = FGAForVisualDialog.from_pretrained("Idan/fga", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add Factor Graph Attention weights (VisDial v1.0, MRR 66.01)
Browse files
README.md
CHANGED
|
@@ -129,18 +129,28 @@ Pass `output_attentions=True` to get the per-utility attention distributions for
|
|
| 129 |
visualization.
|
| 130 |
|
| 131 |
The attention block is the reusable part of the paper and knows nothing about Visual
|
| 132 |
-
Dialog —
|
| 133 |
|
| 134 |
```python
|
| 135 |
-
from fga
|
| 136 |
|
| 137 |
-
attention =
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
], use_prior=True)
|
| 142 |
```
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
## Data
|
| 145 |
|
| 146 |
Preprocessed dialogs: [`Idan/visdial-fga-preprocessed`](https://huggingface.co/datasets/Idan/visdial-fga-preprocessed).
|
|
|
|
| 129 |
visualization.
|
| 130 |
|
| 131 |
The attention block is the reusable part of the paper and knows nothing about Visual
|
| 132 |
+
Dialog — it is an ordinary `torch.nn` layer over any set of modalities:
|
| 133 |
|
| 134 |
```python
|
| 135 |
+
from fga import FactorGraphAttention, Modality
|
| 136 |
|
| 137 |
+
attention = FactorGraphAttention(embed_dims=[512, 2048], num_entities=[20, 36])
|
| 138 |
+
pooled_text, pooled_image = attention(text, image)
|
| 139 |
+
|
| 140 |
+
# or declared by name, with a repeated modality sharing factor weights
|
| 141 |
+
attention = FactorGraphAttention.from_modalities([
|
| 142 |
+
Modality("text", dim=512, size=20),
|
| 143 |
+
Modality("image", dim=2048, size=36),
|
| 144 |
+
Modality("history", dim=128, size=21, repeats=9, connected_to=("text", "image")),
|
| 145 |
], use_prior=True)
|
| 146 |
```
|
| 147 |
|
| 148 |
+
The same layer backs the paper's follow-ups in
|
| 149 |
+
[video dialog](https://github.com/idansc/simple-avsd),
|
| 150 |
+
[spatial navigation](https://github.com/barmayo/spatial_attention) and
|
| 151 |
+
[video retrieval](https://github.com/AmeenAli/VideoMatch); their argument names
|
| 152 |
+
(`util_e`, `sizes`, `high_order_utils`, `*_flag`) are all still accepted.
|
| 153 |
+
|
| 154 |
## Data
|
| 155 |
|
| 156 |
Preprocessed dialogs: [`Idan/visdial-fga-preprocessed`](https://huggingface.co/datasets/Idan/visdial-fga-preprocessed).
|