# eyalmichaeli/saspa-aug architecture

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

- Interactive diagram: https://gitdiagram.com/eyalmichaeli/saspa-aug
- Repository: https://github.com/eyalmichaeli/saspa-aug

## Overview

SaSPA generates structure- and subject-preserving image augmentations, filters them into a per-image mapping, and uses that mapping during fine-grained classifier training. The README documents prompt preparation, multiple dataset implementations, baseline checkpoints, and optional experiment monitoring. Source excerpts confirm generation/filtering and augmentation-aware dataset behavior; some internal wiring and the detailed filtering implementation were not fully sampled, so uncertain links are omitted.

Main entry points: [`fgvc/train.py`](https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/train.py) (Training workflow), [`run_aug/run_aug.py`](https://github.com/eyalmichaeli/saspa-aug/blob/main/run_aug/run_aug.py) (Generate augmentations), [`fgvc/datasets`](https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/datasets) (Dataset implementations), [`all_utils/utils.py`](https://github.com/eyalmichaeli/saspa-aug/blob/main/all_utils/utils.py) (Filter and map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_augmentation["Prompted augmentation"]
  node_prompt_assets["Prompt assets"]
  node_prompt_tools["Prompt preparation"]
  node_augment["Generate augmentations<br/>[run_aug.py]"]
  node_real_guidance["Real-guidance variant"]
end

subgraph group_filtering["Filtering and mapping"]
  node_images["Generated images"]
  node_filter_map["Filter and map<br/>[utils.py]"]
  node_aug_json["Augmentation mapping"]
end

subgraph group_training["Classifier training"]
  node_train_entry["Training workflow<br/>[train.py]"]
  node_config["Dataset hyperparameters"]
  node_losses["Training losses<br/>[losses.py]"]
  node_metrics["Metrics and checkpoints<br/>[util.py]"]
  node_trained_model["Trained checkpoint"]
end

subgraph group_data_models["Datasets and models"]
  node_dataset_factory["Dataset selection"]
  node_dataset_adapters["Dataset implementations"]
  node_aug_wrapper["Augmentation-aware loader"]
  node_classifier["WSDAN CAL model<br/>[cal.py]"]
end

node_researcher(("Researcher"))
node_diffusion["Diffusion pipeline"]
node_wandb["Weights &amp; Biases"]
node_source_data[("Fine-grained datasets")]

node_researcher -->|"prepares prompts"| node_prompt_tools
node_prompt_assets -->|"guides generation"| node_augment
node_prompt_tools -->|"produces prompts"| node_prompt_assets
node_researcher -->|"starts generation"| node_augment
node_augment -->|"invokes pipeline"| node_diffusion
node_real_guidance -.->|"invokes pipeline"| node_diffusion
node_augment -->|"writes images"| node_images
node_augment -->|"creates filtered mapping"| node_filter_map
node_images -->|"reads candidates"| node_filter_map
node_filter_map -->|"writes mapping"| node_aug_json
node_researcher -->|"starts training"| node_train_entry
node_train_entry -->|"loads settings"| node_config
node_train_entry -->|"requests datasets"| node_dataset_factory
node_dataset_factory -->|"selects implementation"| node_dataset_adapters
node_dataset_adapters -->|"reads samples"| node_source_data
node_dataset_adapters -->|"uses wrapper"| node_aug_wrapper
node_train_entry -->|"passes mapping path"| node_aug_json
node_aug_wrapper -->|"reads mapping"| node_aug_json
node_train_entry -->|"trains model"| node_classifier
node_train_entry -->|"uses objectives"| node_losses
node_train_entry -->|"tracks and saves"| node_metrics
node_metrics -->|"writes checkpoint"| node_trained_model
node_train_entry -.->|"logs experiments"| node_wandb

click node_prompt_assets "https://github.com/eyalmichaeli/saspa-aug/tree/main/prompts_engineering"
click node_prompt_tools "https://github.com/eyalmichaeli/saspa-aug/tree/main/prompts_engineering"
click node_augment "https://github.com/eyalmichaeli/saspa-aug/blob/main/run_aug/run_aug.py"
click node_real_guidance "https://github.com/eyalmichaeli/saspa-aug/blob/main/run_aug/run_aug_real_guidance.py"
click node_filter_map "https://github.com/eyalmichaeli/saspa-aug/blob/main/all_utils/utils.py"
click node_train_entry "https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/train.py"
click node_config "https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/configs"
click node_losses "https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/losses.py"
click node_metrics "https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/util.py"
click node_dataset_factory "https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/datasets"
click node_dataset_adapters "https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/datasets"
click node_aug_wrapper "https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/datasets/aug_wrapper_dataset.py"
click node_classifier "https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/models/cal.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_prompt_assets,node_prompt_tools,node_augment,node_real_guidance toneBlue
class node_images,node_filter_map,node_aug_json,node_source_data toneAmber
class node_train_entry,node_config,node_losses,node_metrics,node_trained_model toneMint
class node_dataset_factory,node_dataset_adapters,node_aug_wrapper,node_classifier toneRose
class node_researcher,node_diffusion,node_wandb toneIndigo
```

## Components

### Prompted augmentation

- [Prompt assets](https://github.com/eyalmichaeli/saspa-aug/tree/main/prompts_engineering): `prompts_engineering`
- [Prompt preparation](https://github.com/eyalmichaeli/saspa-aug/tree/main/prompts_engineering): `prompts_engineering`
- [Generate augmentations](https://github.com/eyalmichaeli/saspa-aug/blob/main/run_aug/run_aug.py): `run_aug/run_aug.py`
- [Real-guidance variant](https://github.com/eyalmichaeli/saspa-aug/blob/main/run_aug/run_aug_real_guidance.py): `run_aug/run_aug_real_guidance.py`

### Filtering and mapping

- **Generated images**
- [Filter and map](https://github.com/eyalmichaeli/saspa-aug/blob/main/all_utils/utils.py): `all_utils/utils.py`
- **Augmentation mapping**

### Classifier training

- [Training workflow](https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/train.py): `fgvc/train.py`
- [Dataset hyperparameters](https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/configs): `fgvc/configs`
- [Training losses](https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/losses.py): `fgvc/losses.py`
- [Metrics and checkpoints](https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/util.py): `fgvc/util.py`
- **Trained checkpoint**

### Datasets and models

- [Dataset selection](https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/datasets): `fgvc/datasets`
- [Dataset implementations](https://github.com/eyalmichaeli/saspa-aug/tree/main/fgvc/datasets): `fgvc/datasets`
- [Augmentation-aware loader](https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/datasets/aug_wrapper_dataset.py): `fgvc/datasets/aug_wrapper_dataset.py`
- [WSDAN CAL model](https://github.com/eyalmichaeli/saspa-aug/blob/main/fgvc/models/cal.py): `fgvc/models/cal.py`

### Other components

- **Researcher**
- **Diffusion pipeline**
- **Weights & Biases**
- **Fine-grained datasets**

## Connections

- Researcher → Prompt preparation: prepares prompts
- Prompt assets → Generate augmentations: guides generation
- Prompt preparation → Prompt assets: produces prompts
- Researcher → Generate augmentations: starts generation
- Generate augmentations → Diffusion pipeline: invokes pipeline
- Real-guidance variant → Diffusion pipeline: invokes pipeline
- Generate augmentations → Generated images: writes images
- Generate augmentations → Filter and map: creates filtered mapping
- Generated images → Filter and map: reads candidates
- Filter and map → Augmentation mapping: writes mapping
- Researcher → Training workflow: starts training
- Training workflow → Dataset hyperparameters: loads settings
- Training workflow → Dataset selection: requests datasets
- Dataset selection → Dataset implementations: selects implementation
- Dataset implementations → Fine-grained datasets: reads samples
- Dataset implementations → Augmentation-aware loader: uses wrapper
- Training workflow → Augmentation mapping: passes mapping path
- Augmentation-aware loader → Augmentation mapping: reads mapping
- Training workflow → WSDAN CAL model: trains model
- Training workflow → Training losses: uses objectives
- Training workflow → Metrics and checkpoints: tracks and saves
- Metrics and checkpoints → Trained checkpoint: writes checkpoint
- Training workflow → Weights & Biases: logs experiments
