# verg-avesta/countr architecture

> Architecture diagram of the GitHub repository verg-avesta/countr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/verg-avesta/countr
- Repository: https://github.com/verg-avesta/countr

## Overview

##### Main Components Identification

The system should be divided into these primary components:
- Model Architecture Components
- Training Pipeline
- Inference Pipeline
- Data Processing Components

##### Flow Representation

- Data flow during training (from datasets through model to loss computation)
- Inference path (from input image through model to count prediction)
- Model weight loading paths
- Training feedback loops

##### Technical Details

- Input formats and image processing steps
- Training hyperparameters connection points
- Dataset integration points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        FSC147[("FSC147 Dataset")]
        CARPK[("CARPK Dataset")]
    end

    subgraph "Core Model Architecture"
        MAE["MAE Transformer"]:::model
        CrossViT["CrossViT Components"]:::model
        click MAE "https://github.com/Verg-Avesta/CounTR/blob/main/models_mae_cross.py"
        click CrossViT "https://github.com/Verg-Avesta/CounTR/blob/main/models_crossvit.py"
    end

    subgraph "Training Pipeline"
        direction TB
        DataHandler["Dataset Handler"]:::data
        PreTrain["Pretraining Module"]:::training
        FineTune["Finetuning Module"]:::training
        click DataHandler "https://github.com/Verg-Avesta/CounTR/blob/main/util/FSC147.py"
        click PreTrain "https://github.com/Verg-Avesta/CounTR/blob/main/FSC_pretrain.py"
        click FineTune "https://github.com/Verg-Avesta/CounTR/blob/main/FSC_finetune_cross.py"
    end

    subgraph "Inference Pipeline"
        TestFSC["FSC Test Module"]:::inference
        TestCARPK["CARPK Test Module"]:::inference
        Demo["Demo Interface"]:::inference
        click TestFSC "https://github.com/Verg-Avesta/CounTR/blob/main/FSC_test_cross(zero-shot).py"
        click TestCARPK "https://github.com/Verg-Avesta/CounTR/blob/main/FSC_test_CARPK.py"
        click Demo "https://github.com/Verg-Avesta/CounTR/blob/main/demo.py"
    end

    subgraph "Utilities"
        LRSched["LR Scheduler"]:::util
        PosEmbed["Position Embedding"]:::util
        LARS["LARS Optimizer"]:::util
        DataProc["Data Processing"]:::util
        LRDecay["LR Decay"]:::util
        ImgProc["Image Processing"]:::util
        click LRSched "https://github.com/Verg-Avesta/CounTR/blob/main/util/lr_sched.py"
        click PosEmbed "https://github.com/Verg-Avesta/CounTR/blob/main/util/pos_embed.py"
        click LARS "https://github.com/Verg-Avesta/CounTR/blob/main/util/lars.py"
        click DataProc "https://github.com/Verg-Avesta/CounTR/blob/main/util/datasets.py"
        click LRDecay "https://github.com/Verg-Avesta/CounTR/blob/main/util/lr_decay.py"
        click ImgProc "https://github.com/Verg-Avesta/CounTR/blob/main/util/crop.py"
    end

    FSC147 --> DataHandler
    CARPK --> DataHandler
    DataHandler --> PreTrain
    DataHandler --> FineTune
    PreTrain --> MAE
    FineTune --> MAE
    MAE <--> CrossViT
    MAE --> TestFSC
    MAE --> TestCARPK
    MAE --> Demo
    
    LRSched --> PreTrain
    LRSched --> FineTune
    PosEmbed --> MAE
    LARS --> PreTrain
    LARS --> FineTune
    DataProc --> DataHandler
    LRDecay --> PreTrain
    LRDecay --> FineTune
    ImgProc --> DataHandler

    classDef model fill:#2374f7,stroke:#fff,stroke-width:2px,color:#fff
    classDef data fill:#b83dba,stroke:#fff,stroke-width:2px,color:#fff
    classDef training fill:#48a147,stroke:#fff,stroke-width:2px,color:#fff
    classDef inference fill:#ff6b6b,stroke:#fff,stroke-width:2px,color:#fff
    classDef util fill:#666,stroke:#fff,stroke-width:2px,color:#fff

    subgraph Legend
        L1["Model Components"]:::model
        L2["Data Components"]:::data
        L3["Training Components"]:::training
        L4["Inference Components"]:::inference
        L5["Utility Components"]:::util
    end
```
