Upload folder using huggingface_hub
Browse files- README.md +60 -0
- config.json +15 -0
- model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch
|
| 5 |
+
- image-classification
|
| 6 |
+
- robust-representation
|
| 7 |
+
- modular-ai
|
| 8 |
+
- dynamic-masking
|
| 9 |
+
- dinov2
|
| 10 |
+
- ifam
|
| 11 |
+
arxiv: 2506.08915
|
| 12 |
+
library_name: generic
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# iFAM (imagenet-k1) Model Checkpoint
|
| 16 |
+
|
| 17 |
+
This is the official pre-trained checkpoint of the **iFAM (Inherently Faithful Attention Maps for Vision Transformers)** framework, proposed in the paper **"Two-stage Vision Transformers and Hard Masking offer Robust Object Representations"** (accepted as an oral presentation at ICPR 2026).
|
| 18 |
+
|
| 19 |
+
- **Paper:** [Two-stage Vision Transformers and Hard Masking offer Robust Object Representations](https://arxiv.org/abs/2506.08915)
|
| 20 |
+
- **Repository:** [GitHub - ananthu-aniraj/ifam](https://github.com/ananthu-aniraj/ifam)
|
| 21 |
+
|
| 22 |
+
## Model Description
|
| 23 |
+
iFAM model trained on the ImageNet-1K dataset with 1 part (K=1).
|
| 24 |
+
|
| 25 |
+
The iFAM framework is a two-stage approach:
|
| 26 |
+
1. **Stage 1 (Selector):** Processes the full image to discover object parts and identify task-relevant regions.
|
| 27 |
+
2. **Stage 2 (Predictor):** Restricts its receptive field to the selected regions using input attention masking, preventing spurious background details from affecting the classification.
|
| 28 |
+
|
| 29 |
+
## Usage
|
| 30 |
+
|
| 31 |
+
To use this model, ensure you have the `ifam` repository cloned and the dependencies installed. You can load this model directly from the Hugging Face Hub:
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
import torch
|
| 35 |
+
import sys
|
| 36 |
+
# Append the path to the ifam repository
|
| 37 |
+
sys.path.append("/path/to/ifam")
|
| 38 |
+
|
| 39 |
+
from models import FullTwoStageModelDoubleClassify
|
| 40 |
+
|
| 41 |
+
# Load the model directly from Hugging Face Hub
|
| 42 |
+
model = FullTwoStageModelDoubleClassify.from_pretrained("ananthu-aniraj/ifam-imagenet-k1")
|
| 43 |
+
model.eval()
|
| 44 |
+
|
| 45 |
+
# Example: Run inference
|
| 46 |
+
# x = torch.rand(1, 3, 224, 224)
|
| 47 |
+
# with torch.no_grad():
|
| 48 |
+
# outputs = model(x)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Citation
|
| 52 |
+
If you use this model in your research, please cite:
|
| 53 |
+
```bibtex
|
| 54 |
+
@inproceedings{aniraj2026ifam,
|
| 55 |
+
title={Two-stage Vision Transformers and Hard Masking offer Robust Object Representations},
|
| 56 |
+
author={Aniraj, Ananthu and Dantas, Cassio F. and Ienco, Dino and Marcos, Diego},
|
| 57 |
+
booktitle={International Conference on Pattern Recognition (ICPR)},
|
| 58 |
+
year={2026}
|
| 59 |
+
}
|
| 60 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"gumbel_softmax": true,
|
| 3 |
+
"img_size": 224,
|
| 4 |
+
"init_model_stage_1": null,
|
| 5 |
+
"init_model_stage_2": null,
|
| 6 |
+
"model_arch": "vit_base_patch14_reg4_dinov2.lvd142m",
|
| 7 |
+
"num_classes": 1000,
|
| 8 |
+
"num_landmarks": 1,
|
| 9 |
+
"part_dropout": 0.3,
|
| 10 |
+
"part_dropout_stage_2": 0.3,
|
| 11 |
+
"part_logits_threshold": null,
|
| 12 |
+
"return_transformer_qkv": false,
|
| 13 |
+
"softmax_temperature": 1.0,
|
| 14 |
+
"use_soft_masks": false
|
| 15 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:775cb2d703bd93db1a29488b6a6bae855d62c0b19b9f054f1511ed9675d71d51
|
| 3 |
+
size 692022348
|