Skip to content

Menu

WorksComputer Science

CARE: Constrained Attention Refinement for Fine-Grained Visual Classification via Teacher-Student Distillation

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_dnkxnhez. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

Fine-grained visual classification requires models to recognize subtle local traits while exposing the visual evidence behind their predictions. Class-specific attention pathways provide a natural basis for interpretable recognition, but their constrained prediction structure limits discriminative capacity and underuses intermediate representations from strong pretrained backbones. To address this problem, we propose CARE, a constrained attention refinement framework for interpretable fine-grained recognition via teacher-student distillation. CARE keeps the final prediction and explanation within a class-specific attention student, while introducing a training-only auxiliary query teacher that reads selected intermediate DINOv2 layers with learnable queries. The teacher fuses multi-level representations and transfers logit-standardized class-discriminative knowledge to the student. To further refine the explanation pathway, we design diversity and sparsity terms to regularize student attention heads, reducing redundancy and encouraging compact trait localization. Experiments on CUB, Oxford-IIIT Pet, Stanford Dogs, and Stanford Cars show that CARE achieves strong classification performance under an interpretable frozen-backbone setting, reaching 78.5% Top-1 accuracy on CUB. Faithfulness analysis with insertion and deletion metrics further indicates that the top-ranked attention regions retain class-relevant evidence for explanation.

Introduction

Fine-grained visual classification (FGVC) aims to separate categories that differ in subtle local cues, including species, breeds, and object subtypes. In biodiversity monitoring, industrial inspection, and medical image analysis, a small visual detail may determine the correct category. Models used in these settings therefore need to expose the visual evidence behind their predictions, rather than rely on background bias or holistic shortcuts [13, 6].

Vision Transformers (ViTs) are strong backbones for FGVC because their token interactions capture both local parts and global context [5, 14, 6]. Self-supervised models such as DINO and DINOv2 further provide transferable frozen representations for downstream recognition tasks [2, 16]. Post-hoc attribution methods can explain decisions after a predictive model has been trained, but they do not require the classifier to use trait-level evidence when making predictions [20, 1, 3]. Intrinsically interpretable models connect prediction and explanation more directly, although they often introduce additional structures that are not always suitable for lightweight adaptation of frozen ViT backbones [18, 15].

Visual Prompt Tuning (VPT) adapts frozen ViTs with learnable visual prompt tokens and provides a parameter-efficient alternative to full fine-tuning [8]. Its focus, however, is mainly on recognition performance, and it does not provide class-specific visual explanations. Prompt-CAM extends prompt-based adaptation to intrinsic interpretability by using class-specific prompt outputs for prediction, with prompt-to-patch attention maps serving as class-level explanations [4]. This design is efficient and compatible with frozen ViTs, but prediction is still limited to final-layer prompt representations and a shared scoring head. As a result, it may not fully use intermediate Transformer representations that contain complementary local, part-level, and semantic evidence.

We propose CARE, a constrained attention refinement framework for interpretable fine-grained recognition. CARE keeps a class-specific prompt-attention student as the final prediction and explanation pathway, and improves it through training supervision. Diversity and sparsity losses regularize the student attention heads to reduce redundancy and encourage compact trait localization. A training-only auxiliary query teacher reads selected intermediate DINOv2 layers and transfers multi-level discriminative knowledge to the student through logit-standardized knowledge distillation (KD) [7, 21]. During inference, the teacher branch is removed, so prediction and explanation are produced by the student alone. Our contributions are summarized as follows:

  • We formulate constrained attention refinement for interpretable FGVC, aiming to improve discriminative capacity while keeping prediction and explanation within a class-specific attention pathway.

  • We introduce a training-only auxiliary query teacher that reads multi-level DINOv2 representations and distills logit-standardized class-discriminative knowledge to the student.

  • We apply diversity and sparsity regularization to student attention heads, reducing redundancy and encouraging compact localization of fine-grained traits.

  • We evaluate CARE on CUB, Oxford-IIIT Pet, Stanford Dogs, and Stanford Cars using classification accuracy, insertion/deletion faithfulness, component ablations, and teacher-layer analysis.

Related Work

Fine-grained visual classification. FGVC distinguishes visually similar categories using subtle local traits. Early methods relied on part localization, bilinear interactions, or region modeling [28, 13]. Transformers reduce the need for handcrafted part modeling by representing images as patch tokens [5, 22, 14], and TransFG adapts ViTs to FGVC through discriminative token selection [6]. Furthermore, self-supervised foundation models such as DINO and DINOv2 provide strong frozen representations for downstream recognition [2, 16]. Our work studies how to exploit multi-level DINOv2 representations while preserving class-specific visual evidence for interpretable fine-grained recognition.

Prompt learning and parameter-efficient adaptation. Prompt learning adapts pretrained models with a small number of trainable parameters. VPT introduces visual prompts into frozen ViTs [8], while CoOp and MaPLe adapt vision-language models with learned prompts [30, 10]. Recent work on PEFT further improves prompt-based adaptation [19]. These methods mainly target recognition performance rather than intrinsic explanation. Prompt-CAM extends prompt-based adaptation by using class-specific prompts for both prediction and explanation [4]. In contrast, CARE focuses on refining the class-specific attention pathway through attention regularization and training-only teacher-student distillation.

Visual attribution and interpretability. Post-hoc methods such as Grad-CAM, Attention Rollout, and Transformer attribution explain trained classifiers after the decision function has been learned [20, 1, 3]. They are useful diagnostic tools, but they do not require the classifier itself to rely on interpretable visual evidence. Intrinsic methods instead build explanation structures into the model. MCTformer uses class tokens for localization [26], ProtoTree and ProtoPFormer use prototype reasoning [15, 27], and INTR uses class-specific queries in an encoder–decoder architecture [18]. Class-specific prompt-attention models offer a simpler and more parameter-efficient form of intrinsic explanation, but their constrained prediction pathway can limit discriminative capacity. CARE addresses this limitation by preserving the attention-based explanation pathway while strengthening it with multi-level teacher supervision.

Knowledge distillation and intermediate representations. Knowledge distillation transfers softened outputs or intermediate features from a teacher to a student [7]. Decoupled distillation and logit standardization further refine the transferred signal [29, 21]. In ViTs, intermediate layers encode complementary cues, ranging from local patterns to semantic abstractions. Visual Query Tuning shows that learnable queries can access such representations efficiently [24]. Inspired by this idea, the Auxiliary Query Teacher in CARE reads selected DINOv2 layers, produces teacher logits, and transfers multi-level discriminative knowledge to the Constrained Attention Student only during training.

Methodology

Overview

Given an input image x\mathbf{x} and label y∈{1,…,C}y \in\{1,\ldots,C\}, our goal is to strengthen the discriminative capacity of a class-specific attention pathway while preserving it as the final prediction and explanation source. Figure 1 shows the proposed CARE framework, which is built on a frozen DINOv2 Vision Transformer [16]. During training, CARE contains two branches: (a) a Constrained Attention Student for prediction and explanation, and (b) a training-only Auxiliary Query Teacher for multi-layer distillation.

Figure 1. Overall architecture of CARE. The framework consists of (a) a Constrained Attention Student branch for prediction and explanation, and (b) a training-only Auxiliary Query Teacher branch for multi-layer distillation.

The Constrained Attention Student follows a class-specific prompt-attention design for prediction and explanation. Class-specific prompt outputs are scored by a shared vector to produce logits, and the corresponding prompt-to-patch multi-head attention maps are used as class-specific explanations. We regularize these maps with diversity and sparsity losses to reduce redundancy across heads and encourage more compact localization. This keeps the explanation source tied to the same class-specific pathway used for prediction. The Auxiliary Query Teacher is introduced to exploit hierarchical evidence that may not be fully represented by the final student prompt outputs. It reads features from selected intermediate layers, where cues such as local structure, part boundaries, texture, and higher-level semantics are useful for fine-grained recognition.

The frozen backbone extracts both intermediate and final-layer features. The student produces logits and attention maps through the final class-specific attention pathway. In parallel, the teacher uses learnable query tokens to read selected intermediate layers, fuses the query-conditioned readouts, and predicts teacher logits. These logits supervise the student through logit-standardized KD [7, 21]. At inference, the teacher branch is removed, and the student alone provides both prediction and explanation.

Constrained Attention Student Branch

The student branch follows the class-specific prompt-attention principle of Prompt-CAM [4]. Instead of using a generic CLS-token classifier, class-specific prompt tokens are used to compute category scores from their corresponding prompt outputs. The same prompts also query image patches through attention, so the prompt-to-patch attention maps can be used as class-specific visual evidence.

Let FθF_\theta denote the frozen DINOv2 ViT with NN Transformer layers. The input image xx is mapped to patch tokens E0∈RM×D\mathbf{E}_0 \in\mathbb{R}^{M \times D}, where MM is the number of image patches and DD is the hidden dimension. We introduce class-specific prompt tokens P=[p1,…,pC]T∈RC×D\mathbf{P} = [\mathbf{p}^{1}, \ldots, \mathbf{p}^{C}]^{\mathsf{T}} \in\mathbb{R}^{C \times D}, where pc∈RD\mathbf{p}^{c} \in\mathbb{R}^{D} is the learnable prompt token for class cc. After the final Transformer layer, the class prompt outputs are ZNs=[zNs,1,…,zNs,C]T∈RC×D\mathbf{Z}_{N}^{s} = [\mathbf{z}_{N}^{s,1}, \ldots, \mathbf{z}_{N}^{s,C}]^{\mathsf{T}} \in\mathbb{R}^{C \times D}.

A shared scoring vector ws∈RD\mathbf{w}_{s} \in\mathbb{R}^{D} and bias bs∈Rb_{s} \in\mathbb{R} map each class prompt to a scalar logit:

scs=wsTzNs,c+bs,c=1,…,C.(1)s_{c}^{s} = \mathbf{w}_{s}^{\mathsf{T}}\mathbf{z}_{N}^{s,c} + b_{s}, \qquad c = 1,\ldots,C. \tag*{(1)}

The student logit vector and classification loss are

ss=[s1s,…,sCs]T∈RC,Lclss=−log⁡exp⁡(sys)∑c=1Cexp⁡(scs).(2)\mathbf{s}^{s} = [s_{1}^{s},\ldots,s_{C}^{s}]^{\mathsf{T}} \in\mathbb{R}^{C}, \qquad\mathcal{L}_{\mathrm{cls}}^{s} = -\log\frac{\exp(s_{y}^{s})}{\sum_{c=1}^{C}\exp(s_{c}^{s})}. \tag*{(2)}

For class cc and attention head rr, let αc,r∈RM\alpha^{c,r} \in\mathbb{R}^{M} denote the final-layer prompt-to-patch attention map over image patches. With RR attention heads, the attention-map set for class cc is Ac={αc,r}r=1R\mathcal{A}^{c} = \{\alpha^{c,r}\}_{r=1}^{R}. The Constrained Attention Student keeps the class-specific prediction pathway and adds Ldiv\mathcal{L}_{\mathrm{div}} and Lsp\mathcal{L}_{\mathrm{sp}} to regularize the student attention maps.

Auxiliary Query Teacher Branch

The Auxiliary Query Teacher reads features from selected layers of the frozen backbone. Let the frozen backbone contain NN Transformer layers indexed as ℓ0,ℓ1,…,ℓN−1\ell_{0}, \ell_{1}, \ldots, \ell_{N-1}. The selected teacher-layer set is denoted as S={ℓi,ℓj,ℓk}\mathcal{S} = \{\ell_{i}, \ell_{j}, \ell_{k}\}, where $0 \leq i < j < k \leq N - 1$. Unless otherwise stated, we use the zero-based DINOv2 layer indices {4,8,11}\{4, 8, 11\}.

For layer ℓ∈S\ell\in\mathcal{S}, the context tokens are Hℓ=[hℓ1,…,hℓMℓ]T∈RMℓ×D\mathbf{H}_{\ell} = [\mathbf{h}_{\ell}^{1}, \ldots, \mathbf{h}_{\ell}^{M_{\ell}}]^{\mathsf{T}} \in\mathbb{R}^{M_{\ell} \times D}, where MℓM_{\ell} denotes the number of context tokens available to the teacher branch. These tokens contain the intermediate non-prompt representations produced by the frozen backbone.

We introduce NqN_{q} learnable query tokens Uℓ∈RNq×D\mathbf{U}_{\ell} \in\mathbb{R}^{N_{q} \times D} for each selected layer, with Nq=8N_{q} = 8 in the main configuration. The query, key, and value matrices are

Qℓ=UℓWℓQ,Kℓ=HℓWℓK,Vℓ=HℓWℓV,(3)\mathbf{Q}_{\ell} = \mathbf{U}_{\ell}\mathbf{W}_{\ell}^{Q}, \qquad\mathbf{K}_{\ell} = \mathbf{H}_{\ell}\mathbf{W}_{\ell}^{K}, \qquad\mathbf{V}_{\ell} = \mathbf{H}_{\ell}\mathbf{W}_{\ell}^{V}, \tag*{(3)}

where WℓQ,WℓK,WℓV∈RD×D\mathbf{W}^{Q}_{\ell}, \mathbf{W}^{K}_{\ell}, \mathbf{W}^{V}_{\ell} \in\mathbb{R}^{D \times D}. The layer-wise cross-attention matrix is

Aℓ=softmax⁡ctx(QℓKℓ⊤D)∈RNq×Mℓ,(4)\mathbf{A}_{\ell} = \operatorname{softmax}_{\mathrm{ctx}}\left(\frac{\mathbf{Q}_{\ell}\mathbf{K}_{\ell}^{\top}}{\sqrt{D}}\right) \in\mathbb{R}^{N_q \times M_{\ell}}, \tag*{(4)}

where the softmax is applied over the context-token dimension. Equivalently,

Aℓ,q,m=exp⁡(⟨Qℓq,Kℓm⟩/D)∑m′=1Mℓexp⁡(⟨Qℓq,Kℓm′⟩/D).(5)A_{\ell,q,m} = \frac{\exp(\langle\mathbf{Q}_{\ell}^{q}, \mathbf{K}_{\ell}^{m}\rangle/\sqrt{D})}{\sum_{m'=1}^{M_{\ell}} \exp(\langle\mathbf{Q}_{\ell}^{q}, \mathbf{K}_{\ell}^{m'}\rangle/\sqrt{D})}. \tag*{(5)}

The query-conditioned readout is

Rℓ=AℓVℓ∈RNq×D.(6)\mathbf{R}_{\ell} = \mathbf{A}_{\ell}\mathbf{V}_{\ell} \in\mathbb{R}^{N_q \times D}. \tag*{(6)}

In implementation, this readout is realized as a residual multi-head cross-attention module followed by a lightweight feed-forward network, and the readout dimension is kept the same as the backbone embedding dimension.

We average the query readouts and fuse the selected layers:

ρ(Rℓ)=1Nq∑q=1NqRℓq,g=ϕ(Concat⁡[ρ(Rℓi),ρ(Rℓj),ρ(Rℓk)]),(7)\rho(\mathbf{R}_{\ell}) = \frac{1}{N_q}\sum_{q=1}^{N_q}\mathbf{R}_{\ell}^{q}, \qquad\mathbf{g} = \phi\left(\operatorname{Concat}[\rho(\mathbf{R}_{\ell_i}), \rho(\mathbf{R}_{\ell_j}), \rho(\mathbf{R}_{\ell_k})]\right), \tag*{(7)}

where ρ(Rℓ)∈RD\rho(\mathbf{R}_{\ell}) \in\mathbb{R}^{D}, ϕ:R3D→RD\phi: \mathbb{R}^{3D} \to\mathbb{R}^{D} is a lightweight fusion MLP, and g∈RD\mathbf{g} \in\mathbb{R}^{D} is the fused teacher representation.

The teacher logits and auxiliary loss are

st=Wtg+bt,Laux=−log⁡exp⁡(syt)∑c=1Cexp⁡(sct).(8)\mathbf{s}^{t} = \mathbf{W}_{t}\mathbf{g} + \mathbf{b}_{t}, \qquad\mathcal{L}_{\mathrm{aux}} = -\log\frac{\exp(s^{t}_{y})}{\sum_{c=1}^{C}\exp(s^{t}_{c})}. \tag*{(8)}

Here, Wt∈RC×D\mathbf{W}_{t} \in\mathbb{R}^{C \times D}, bt∈RC\mathbf{b}_{t} \in\mathbb{R}^{C}, and st∈RC\mathbf{s}^{t} \in\mathbb{R}^{C}. The teacher branch is used only for training-time supervision and is not used as the explanation source.

Logit-Standardized Knowledge Distillation

Teacher and student logits may have different scales, so we standardize them before distillation [21]. For s∈RC\mathbf{s} \in\mathbb{R}^{C},

s^=s−μ(s)1σ(s)+ϵ,μ(s)=1C∑j=1Csj,σ(s)=(1C∑j=1C(sj−μ(s))2)1/2.(9)\hat{\mathbf{s}} = \frac{\mathbf{s} - \mu(\mathbf{s})\mathbf{1}}{\sigma(\mathbf{s}) + \epsilon}, \qquad\mu(\mathbf{s}) = \frac{1}{C}\sum_{j=1}^{C}s_j, \qquad\sigma(\mathbf{s}) = \left(\frac{1}{C}\sum_{j=1}^{C}(s_j-\mu(\mathbf{s}))^2\right)^{1/2}. \tag*{(9)}

Here, 1∈RC\mathbf{1} \in\mathbb{R}^{C} is an all-one vector and ϵ\epsilon is a small constant for numerical stability. The standardized teacher and student distributions are

qt=softmax⁡(sg⁡(s^t)T),qs=softmax⁡(s^sT),(10)\mathbf{q}^{t} = \operatorname{softmax}\left(\frac{\operatorname{sg}(\hat{\mathbf{s}}^{t})}{T}\right), \qquad\mathbf{q}^{s} = \operatorname{softmax}\left(\frac{\hat{\mathbf{s}}^{s}}{T}\right), \tag*{(10)}

where T>0T > 0 is the distillation temperature, qt,qs∈RC\mathbf{q}^{t}, \mathbf{q}^{s} \in\mathbb{R}^{C} are probability distributions, and sg⁡(⋅)\operatorname{sg}(\cdot) denotes stop-gradient. Thus, the KD term transfers knowledge from the teacher to the student without updating the teacher through the distillation loss.

The KL divergence and KD loss are defined as:

KL⁡(qt∥qs)=∑c=1Cqctlog⁡(qct+ϵqcs+ϵ),LKD=T2KL⁡(qt∥qs).(11)\operatorname{KL}(\mathbf{q}^{t} \mathbin\Vert\mathbf{q}^{s}) = \sum_{c=1}^{C} q_{c}^{t} \log\left(\frac{q_{c}^{t}+\epsilon}{q_{c}^{s}+\epsilon}\right), \qquad\mathcal{L}_{\mathrm{KD}} = T^{2}\operatorname{KL}(\mathbf{q}^{t} \mathbin\Vert\mathbf{q}^{s}). \tag*{(11)}

This loss transfers the teacher’s relative class distribution to the Constrained Attention Student.

Attention Diversity and Sparsity Regularization

For the ground-truth class yy, the normalized attention map of head rr is

α~y,r=αy,r∑m=1Mαmy,r+ϵ∈RM,(12)\widetilde{\boldsymbol{\alpha}}^{y,r} = \frac{\boldsymbol{\alpha}^{y,r}}{\sum_{m=1}^{M}\alpha_{m}^{y,r}+\epsilon} \in\mathbb{R}^{M}, \tag*{(12)}

where αmy,r\alpha_{m}^{y,r} denotes the attention value on patch mm and ϵ\epsilon is a small constant. The diversity loss is the average pairwise cosine similarity between different heads:

Ldiv=1R(R−1)∑r,r′=1r≠r′R(α~y,r)Tα~y,r′∥α~y,r∥2∥α~y,r′∥2+ϵ.(13)\mathcal{L}_{\mathrm{div}} = \frac{1}{R(R-1)}\sum_{\substack{r,r'=1 \\ r\ne r'}}^{R}\frac{\left(\widetilde{\boldsymbol{\alpha}}^{y,r}\right)^{\mathsf{T}}\widetilde{\boldsymbol{\alpha}}^{y,r'}}{\left\|\widetilde{\boldsymbol{\alpha}}^{y,r}\right\|_{2}\left\|\widetilde{\boldsymbol{\alpha}}^{y,r'}\right\|_{2}+\epsilon}. \tag*{(13)}

For sparsity, we first select the top-kk attention heads of the ground-truth class and then regularize their entropy. The head-selection score is defined by the maximum prompt-to-patch attention response:

ηry=max⁡m∈{1,…,M}αmy,r.(14)\eta_{r}^{y} = \max_{m\in\{1,\ldots,M\}}\alpha_{m}^{y,r}. \tag*{(14)}

The selected head index set is

Iky=TopK⁡r∈{1,…,R}(sg⁡(ηry),k),(15)\mathcal{I}_{k}^{y} = \operatorname{TopK}_{r\in\{1,\ldots,R\}}\left(\operatorname{sg}\left(\eta_{r}^{y}\right), k\right), \tag*{(15)}

where sg⁡(⋅)\operatorname{sg}(\cdot) denotes stop-gradient. The discrete top-kk operation determines which heads are regularized, while gradients are back-propagated through the selected attention maps.

The sparsity loss is the normalized entropy of the selected heads:

Lsp=1∣Iky∣∑r∈IkyH(α~y,r)log⁡M.(16)\mathcal{L}_{\mathrm{sp}} = \frac{1}{\left|\mathcal{I}_{k}^{y}\right|}\sum_{r\in\mathcal{I}_{k}^{y}}\frac{\mathcal{H}\left(\widetilde{\boldsymbol{\alpha}}^{y,r}\right)}{\log M}. \tag*{(16)}

where

H(α~y,r)=−∑m=1Mα~my,rlog⁡(α~my,r+ϵ).(17)\mathcal{H}\left(\widetilde{\boldsymbol{\alpha}}^{y,r}\right) = -\sum_{m=1}^{M}\widetilde{\alpha}_{m}^{y,r}\log\left(\widetilde{\alpha}_{m}^{y,r}+\epsilon\right). \tag*{(17)}

Both regularizers act directly on the Constrained Attention Student attention maps.

Overall Objective and Training

The total objective is

Ltotal=Lclss+λauxLaux+λKDLKD+λdivLdiv+λspLsp.(18)\mathcal{L}_{\mathrm{total}} = \mathcal{L}_{\mathrm{cls}}^{s} + \lambda_{\mathrm{aux}}\mathcal{L}_{\mathrm{aux}} + \lambda_{\mathrm{KD}}\mathcal{L}_{\mathrm{KD}} + \lambda_{\mathrm{div}}\mathcal{L}_{\mathrm{div}} + \lambda_{\mathrm{sp}}\mathcal{L}_{\mathrm{sp}}. \tag*{(18)}

Here, λaux\lambda_{\mathrm{aux}}, λKD\lambda_{\mathrm{KD}}, λdiv\lambda_{\mathrm{div}}, and λsp\lambda_{\mathrm{sp}} are scalar loss weights. The attention regularizers do not introduce additional trainable parameters; they only impose constraints on student attention maps. The trainable parameters include the class-specific prompt tokens, the shared student scoring head, and the Auxiliary Query Teacher branch, while the DINOv2 backbone remains frozen. During inference, the final prediction and explanation are produced by the Constrained Attention Student branch, and the Auxiliary Query Teacher is removed.

Experiments

Datasets and Implementation Details

Datasets We evaluate CARE on CUB-200-2011 [23], Stanford Dogs [11], Oxford-IIIT Pet [17], and Stanford Cars [12]. CUB is used for ablation studies, teacher-layer selection, and hyperparameter analysis. The remaining datasets test whether the observed behavior transfers across different fine-grained domains.

Experimental settings All prompt-based models use a frozen DINOv2 ViT-B/14 backbone [16] with an input resolution of 224×224224 \times224. Unless otherwise stated, models are trained for 60 epochs with SGD, momentum 0.9, weight decay 0.001, batch size 64, learning rate 0.005, and 10 warm-up epochs. For CARE, we use zero-based teacher-layer indices {4,8,11}\{4, 8, 11\}, Nq=8N_q = 8, λaux=0.5\lambda_{\mathrm{aux}} = 0.5, λKD=1.0\lambda_{\mathrm{KD}} = 1.0, T=2.0T = 2.0, λdiv=0.05\lambda_{\mathrm{div}} = 0.05, λsp=0.01\lambda_{\mathrm{sp}} = 0.01, and k=4k = 4 for sparsity regularization.

Evaluation Metrics Classification performance is measured by Top-1 accuracy. For explanation faithfulness, we report insertion and deletion scores. Class-specific prompt-attention methods are evaluated using their intrinsic attention maps, while Grad-CAM, Layer-CAM, and Attention Rollout are evaluated on the DINOv2 Linear Probing classifier [20, 9, 1].

Baselines We compare CARE with both recognition-oriented and interpretable baselines. DINOv2 Linear Probing is included as a recognition-oriented reference with a frozen ViT-B/14 backbone and a linear head. For interpretable fine-grained recognition, we compare with INTR [18], ProtoTree [15], TesNet [25], and the class-specific prompt-attention baseline Prompt-CAM [4]. Unless otherwise stated, Linear Probing, Prompt-CAM, and CARE are evaluated under the same frozen DINOv2 setting, while the remaining interpretable baseline results follow the corresponding published reports. Prompt-CAM is the closest baseline, while CARE further introduces constrained attention refinement with training-only teacher-student distillation.

Main Results

The classification results show that CARE consistently improves the class-specific prompt-attention baseline across all four fine-grained benchmarks, as reported in Table 1. Compared with Prompt-CAM, CARE increases Top-1 accuracy from 74.1% to 78.5% on CUB, from 81.3% to 81.9% on Stanford Dogs, from 92.7% to 93.6% on Oxford-IIIT Pet, and from 84.3% to 87.1% on Stanford Cars.

DatasetLinear ProbingINTRProtoTreeTesNetPrompt-CAMCARE
CUB89.671.868.577.774.178.5
Dog87.372.568.476.581.381.9
Pet96.290.4––92.793.6
Cars88.286.870.084.684.387.1

Table 1. Top-1 classification accuracy (%) on four fine-grained recognition benchmarks. Gray values denote recognition-oriented Linear Probing results provided for reference. Bold indicates the best result among the compared interpretable methods.

These gains suggest that the auxiliary query teacher and logit-standardized distillation improve the discriminative ability of the class-specific attention pathway while preserving its intrinsic explanation mechanism.

Faithfulness Analysis

Explanation faithfulness is evaluated with insertion and deletion scores under the two settings defined above: post-hoc explanations on the DINOv2 Linear Probing classifier and intrinsic attention maps from class-specific prompt-attention methods. All methods follow the same perturbation protocol. Saliency maps are upsampled to the image resolution, pixels are ranked by descending saliency, and each score is computed as the area under the target-class confidence curve over 50 perturbation steps. The quantitative results are reported in Table 2.

(a) Post-hoc methods on CUB(b) Class-specific prompt-attention methods
MethodIns.↑Del.↓MethodCUB Ins.↑CUB Del.↓Pet Ins.↑Pet Del.↓Dog Ins.↑Dog Del.↓
Grad-CAM0.610.17Prompt-CAM0.780.130.790.400.680.31
Layer-CAM0.770.28Prompt-CAM + Reg.0.850.15––––
Att. Rollout0.730.28CARE0.860.160.860.390.830.29

Table 2. Insertion/deletion faithfulness evaluation under post-hoc and class-specific prompt-attention explanation settings. Prompt-CAM + Reg. denotes the student-only CARE variant with Ldiv+Lsp\mathcal{L}_{\mathrm{div}}+\mathcal{L}_{\mathrm{sp}}, without the Auxiliary Query Teacher or KD.

Under the intrinsic prompt-attention setting, CARE improves insertion over Prompt-CAM on CUB, Oxford-IIIT Pet, and Stanford Dogs. This suggests that the top-ranked attention regions selected by CARE contain more prediction-relevant evidence during the insertion process. On CUB, the regularization-only variant also improves insertion, indicating that diversity and sparsity constraints can improve the quality of selected-head evidence. Deletion results are more mixed: CARE is slightly worse than Prompt-CAM on CUB, but performs better on Oxford-IIIT Pet and Stanford Dogs. The corresponding insertion and deletion curves are shown in Figure 2.

Insertion and deletion curves on CUBInsertion and deletion curves on Oxford-IIIT PetInsertion and deletion curves on Stanford Dogs

Figure 2. Insertion and deletion curve comparisons on CUB, Oxford-IIIT Pet, and Stanford Dogs. The CUB curves include Prompt-CAM, Prompt-CAM with diversity and sparsity attention regularization, and CARE. The Oxford-IIIT Pet and Stanford Dogs curves include Prompt-CAM and CARE.

Ablation Study

Component ablation. The component ablation on CUB examines how each part of CARE contributes to the final performance, including the Auxiliary Query Teacher, logit-standardized KD, and attention regularization, as reported in Table 3. The teacher-distillation variant improves the Prompt-CAM baseline from 74.1% to 78.3%, indicating that multi-level teacher supervision is the main source of the accuracy gain. In contrast, applying Ldiv\mathcal{L}_{\mathrm{div}} and Lsp\mathcal{L}_{\mathrm{sp}} without teacher supervision reduces accuracy to 73.4%, suggesting that attention regularization alone can over-constrain the class-specific attention pathway. When teacher-guided distillation and attention regularization are combined, accuracy reaches 78.5%, outperforming both the Prompt-CAM baseline and the teacher-only variant. This result suggests that multi-level teacher supervision and attention regularization play complementary roles in improving the Constrained Attention Student.

SettingTeacherKDReg.Top-1
Prompt-CAM–––74.1
CARE w/o Reg.✓✓–78.3
CARE w/o Teacher/KD––✓73.4
CARE✓✓✓78.5

Table 3. Component ablation study of CARE on the CUB dataset. The teacher branch includes Laux\mathcal{L}_{\mathrm{aux}} by default. CARE w/o Teacher/KD removes both the Auxiliary Query Teacher and KD, leaving only attention regularization on the student.

KD-weight sensitivity. Although the framework contains several loss weights, we focus the sensitivity analysis on λKD\lambda_{\mathrm{KD}} because it directly controls the strength of knowledge transfer from the Auxiliary Query Teacher to the Constrained Attention Student. The accuracy curve in Figure 3(a) shows that the best result is obtained at λKD=1.0\lambda_{\mathrm{KD}}=1.0, reaching 78.55% Top-1 accuracy on CUB. The faithfulness curves in Figure 3(b) show that insertion and deletion scores vary only slightly across the tested KD weights. We therefore use λKD=1.0\lambda_{\mathrm{KD}}=1.0 as the default setting in the main experiments.

Sensitivity analysis of the KD loss weight on CUB, showing classification accuracy and faithfulness scores

Figure 3. (a) Classification accuracy. (b) Faithfulness scores. Sensitivity analysis of the KD loss weight λKD\lambda_{\mathrm{KD}} on CUB. (a) reports Top-1 classification accuracy. (b) reports insertion and deletion faithfulness scores. All other hyperparameters are kept identical to the default CARE configuration.

Query Token Analysis

The number of learnable query tokens controls the readout capacity of the Auxiliary Query Teacher for multi-level feature aggregation. We analyze this factor on CUB by fixing the selected teacher-layer indices to {4,8,11}\{4, 8, 11\} and changing only

NqN_q, with Prompt-CAM included as the baseline without teacher query tokens. The results are reported in Table 4.

SettingNqN_qTop-1Train. ParamsTotal Params
Prompt-CAM–74.11.84M87.56M
CARE477.125.05M110.77M
CARE878.525.06M110.78M
CARE1676.725.07M110.79M

Table 4. Query-token analysis on the CUB dataset.

With Nq=4N_q = 4, CARE reaches 77.1% Top-1 accuracy, improving over Prompt-CAM but remaining below the default setting. This suggests that four query tokens may provide insufficient capacity to summarize intermediate representations. Increasing NqN_q to 8 raises accuracy to 78.5%, indicating that moderate query-token capacity helps the teacher extract multi-level evidence. Increasing NqN_q to 16 lowers accuracy to 76.7%, suggesting that excessive query tokens may introduce redundant or unstable readouts for distillation.

The parameter counts change only marginally across different values of NqN_q, so the accuracy differences mainly reflect teacher readout capacity rather than parameter scaling. We therefore use Nq=8N_q = 8 as the default setting.

Selecting Complementary Teacher Layers

The selected teacher-layer indices control the depth distribution of the multi-level supervision provided by the Auxiliary Query Teacher. As reported in Table 5, the zero-based index combination {4,8,11}\{4, 8, 11\} achieves the best accuracy, while changing the early, middle, or late layer reduces performance. This suggests that the teacher branch benefits from complementary representations across different Transformer depths.

Teacher indicesTop-1
4, 8, 1178.5
5, 8, 1176.9
4, 7, 1176.7
4, 9, 1176.6
3, 7, 1077.1

Table 5. Layer combination study on the CUB dataset.

This pattern is consistent with the hierarchy of ViT features: earlier layers preserve local appearance cues, middle layers provide part-level structure, and deeper layers encode semantic information. The {4, 8, 11} combination therefore provides a more balanced teacher signal than alternatives at similar depths.

Qualitative Discussion

Qualitative visualizations are used to examine whether the refined class-specific attention maps highlight meaningful fine-grained regions across CUB, Oxford-IIIT Pet, Stanford Dogs, and Stanford Cars, as shown in Figure 4. Prompt-CAM and CARE follow the same visualization protocol for selecting the displayed attention heads. Specifically, we adopt the iterative head-pruning procedure used by the Prompt-CAM baseline: at each step, one candidate head is replaced by a uniform attention pattern, the model is re-evaluated, and the head whose removal causes the smallest decrease in target-class confidence is pruned. The four remaining heads are visualized as trait-level attention maps. This visualization-time selection is separate from the training-time sparsity regularization in § 3.5.

Visualization of class-specific attention maps from the top-4 attention heads on CUB, Oxford-IIIT Pet, Stanford Dogs, and Stanford Cars

Figure 4. Visualization of class-specific attention maps from the top-4 attention heads on CUB, Oxford-IIIT Pet, Stanford Dogs, and Stanford Cars.

The selected heads generally correspond to semantically meaningful fine-grained regions, such as the head, beak, neck, ears, or other object-specific local parts. Since the heads are selected according to their contribution to target-class confidence rather than human visual preference, some maps may still contain contextual or diffuse responses. Compared with Prompt-CAM, CARE produces more compact and less redundant attention patterns in many examples. This qualitative behavior is consistent with the insertion/deletion results and supports the role of attention regularization in refining class-specific localization.

Limitations and Discussion

CARE has two main limitations. First, the Auxiliary Query Teacher introduces additional training-time parameters and computational overhead, mainly from the learnable query tokens, multi-layer query readout, feature fusion, and teacher classifier. However, the teacher branch is discarded during inference, so the additional cost does not affect the deployed student model. Second, our experiments are conducted primarily on natural fine-grained datasets. Applying CARE to domains such as medical or industrial imagery requires further evaluation under domain-specific variations, robustness requirements, and reliability constraints.

Conclusion

We presented CARE, a constrained attention refinement framework for faithful fine-grained visual classification. CARE uses a Constrained Attention Student and a training-only Auxiliary Query Teacher to transfer multi-level discriminative knowledge while preserving class-specific attention as the prediction and explanation source. Experiments on four fine-grained benchmarks show consistent accuracy gains over the class-specific prompt-attention baseline and competitive faithfulness results, indicating that teacher-student distillation and attention regularization can strengthen the interpretable attention pathway without replacing its intrinsic localization mechanism.

Acknowledgements

This work was supported in part by the National Natural Science Foundation of China (No. 62306075) and the Natural Science Foundation of Shandong Province (No. ZR2026QC0725).

References

  1. [1]Abnar, S., Zuidema, W.: Quantifying attention flow in transformers. In: Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics. pp. 4190–4197 (2020)arxiv.org/abs/2005.00928
  2. [2]Caron, M., Touvron, H., Misra, I., Jégou, H., Mairal, J., Bojanowski, P., Joulin, A.: Emerging properties in self-supervised vision transformers. In: Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV). pp. 9650–9660 (2021)arxiv.org/abs/2104.14294
  3. [3]Chefer, H., Gur, S., Wolf, L.: Transformer interpretability beyond attention visualization. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 782–791 (2021)arxiv.org/abs/2012.09838
  4. [4]Chowdhury, A., Paul, D., Mai, Z., Gu, J., Zhang, Z., Mehrab, K.S., Campolongo, E.G., Rubenstein, D., Stewart, C.V., Karpate, A., Berger-Wolf, T., Su, Y., Chao, W.L.: Prompt-CAM: Making vision transformers interpretable for fine-grained analysis. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 4375–4385 (2025)arxiv.org/abs/2501.09333
  5. [5]Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., Uszkoreit, J., Houlsby, N.: An image is worth 16x16 words: Transformers for image recognition at scale. In: International Conference on Learning Representations (ICLR) (2021)
  6. [6]He, J., Chen, J.N., Liu, S., Kortylewski, A., Yang, C., Bai, Y., Wang, C.: Transfg: A transformer architecture for fine-grained recognition. In: Proceedings of the AAAI Conference on Artificial Intelligence. vol. 36, pp. 852–860 (2022)arxiv.org/abs/2103.07976
  7. [7]Hinton, G., Vinyals, O., Dean, J.: Distilling the knowledge in a neural network. In: NIPS Deep Learning and Representation Learning Workshop (2015)arxiv.org/abs/1503.02531
  8. [8]Jia, M., Tang, L., Chen, B.C., Cardie, C., Belongie, S., Hariharan, B., Lim, S.N.: Visual prompt tuning. In: Proceedings of the European Conference on Computer Vision (ECCV). pp. 709–727 (2022)arxiv.org/abs/2203.12119
  9. [9]Jiang, P.T., Zhang, C.B., Hou, Q., Cheng, M.M., Wei, Y.: Layercam: Exploring hierarchical class activation maps for localization. IEEE Transactions on Image Processing 30, 5875–5888 (2021)DOI
  10. [10]Khattak, M.U., Rasheed, H., Maaz, M., Khan, S., Khan, F.S.: Maple: Multi-modal prompt learning. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 19113–19122 (2023)arxiv.org/abs/2210.03117
  11. [11]Khosla, A., Jayadevaprakash, N., Yao, B., Fei-Fei, L.: Fi: Novel dataset for fine-grained image categorization. In: Proceedings of the CVPR Workshop on Fine-Grained Visual Categorization (2011)
  12. [12]Krause, J., Stark, M., Deng, J., Fei-Fei, L.: 3D object representations for fine-grained categorization. In: Proceedings of the IEEE International Conference on Computer Vision Workshops. pp. 554–561 (2013)DOI
  13. [13]Lin, T.Y., RoyChowdhury, A., Maji, S.: Bilinear CNN models for fine-grained visual recognition. In: Proceedings of the IEEE International Conference on Computer Vision (ICCV). pp. 1449–1457 (2015)DOI
  14. [14]Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., Guo, B.: Swin transformer: Hierarchical vision transformer using shifted windows. In: Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV). pp. 10012–10022 (2021)arxiv.org/abs/2103.14030
  15. [15]Nauta, M., van Bree, R., Seifert, C.: Neural prototype trees for interpretable fine-grained image recognition. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 14933–14943 (2021)arxiv.org/abs/2012.02046
  16. [16]Oquab, M., Darcet, T., Moutakanni, T., Vo, H., Szafraniec, M., Khalidov, V., Fernandez, P., Haziza, D., Massa, F., El-Nouby, A., Assran, M., Ballas, N., Galuba, W., Howes, R., Huang, P.Y., Li, S.W., Misra, I., Rabbat, M., Sharma, V., Synnaeve, G., Xu, H., Jégou, H., Mairal, J., Labatut, P., Joulin, A., Bojanowski, P.: DinoV2: Learning robust visual features without supervision. Transactions on Machine Learning Research (2024)arxiv.org/abs/2304.07193
  17. [17]Parkhi, O.M., Vedaldi, A., Zisserman, A., Jawahar, C.V.: Cats and dogs. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR). pp. 3498–3505 (2012)
  18. [18]Paul, D., Chowdhury, A., Xiong, X., Chang, F.J., Carlyn, D., Stevens, S., Provost, K.L., Karpatne, A., Carstens, B., Rubenstein, D., Stewart, C., Berger-Wolf, T., Su, Y., Chao, W.L.: A simple interpretable transformer for fine-grained image classification and analysis. In: International Conference on Learning Representations (ICLR) (2024)arxiv.org/abs/2311.04157
  19. [19]Ren, L., Chen, C., Wang, L., Hua, K.A.: Da-VPT: Semantic-guided visual prompt tuning for vision transformers. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (2025)arxiv.org/abs/2505.23694
  20. [20]Selvaraju, R.R., Cogswell, M., Das, A., Vedantam, R., Parikh, D., Batra, D.: Grad-CAM: Visual explanations from deep networks via gradient-based localization. In: Proceedings of the IEEE International Conference on Computer Vision (ICCV). pp. 618–626 (2017)
  21. [21]Sun, S., Ren, W., Li, J., Wang, R., Cao, X.: Logit standardization in knowledge distillation. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 15731–15740 (2024)arxiv.org/abs/2403.01427
  22. [22]Touvron, H., Cord, M., Douze, M., Massa, F., Sablayrolles, A., Jégou, H.: Training data-efficient image transformers and distillation through attention. In: Proceedings of the International Conference on Machine Learning (ICML). pp. 10347–10357 (2021)arxiv.org/abs/2012.12877
  23. [23]Wah, C., Branson, S., Welinder, P., Perona, P., Belongie, S.: The caltech-ucsd birds-200-2011 dataset. Tech. Rep. CNS-TR-2011-001, California Institute of Technology (2011)
  24. [24]Wang, J., Huang, Y., Wu, S., Chen, C., Tan, M.: Visual query tuning: Towards effective usage of intermediate representations for parameter and memory efficient transfer learning. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 7725–7735 (2023)
  25. [25]Wang, J., Liu, H., Wang, X., Jing, L.: Interpretable image recognition by constructing transparent embedding space. In: Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) (2021)DOI
  26. [26]Xu, L., Ouyang, W., Bennamoun, M., Boussaid, F., Xu, D.: Multi-class token transformer for weakly supervised semantic segmentation. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 4310–4319 (2022)arxiv.org/abs/2203.02891
  27. [27]Xue, M., Huang, Q., Zhang, H., Meng, L.Z., Song, J., Song, M.: Protoformer: Concentrating on prototypical parts in vision transformers for interpretable image recognition. In: Proceedings of the International Joint Conference on Artificial Intelligence (IJCAI). pp. 1517–1525 (2024)DOI
  28. [28]Zhang, N., Donahue, J., Girshick, R., Darrell, T.: Part-based R-CNNs for fine-grained category detection. In: Proceedings of the European Conference on Computer Vision (ECCV). pp. 834–849 (2014)arxiv.org/abs/1407.3867
  29. [29]Zhao, B., Cui, Q., Song, R., Qiu, Y., Liang, J.: Decoupled knowledge distillation. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 11953–11962 (2022)arxiv.org/abs/2203.08679
  30. [30]Zhou, K., Yang, J., Loy, C.C., Liu, Z.: Learning to prompt for vision-language models. International Journal of Computer Vision 130, 2337–2348 (2022)DOI

AI tools statement

No AI-use declaration is available for this version in Valency.

The available record does not establish whether AI systems or models contributed to this work.

How AI tools are recorded

Paper details

Cite this paper

Publication

License
CC0-1.0
Published
Version
Latest

Data & code

Code, data, proofs and workflows the authors linked for testing, review and reproduction. These links are part of this work’s metadata and are released under the same license as the rest of that metadata. Valency doesn’t host the files; each keeps the license set where it’s hosted.

Pick where to look, or just type