# changsubi/gacl architecture

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

- Interactive diagram: https://gitdiagram.com/changsubi/gacl
- Repository: https://github.com/changsubi/gacl

## Overview

GACL is a Korean wildlife camera-trap classification system with a documented two-stage detection-and-classification workflow, plus a training and evaluation path. The graph preserves the documented multimodal model, data preparation, calibration, and analysis capabilities. Some connections are based on README descriptions or SOURCE INDEX references; unsampled implementations are represented only where the tree or documentation supports them.

Main entry points: [`src/models/gacl_model.py`](https://github.com/changsubi/gacl/blob/main/src/models/gacl_model.py) (GACL classifier), [`scripts/train.py`](https://github.com/changsubi/gacl/blob/main/scripts/train.py) (Training entry), [`src/training/trainer.py`](https://github.com/changsubi/gacl/blob/main/src/training/trainer.py) (Training loop), [`src/inference/pipeline.py`](https://github.com/changsubi/gacl/blob/main/src/inference/pipeline.py) (Detection-classification pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset["Wildlife dataset<br/>[dataset.py]"]
  node_augmentation["Image augmentation<br/>[augmentation.py]"]
  node_preprocessing["Image and text preprocessing<br/>[preprocessing.py]"]
end

subgraph group_model["GACL model"]
  node_detector["Wildlife detector<br/>[detection.py]"]
  node_backbone["Dilated and graph backbone<br/>[backbone.py]"]
  node_encoders["Vision and text encoders<br/>[encoders.py]"]
  node_losses["Contrastive and classification losses<br/>[losses.py]"]
  node_gacl["GACL classifier<br/>[gacl_model.py]"]
end

subgraph group_train["Training and evaluation"]
  node_train_entry["Training entry<br/>[train.py]"]
  node_calibration_entry["Calibration analysis entry"]
  node_trainer["Training loop<br/>[trainer.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
  node_calibration["Calibration and thresholds<br/>[calibration.py]"]
  node_training_utils["Training utilities<br/>[utils.py]"]
end

subgraph group_infer["Inference"]
  node_inference_entry["Inference entry<br/>[inference.py]"]
  node_pipeline["Detection-classification pipeline<br/>[pipeline.py]"]
  node_predictor["Prediction interface<br/>[predictor.py]"]
end

subgraph group_ops["Configuration and utilities"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_dataset_utils["Dataset analysis utilities<br/>[dataset_utils.py]"]
end

node_user(("Wildlife analyst"))
node_image_data["Camera-trap images"]
node_detector_service["Detector weights or service"]
node_classification_results["Species predictions"]

node_user -->|"provides images"| node_image_data
node_user -->|"starts training"| node_train_entry
node_user -->|"requests inference"| node_inference_entry
node_user -->|"runs analysis"| node_calibration_entry
node_image_data -->|"loads samples"| node_dataset
node_train_entry -->|"creates datasets"| node_dataset
node_train_entry -->|"configures transforms"| node_augmentation
node_train_entry -->|"initializes model"| node_gacl
node_train_entry -->|"starts trainer"| node_trainer
node_train_entry -->|"uses dataset tools"| node_dataset_utils
node_trainer -->|"runs forward pass"| node_gacl
node_trainer -->|"mixes batches"| node_augmentation
node_trainer -->|"evaluates results"| node_metrics
node_trainer -->|"uses helpers"| node_training_utils
node_trainer -->|"uses analysis"| node_calibration
node_gacl -->|"builds graph features"| node_backbone
node_gacl -->|"encodes modalities"| node_encoders
node_gacl -->|"computes combined loss"| node_losses
node_inference_entry -->|"runs full pipeline"| node_pipeline
node_inference_entry -->|"runs classifier mode"| node_predictor
node_pipeline -->|"detects animals"| node_detector
node_pipeline -->|"classifies detections"| node_gacl
node_pipeline -.->|"loads detector weights"| node_detector_service
node_predictor -->|"predicts species"| node_gacl
node_predictor -->|"prepares inputs"| node_preprocessing
node_pipeline -->|"returns detections"| node_classification_results
node_predictor -.->|"returns predictions"| node_classification_results
node_calibration_entry -->|"analyzes predictions"| node_predictor
node_calibration_entry -.->|"runs threshold analysis"| node_calibration
node_dataset_utils -->|"analyzes structure"| node_image_data
node_config -.->|"sets model parameters"| node_gacl
node_config -->|"sets thresholds"| node_pipeline

click node_train_entry "https://github.com/changsubi/gacl/blob/main/scripts/train.py"
click node_inference_entry "https://github.com/changsubi/gacl/blob/main/scripts/inference.py"
click node_calibration_entry "https://github.com/changsubi/gacl/blob/main/scripts/calibration_analysis.py"
click node_dataset "https://github.com/changsubi/gacl/blob/main/src/data/dataset.py"
click node_augmentation "https://github.com/changsubi/gacl/blob/main/src/data/augmentation.py"
click node_preprocessing "https://github.com/changsubi/gacl/blob/main/src/data/preprocessing.py"
click node_detector "https://github.com/changsubi/gacl/blob/main/src/models/detection.py"
click node_backbone "https://github.com/changsubi/gacl/blob/main/src/models/backbone.py"
click node_encoders "https://github.com/changsubi/gacl/blob/main/src/models/encoders.py"
click node_losses "https://github.com/changsubi/gacl/blob/main/src/models/losses.py"
click node_gacl "https://github.com/changsubi/gacl/blob/main/src/models/gacl_model.py"
click node_trainer "https://github.com/changsubi/gacl/blob/main/src/training/trainer.py"
click node_metrics "https://github.com/changsubi/gacl/blob/main/src/training/metrics.py"
click node_calibration "https://github.com/changsubi/gacl/blob/main/src/training/calibration.py"
click node_training_utils "https://github.com/changsubi/gacl/blob/main/src/training/utils.py"
click node_pipeline "https://github.com/changsubi/gacl/blob/main/src/inference/pipeline.py"
click node_predictor "https://github.com/changsubi/gacl/blob/main/src/inference/predictor.py"
click node_config "https://github.com/changsubi/gacl/blob/main/configs/config.py"
click node_dataset_utils "https://github.com/changsubi/gacl/blob/main/src/utils/dataset_utils.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_dataset,node_augmentation,node_preprocessing toneBlue
class node_detector,node_backbone,node_encoders,node_losses,node_gacl toneAmber
class node_train_entry,node_calibration_entry,node_trainer,node_metrics,node_calibration,node_training_utils toneMint
class node_inference_entry,node_pipeline,node_predictor toneRose
class node_config,node_dataset_utils,node_user,node_image_data,node_detector_service,node_classification_results toneIndigo
```

## Components

### Data preparation

- [Wildlife dataset](https://github.com/changsubi/gacl/blob/main/src/data/dataset.py): `src/data/dataset.py`
- [Image augmentation](https://github.com/changsubi/gacl/blob/main/src/data/augmentation.py): `src/data/augmentation.py`
- [Image and text preprocessing](https://github.com/changsubi/gacl/blob/main/src/data/preprocessing.py): `src/data/preprocessing.py`

### GACL model

- [Wildlife detector](https://github.com/changsubi/gacl/blob/main/src/models/detection.py): `src/models/detection.py`
- [Dilated and graph backbone](https://github.com/changsubi/gacl/blob/main/src/models/backbone.py): `src/models/backbone.py`
- [Vision and text encoders](https://github.com/changsubi/gacl/blob/main/src/models/encoders.py): `src/models/encoders.py`
- [Contrastive and classification losses](https://github.com/changsubi/gacl/blob/main/src/models/losses.py): `src/models/losses.py`
- [GACL classifier](https://github.com/changsubi/gacl/blob/main/src/models/gacl_model.py): `src/models/gacl_model.py`

### Training and evaluation

- [Training entry](https://github.com/changsubi/gacl/blob/main/scripts/train.py): `scripts/train.py`
- [Calibration analysis entry](https://github.com/changsubi/gacl/blob/main/scripts/calibration_analysis.py): `scripts/calibration_analysis.py`
- [Training loop](https://github.com/changsubi/gacl/blob/main/src/training/trainer.py): `src/training/trainer.py`
- [Evaluation metrics](https://github.com/changsubi/gacl/blob/main/src/training/metrics.py): `src/training/metrics.py`
- [Calibration and thresholds](https://github.com/changsubi/gacl/blob/main/src/training/calibration.py): `src/training/calibration.py`
- [Training utilities](https://github.com/changsubi/gacl/blob/main/src/training/utils.py): `src/training/utils.py`

### Inference

- [Inference entry](https://github.com/changsubi/gacl/blob/main/scripts/inference.py): `scripts/inference.py`
- [Detection-classification pipeline](https://github.com/changsubi/gacl/blob/main/src/inference/pipeline.py): `src/inference/pipeline.py`
- [Prediction interface](https://github.com/changsubi/gacl/blob/main/src/inference/predictor.py): `src/inference/predictor.py`

### Configuration and utilities

- [Runtime configuration](https://github.com/changsubi/gacl/blob/main/configs/config.py): `configs/config.py`
- [Dataset analysis utilities](https://github.com/changsubi/gacl/blob/main/src/utils/dataset_utils.py): `src/utils/dataset_utils.py`

### Other components

- **Wildlife analyst**
- **Camera-trap images**
- **Detector weights or service**
- **Species predictions**

## Connections

- Wildlife analyst → Camera-trap images: provides images (evidence: `README.md`)
- Wildlife analyst → Training entry: starts training (evidence: `README.md`)
- Wildlife analyst → Inference entry: requests inference (evidence: `README.md`)
- Wildlife analyst → Calibration analysis entry: runs analysis (evidence: `README.md`)
- Camera-trap images → Wildlife dataset: loads samples (evidence: `src/data/dataset.py`)
- Training entry → Wildlife dataset: creates datasets (evidence: `scripts/train.py`)
- Training entry → Image augmentation: configures transforms (evidence: `scripts/train.py`)
- Training entry → GACL classifier: initializes model (evidence: `scripts/train.py`)
- Training entry → Training loop: starts trainer (evidence: `scripts/train.py`)
- Training entry → Dataset analysis utilities: uses dataset tools (evidence: `scripts/train.py`)
- Training loop → GACL classifier: runs forward pass (evidence: `src/training/trainer.py`)
- Training loop → Image augmentation: mixes batches (evidence: `src/training/trainer.py`)
- Training loop → Evaluation metrics: evaluates results (evidence: `src/training/trainer.py`)
- Training loop → Training utilities: uses helpers (evidence: `src/training/trainer.py`)
- Training loop → Calibration and thresholds: uses analysis (evidence: `src/training/trainer.py`)
- GACL classifier → Dilated and graph backbone: builds graph features (evidence: `src/models/gacl_model.py`)
- GACL classifier → Vision and text encoders: encodes modalities (evidence: `src/models/gacl_model.py`)
- GACL classifier → Contrastive and classification losses: computes combined loss (evidence: `src/models/gacl_model.py`)
- Inference entry → Detection-classification pipeline: runs full pipeline (evidence: `scripts/inference.py`)
- Inference entry → Prediction interface: runs classifier mode (evidence: `scripts/inference.py`)
- Detection-classification pipeline → Wildlife detector: detects animals (evidence: `src/inference/pipeline.py`)
- Detection-classification pipeline → GACL classifier: classifies detections (evidence: `src/inference/pipeline.py`)
- Detection-classification pipeline → Detector weights or service: loads detector weights (evidence: `README.md`)
- Prediction interface → GACL classifier: predicts species (evidence: `src/inference/predictor.py`)
- Prediction interface → Image and text preprocessing: prepares inputs (evidence: `src/inference/predictor.py`)
- Detection-classification pipeline → Species predictions: returns detections (evidence: `README.md`)
- Prediction interface → Species predictions: returns predictions
- Calibration analysis entry → Prediction interface: analyzes predictions (evidence: `scripts/calibration_analysis.py`)
- Calibration analysis entry → Calibration and thresholds: runs threshold analysis
- Dataset analysis utilities → Camera-trap images: analyzes structure (evidence: `src/utils/dataset_utils.py`)
- Runtime configuration → GACL classifier: sets model parameters
- Runtime configuration → Detection-classification pipeline: sets thresholds (evidence: `src/inference/pipeline.py`)
