# greedylearner1146/hela-vfa architecture

> Architecture diagram of the GitHub repository greedylearner1146/hela-vfa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/greedylearner1146/hela-vfa
- Repository: https://github.com/greedylearner1146/hela-vfa

## Overview

##### Project Type and Purpose
- HELA-VFA is a PyTorch-based few-shot classification pipeline that implements a Hellinger-distance and attention-based variational feature aggregation network.
- It uses a ResNet-12 backbone with channel/spatial attention, a custom metric-learning loss library (the “Hesim” folder), and standard data-prep, augmentation, training, and evaluation scripts.

##### File-Structure Analysis
Top-level files & scripts:
- Data_Preparation.py, Data_Augmentation.py – image ingestion, splitting, transforms.
- Attention.py, ResNet12.py – attention modules and backbone definition.
- dataloader.py, sampler_loader.py, test_loader.py – few-shot episode construction.
- Hellinger_dist.py, HELA_VFA_main.py – computation of Hellinger distance and main variational aggregation.
- model_train.py, evaluate.py – orchestrate training loop and final evaluation.
- Hesim/… – metric-learning helper classes, reducers, distance functions culminating in HesimLoss.

##### README Insights
- Outlines a sequential pipeline: data prep → augmentation → attention model → backbone → sampling → loss → train → eval → test.
- External dependencies: PyTorch, Sicara few-shot library, PyTorch-metric-learning concepts.
- Data & weight files hosted on Google Drive.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Pipeline
    subgraph "Data Pipeline"
        direction TB
        RawImages[(Raw Images)]:::data
        DP["Data Preparation"]:::data
        Preproc[(Preprocessed Dataset)]:::data
        DA["Data Augmentation"]:::data
        AugData[(Augmented Data)]:::data
        DL["Episode Builder"]:::data
        SL["Sampler Config"]:::data
        TL["Test Episode Loader"]:::data
    end

    %% Model Pipeline
    subgraph "Model Pipeline"
        direction TB
        Episodes[(Few-Shot Episodes)]:::data
        ATT["Attention Modules"]:::model
        RES["ResNet-12 Backbone"]:::model
        Embeddings[(Feature Embeddings)]:::model
        VFA["Variational Feature Aggregation"]:::model
        Distributions[(Class-Conditional Distributions)]:::model
    end

    %% Loss Module
    subgraph "Loss Module"
        direction TB
        HD["Hellinger Distance"]:::loss
        Hesim["Hesim Metric Library"]:::loss
        LossVal[(Loss Value)]:::loss
    end

    %% Training & Evaluation
    subgraph "Training & Evaluation"
        direction TB
        Train["Training Engine"]:::train
        Checkpoints[(Model Checkpoints)]:::train
        Eval["Evaluation Engine"]:::train
        Metrics[(Performance Metrics)]:::train
        MetaTest["Meta-Test Loader"]:::train
        Results[(Meta-Test Results)]:::train
    end

    %% External Resources
    subgraph "External Services"
        direction TB
        Sicara[(Sicara Library)]:::external
        GDrive[(Google Drive Storage)]:::external
    end

    %% Data Flow Connections
    RawImages --> DP --> Preproc --> DA --> AugData --> DL --> SL --> Episodes
    Episodes --> ATT --> Embeddings --> RES --> Embeddings
    Embeddings --> VFA --> Distributions
    Distributions --> HD --> LossVal
    LossVal --> Hesim --> LossVal
    LossVal --> Train --> Checkpoints --> Eval --> Metrics --> MetaTest --> Results

    %% External Calls
    Episodes -->|uses| Sicara
    RawImages -->|loads/saves| GDrive
    Checkpoints -->|stores/loads| GDrive

    %% Click Events
    click DP "https://github.com/greedylearner1146/hela-vfa/blob/main/Data_Preparation.py"
    click DA "https://github.com/greedylearner1146/hela-vfa/blob/main/Data_Augmentation.py"
    click DL "https://github.com/greedylearner1146/hela-vfa/blob/main/dataloader.py"
    click SL "https://github.com/greedylearner1146/hela-vfa/blob/main/sampler_loader.py"
    click TL "https://github.com/greedylearner1146/hela-vfa/blob/main/test_loader.py"
    click ATT "https://github.com/greedylearner1146/hela-vfa/blob/main/Attention.py"
    click RES "https://github.com/greedylearner1146/hela-vfa/blob/main/ResNet12.py"
    click VFA "https://github.com/greedylearner1146/hela-vfa/blob/main/HELA_VFA_main.py"
    click HD "https://github.com/greedylearner1146/hela-vfa/blob/main/Hellinger_dist.py"
    click Hesim "https://github.com/greedylearner1146/hela-vfa/tree/main/Hesim/"
    click Train "https://github.com/greedylearner1146/hela-vfa/blob/main/model_train.py"
    click Eval "https://github.com/greedylearner1146/hela-vfa/blob/main/evaluate.py"

    %% Styles
    classDef data fill:#cce5ff,stroke:#2a6fdb,color:#000
    classDef model fill:#d4edda,stroke:#3c763d,color:#000
    classDef loss fill:#fff3cd,stroke:#856404,color:#000
    classDef train fill:#e2d7f1,stroke:#6f42c1,color:#000
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000
```
