# valeoai/naf architecture

> Architecture diagram of the GitHub repository valeoai/naf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valeoai/naf
- Repository: https://github.com/valeoai/naf
- Video tour (about a minute): https://gitdiagram.com/valeoai/naf/video

## Overview

NAF is a zero-shot feature upsampler: an image guides the conversion of low-resolution Vision Foundation Model features to a requested higher resolution. The repository also provides alternative upsamplers, image restoration/denoising, and downstream depth, segmentation, and video-segmentation evaluation. Edges are limited to README statements and relationships visible in the sampled source or SOURCE INDEX; unsampled evaluation/model wiring is left unasserted.

Main entry points: [`src/model/naf.py`](https://github.com/valeoai/naf/blob/main/src/model/naf.py) (NAF Upsampler), [`utils/training.py`](https://github.com/valeoai/naf/blob/main/utils/training.py) (Training Utilities), [`denoising.py`](https://github.com/valeoai/naf/blob/main/denoising.py) (Denoising Workflow), [`evaluation/eval_video_seg.py`](https://github.com/valeoai/naf/blob/main/evaluation/eval_video_seg.py) (Video Segmentation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_upsampling["Feature Upsampling"]
  node_hub["Hub Loader<br/>[hubconf.py]"]
  node_naf["NAF Upsampler<br/>[naf.py]"]
  node_alternatives["Alternative Upsamplers"]
end

subgraph group_architecture["Model Components"]
  node_backbone["ViT Backbone<br/>[vit_wrapper.py]"]
  node_attention["Cross-Scale Attention<br/>[attentions.py]"]
  node_convolutions["Convolution Encoder<br/>[convolutions.py]"]
  node_rope["RoPE Encoding<br/>[rope.py]"]
  node_jafar["JAFAR Upsampler<br/>[jafar.py]"]
  node_featup["FeatUp Upsampler<br/>[featup.py]"]
  node_jbu["Joint Bilateral<br/>[jbu.py]"]
  node_ircnn["IRCNN Model<br/>[ircnn.py]"]
  node_rednet["REDNet Model<br/>[rednet.py]"]
  node_restormer["Restormer<br/>[restormer.py]"]
end

subgraph group_training["Training and Restoration"]
  node_train["Feature Training<br/>[train.py]"]
  node_training_utils["Training Utilities<br/>[training.py]"]
  node_denoising["Denoising Workflow<br/>[denoising.py]"]
  node_image_utils["Image Utilities<br/>[img.py]"]
  node_loss["Feature Loss<br/>[loss.py]"]
end

subgraph group_evaluation["Downstream Evaluation"]
  node_depth_eval["Depth Probing"]
  node_seg_eval["Segmentation Probing"]
  node_video_eval["Video Segmentation<br/>[eval_video_seg.py]"]
  node_datasets["Evaluation Datasets"]
end

node_user(("User"))

node_user -->|"loads model"| node_hub
node_hub -->|"loads"| node_naf
node_user -->|"supplies image, features"| node_naf
node_naf -->|"applies attention"| node_attention
node_naf -->|"encodes image"| node_convolutions
node_naf -->|"encodes positions"| node_rope
node_attention -->|"uses encoding"| node_rope
node_train -->|"uses utilities"| node_training_utils
node_training_utils -->|"loads backbone"| node_backbone
node_training_utils -->|"uses image helpers"| node_image_utils
node_denoising -->|"uses utilities"| node_training_utils
node_denoising -.->|"trains model"| node_ircnn
node_denoising -.->|"trains model"| node_rednet
node_denoising -.->|"trains model"| node_naf
node_depth_eval -->|"uses utilities"| node_training_utils
node_seg_eval -->|"uses utilities"| node_training_utils
node_video_eval -->|"uses utilities"| node_training_utils
node_video_eval -.->|"evaluates DAVIS data"| node_datasets
node_depth_eval -.->|"evaluates upsampler"| node_naf
node_seg_eval -.->|"evaluates upsampler"| node_naf
node_video_eval -.->|"evaluates upsampler"| node_jafar
node_featup -->|"uses stack"| node_jbu
node_jafar -->|"uses encoder"| node_convolutions
node_loss -.->|"used for probing"| node_depth_eval

click node_hub "https://github.com/valeoai/naf/blob/main/hubconf.py"
click node_naf "https://github.com/valeoai/naf/blob/main/src/model/naf.py"
click node_alternatives "https://github.com/valeoai/naf/tree/main/src/model"
click node_backbone "https://github.com/valeoai/naf/blob/main/src/backbone/vit_wrapper.py"
click node_attention "https://github.com/valeoai/naf/blob/main/src/layers/attentions.py"
click node_convolutions "https://github.com/valeoai/naf/blob/main/src/layers/convolutions.py"
click node_rope "https://github.com/valeoai/naf/blob/main/src/layers/rope.py"
click node_jafar "https://github.com/valeoai/naf/blob/main/src/model/jafar.py"
click node_featup "https://github.com/valeoai/naf/blob/main/src/model/featup.py"
click node_jbu "https://github.com/valeoai/naf/blob/main/src/model/jbu.py"
click node_ircnn "https://github.com/valeoai/naf/blob/main/src/model/ircnn.py"
click node_rednet "https://github.com/valeoai/naf/blob/main/src/model/rednet.py"
click node_restormer "https://github.com/valeoai/naf/blob/main/src/model/restormer.py"
click node_train "https://github.com/valeoai/naf/blob/main/train.py"
click node_training_utils "https://github.com/valeoai/naf/blob/main/utils/training.py"
click node_denoising "https://github.com/valeoai/naf/blob/main/denoising.py"
click node_image_utils "https://github.com/valeoai/naf/blob/main/utils/img.py"
click node_depth_eval "https://github.com/valeoai/naf/blob/main/evaluation/eval_depth_probing.py"
click node_seg_eval "https://github.com/valeoai/naf/blob/main/evaluation/eval_seg_probing.py"
click node_video_eval "https://github.com/valeoai/naf/blob/main/evaluation/eval_video_seg.py"
click node_datasets "https://github.com/valeoai/naf/tree/main/evaluation/dataset"
click node_loss "https://github.com/valeoai/naf/blob/main/src/loss.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_hub,node_naf,node_alternatives,node_user toneBlue
class node_backbone,node_attention,node_convolutions,node_rope,node_jafar,node_featup,node_jbu,node_ircnn,node_rednet,node_restormer toneAmber
class node_train,node_training_utils,node_denoising,node_image_utils,node_loss toneMint
class node_depth_eval,node_seg_eval,node_video_eval,node_datasets toneRose
```

## Components

### Feature Upsampling

- [Hub Loader](https://github.com/valeoai/naf/blob/main/hubconf.py): `hubconf.py`
- [NAF Upsampler](https://github.com/valeoai/naf/blob/main/src/model/naf.py): `src/model/naf.py`
- [Alternative Upsamplers](https://github.com/valeoai/naf/tree/main/src/model): `src/model`

### Model Components

- [ViT Backbone](https://github.com/valeoai/naf/blob/main/src/backbone/vit_wrapper.py): `src/backbone/vit_wrapper.py`
- [Cross-Scale Attention](https://github.com/valeoai/naf/blob/main/src/layers/attentions.py): `src/layers/attentions.py`
- [Convolution Encoder](https://github.com/valeoai/naf/blob/main/src/layers/convolutions.py): `src/layers/convolutions.py`
- [RoPE Encoding](https://github.com/valeoai/naf/blob/main/src/layers/rope.py): `src/layers/rope.py`
- [JAFAR Upsampler](https://github.com/valeoai/naf/blob/main/src/model/jafar.py): `src/model/jafar.py`
- [FeatUp Upsampler](https://github.com/valeoai/naf/blob/main/src/model/featup.py): `src/model/featup.py`
- [Joint Bilateral](https://github.com/valeoai/naf/blob/main/src/model/jbu.py): `src/model/jbu.py`
- [IRCNN Model](https://github.com/valeoai/naf/blob/main/src/model/ircnn.py): `src/model/ircnn.py`
- [REDNet Model](https://github.com/valeoai/naf/blob/main/src/model/rednet.py): `src/model/rednet.py`
- [Restormer](https://github.com/valeoai/naf/blob/main/src/model/restormer.py): `src/model/restormer.py`

### Training and Restoration

- [Feature Training](https://github.com/valeoai/naf/blob/main/train.py): `train.py`
- [Training Utilities](https://github.com/valeoai/naf/blob/main/utils/training.py): `utils/training.py`
- [Denoising Workflow](https://github.com/valeoai/naf/blob/main/denoising.py): `denoising.py`
- [Image Utilities](https://github.com/valeoai/naf/blob/main/utils/img.py): `utils/img.py`
- [Feature Loss](https://github.com/valeoai/naf/blob/main/src/loss.py): `src/loss.py`

### Downstream Evaluation

- [Depth Probing](https://github.com/valeoai/naf/blob/main/evaluation/eval_depth_probing.py): `evaluation/eval_depth_probing.py`
- [Segmentation Probing](https://github.com/valeoai/naf/blob/main/evaluation/eval_seg_probing.py): `evaluation/eval_seg_probing.py`
- [Video Segmentation](https://github.com/valeoai/naf/blob/main/evaluation/eval_video_seg.py): `evaluation/eval_video_seg.py`
- [Evaluation Datasets](https://github.com/valeoai/naf/tree/main/evaluation/dataset): `evaluation/dataset`

### Other components

- **User**

## Connections

- User → Hub Loader: loads model (evidence: `README.md`)
- Hub Loader → NAF Upsampler: loads (evidence: `hubconf.py`)
- User → NAF Upsampler: supplies image, features (evidence: `README.md`)
- NAF Upsampler → Cross-Scale Attention: applies attention (evidence: `src/model/naf.py`)
- NAF Upsampler → Convolution Encoder: encodes image (evidence: `src/model/naf.py`)
- NAF Upsampler → RoPE Encoding: encodes positions (evidence: `src/model/naf.py`)
- Cross-Scale Attention → RoPE Encoding: uses encoding (evidence: `src/layers/attentions.py`)
- Feature Training → Training Utilities: uses utilities (evidence: `train.py`)
- Training Utilities → ViT Backbone: loads backbone (evidence: `utils/training.py`)
- Training Utilities → Image Utilities: uses image helpers (evidence: `utils/training.py`)
- Denoising Workflow → Training Utilities: uses utilities (evidence: `denoising.py`)
- Denoising Workflow → IRCNN Model: trains model
- Denoising Workflow → REDNet Model: trains model
- Denoising Workflow → NAF Upsampler: trains model
- Depth Probing → Training Utilities: uses utilities (evidence: `evaluation/eval_depth_probing.py`)
- Segmentation Probing → Training Utilities: uses utilities (evidence: `evaluation/eval_seg_probing.py`)
- Video Segmentation → Training Utilities: uses utilities (evidence: `evaluation/eval_video_seg.py`)
- Video Segmentation → Evaluation Datasets: evaluates DAVIS data
- Depth Probing → NAF Upsampler: evaluates upsampler
- Segmentation Probing → NAF Upsampler: evaluates upsampler
- Video Segmentation → JAFAR Upsampler: evaluates upsampler
- FeatUp Upsampler → Joint Bilateral: uses stack (evidence: `src/model/featup.py`)
- JAFAR Upsampler → Convolution Encoder: uses encoder (evidence: `src/model/jafar.py`)
- Feature Loss → Depth Probing: used for probing (evidence: `evaluation/eval_depth_probing.py`)
