# asbj021/geneticpatchpruning architecture

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

- Interactive diagram: https://gitdiagram.com/asbj021/geneticpatchpruning
- Repository: https://github.com/asbj021/geneticpatchpruning

## Overview

GeneticPatchPruning explores Vision Transformer efficiency by selecting image patches, using genetic search to produce pruning records and training learned selectors that can be evaluated against CLIP baselines. The source index supports the main links among data collection, the genetic algorithm, CLIP scoring, selector training, and evaluation. The README gives only the product title, so broader evaluation and training branches are represented from the tree without assuming unshown call paths.

Main entry points: [`gpp/dataset/data_utils.py`](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/dataset/data_utils.py) (Dataset utilities), [`gpp/model/model.py`](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/model/model.py) (Patch selectors), [`gpp/model/clip_model.py`](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/model/clip_model.py) (CLIP inference), [`gpp/genetic_algo/runner.py`](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/runner.py) (Search runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and collection"]
  node_data_utils["Dataset utilities<br/>[data_utils.py]"]
  node_patch_dataset["Patch datasets"]
  node_collect_ga["GA collection"]
  node_collect_parallel["Parallel collection<br/>[parallel_gpp.py]"]
end

subgraph group_search["Patch search"]
  node_search_runner["Search runner<br/>[runner.py]"]
  node_genetic_algo["Genetic search<br/>[ga.py]"]
  node_fitness["Fitness scoring<br/>[scoring.py]"]
  node_clip_runtime["CLIP inference<br/>[clip_model.py]"]
  node_records[("Selection records<br/>[io.py]")]
end

subgraph group_learn["Selector training"]
  node_selector["Patch selectors<br/>[model.py]"]
  node_standard_train["Selector training<br/>[train.py]"]
  node_adaptive_train["Adaptive training<br/>[adaptive_train.py]"]
  node_distill_train["GA distillation"]
  node_new_train["Training workflow<br/>[new_train.py]"]
  node_patch_train["Patch training<br/>[p_train.py]"]
end

subgraph group_assess["Evaluation"]
  node_eval_main["Selector evaluation<br/>[evaluate.py]"]
  node_eval_adaptive["Adaptive evaluation<br/>[adaptive_eval.py]"]
  node_eval_distill["Distillation evaluation<br/>[eval_ga_distill.py]"]
  node_baseline_compare["Baseline comparison<br/>[compare_og_ga.py]"]
  node_eval_suite["Benchmarks and analysis"]
end

node_researcher(("Researcher"))
node_image_data[("Image datasets")]

node_researcher -.->|"starts collection"| node_collect_ga
node_researcher -.->|"starts training"| node_standard_train
node_researcher -.->|"runs evaluation"| node_eval_main
node_image_data -.->|"provides samples"| node_data_utils
node_data_utils -->|"uses"| node_patch_dataset
node_collect_ga -->|"loads data"| node_data_utils
node_collect_ga -->|"runs search"| node_search_runner
node_collect_ga -->|"loads CLIP"| node_clip_runtime
node_collect_parallel -->|"loads data"| node_data_utils
node_collect_parallel -->|"runs search"| node_search_runner
node_collect_parallel -->|"loads CLIP"| node_clip_runtime
node_search_runner -->|"invokes search"| node_genetic_algo
node_search_runner -->|"prepares inference"| node_clip_runtime
node_search_runner -->|"writes records"| node_records
node_genetic_algo -->|"scores candidates"| node_fitness
node_fitness -->|"evaluates patches"| node_clip_runtime
node_standard_train -->|"uses data"| node_data_utils
node_standard_train -->|"trains"| node_selector
node_adaptive_train -->|"uses data"| node_data_utils
node_adaptive_train -->|"trains"| node_selector
node_distill_train -->|"uses data"| node_data_utils
node_distill_train -->|"trains"| node_selector
node_new_train -->|"uses data"| node_data_utils
node_new_train -->|"trains"| node_selector
node_patch_train -->|"uses data"| node_data_utils
node_patch_train -->|"trains"| node_selector
node_eval_main -->|"loads data"| node_data_utils
node_eval_main -->|"uses selector"| node_selector
node_eval_main -.->|"runs inference"| node_clip_runtime
node_eval_adaptive -->|"loads data"| node_data_utils
node_eval_adaptive -->|"uses selector"| node_selector
node_eval_distill -->|"loads data"| node_data_utils
node_eval_distill -->|"evaluates selector"| node_selector
node_eval_distill -->|"runs inference"| node_clip_runtime
node_baseline_compare -->|"loads data"| node_data_utils
node_baseline_compare -->|"compares CLIP"| node_clip_runtime

click node_data_utils "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/dataset/data_utils.py"
click node_patch_dataset "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/dataset/dataset_patch_selection.py"
click node_collect_ga "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/data_collection/genetic_patch_pruning.py"
click node_collect_parallel "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/data_collection/parallel_gpp.py"
click node_search_runner "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/runner.py"
click node_genetic_algo "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/ga.py"
click node_fitness "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/scoring.py"
click node_clip_runtime "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/model/clip_model.py"
click node_records "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/io.py"
click node_selector "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/model/model.py"
click node_standard_train "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/train.py"
click node_adaptive_train "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/adaptive_train.py"
click node_distill_train "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/ga_distill_train.py"
click node_new_train "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/new_train.py"
click node_patch_train "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/p_train.py"
click node_eval_main "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/evaluate.py"
click node_eval_adaptive "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/adaptive_eval.py"
click node_eval_distill "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/eval_ga_distill.py"
click node_baseline_compare "https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/compare_og_ga.py"
click node_eval_suite "https://github.com/asbj021/geneticpatchpruning/tree/main/gpp/eval"

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_data_utils,node_patch_dataset,node_collect_ga,node_collect_parallel toneBlue
class node_search_runner,node_genetic_algo,node_fitness,node_clip_runtime,node_records,node_image_data toneAmber
class node_selector,node_standard_train,node_adaptive_train,node_distill_train,node_new_train,node_patch_train toneMint
class node_eval_main,node_eval_adaptive,node_eval_distill,node_baseline_compare,node_eval_suite toneRose
class node_researcher toneIndigo
```

## Components

### Data and collection

- [Dataset utilities](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/dataset/data_utils.py): `gpp/dataset/data_utils.py`
- [Patch datasets](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/dataset/dataset_patch_selection.py): `gpp/dataset/dataset_patch_selection.py`
- [GA collection](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/data_collection/genetic_patch_pruning.py): `gpp/data_collection/genetic_patch_pruning.py`
- [Parallel collection](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/data_collection/parallel_gpp.py): `gpp/data_collection/parallel_gpp.py`

### Patch search

- [Search runner](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/runner.py): `gpp/genetic_algo/runner.py`
- [Genetic search](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/ga.py): `gpp/genetic_algo/ga.py`
- [Fitness scoring](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/scoring.py): `gpp/genetic_algo/scoring.py`
- [CLIP inference](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/model/clip_model.py): `gpp/model/clip_model.py`
- [Selection records](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/genetic_algo/io.py): `gpp/genetic_algo/io.py`

### Selector training

- [Patch selectors](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/model/model.py): `gpp/model/model.py`
- [Selector training](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/train.py): `gpp/train/train.py`
- [Adaptive training](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/adaptive_train.py): `gpp/train/adaptive_train.py`
- [GA distillation](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/ga_distill_train.py): `gpp/train/ga_distill_train.py`
- [Training workflow](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/new_train.py): `gpp/train/new_train.py`
- [Patch training](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/train/p_train.py): `gpp/train/p_train.py`

### Evaluation

- [Selector evaluation](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/evaluate.py): `gpp/eval/evaluate.py`
- [Adaptive evaluation](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/adaptive_eval.py): `gpp/eval/adaptive_eval.py`
- [Distillation evaluation](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/eval_ga_distill.py): `gpp/eval/eval_ga_distill.py`
- [Baseline comparison](https://github.com/asbj021/geneticpatchpruning/blob/main/gpp/eval/compare_og_ga.py): `gpp/eval/compare_og_ga.py`
- [Benchmarks and analysis](https://github.com/asbj021/geneticpatchpruning/tree/main/gpp/eval): `gpp/eval`

### Other components

- **Researcher**
- **Image datasets**

## Connections

- Researcher → GA collection: starts collection
- Researcher → Selector training: starts training
- Researcher → Selector evaluation: runs evaluation
- Image datasets → Dataset utilities: provides samples
- Dataset utilities → Patch datasets: uses (evidence: `gpp/dataset/data_utils.py`)
- GA collection → Dataset utilities: loads data (evidence: `gpp/data_collection/genetic_patch_pruning.py`)
- GA collection → Search runner: runs search (evidence: `gpp/data_collection/genetic_patch_pruning.py`)
- GA collection → CLIP inference: loads CLIP (evidence: `gpp/data_collection/genetic_patch_pruning.py`)
- Parallel collection → Dataset utilities: loads data (evidence: `gpp/data_collection/parallel_gpp.py`)
- Parallel collection → Search runner: runs search (evidence: `gpp/data_collection/parallel_gpp.py`)
- Parallel collection → CLIP inference: loads CLIP (evidence: `gpp/data_collection/parallel_gpp.py`)
- Search runner → Genetic search: invokes search (evidence: `gpp/genetic_algo/runner.py`)
- Search runner → CLIP inference: prepares inference (evidence: `gpp/genetic_algo/runner.py`)
- Search runner → Selection records: writes records (evidence: `gpp/genetic_algo/runner.py`)
- Genetic search → Fitness scoring: scores candidates (evidence: `gpp/genetic_algo/ga.py`)
- Fitness scoring → CLIP inference: evaluates patches (evidence: `gpp/genetic_algo/scoring.py`)
- Selector training → Dataset utilities: uses data (evidence: `gpp/train/train.py`)
- Selector training → Patch selectors: trains (evidence: `gpp/train/train.py`)
- Adaptive training → Dataset utilities: uses data (evidence: `gpp/train/adaptive_train.py`)
- Adaptive training → Patch selectors: trains (evidence: `gpp/train/adaptive_train.py`)
- GA distillation → Dataset utilities: uses data (evidence: `gpp/train/ga_distill_train.py`)
- GA distillation → Patch selectors: trains (evidence: `gpp/train/ga_distill_train.py`)
- Training workflow → Dataset utilities: uses data (evidence: `gpp/train/new_train.py`)
- Training workflow → Patch selectors: trains (evidence: `gpp/train/new_train.py`)
- Patch training → Dataset utilities: uses data (evidence: `gpp/train/p_train.py`)
- Patch training → Patch selectors: trains (evidence: `gpp/train/p_train.py`)
- Selector evaluation → Dataset utilities: loads data (evidence: `gpp/eval/evaluate.py`)
- Selector evaluation → Patch selectors: uses selector (evidence: `gpp/eval/evaluate.py`)
- Selector evaluation → CLIP inference: runs inference (evidence: `gpp/eval/evaluate.py`)
- Adaptive evaluation → Dataset utilities: loads data (evidence: `gpp/eval/adaptive_eval.py`)
- Adaptive evaluation → Patch selectors: uses selector (evidence: `gpp/eval/adaptive_eval.py`)
- Distillation evaluation → Dataset utilities: loads data (evidence: `gpp/eval/eval_ga_distill.py`)
- Distillation evaluation → Patch selectors: evaluates selector (evidence: `gpp/eval/eval_ga_distill.py`)
- Distillation evaluation → CLIP inference: runs inference (evidence: `gpp/eval/eval_ga_distill.py`)
- Baseline comparison → Dataset utilities: loads data (evidence: `gpp/eval/compare_og_ga.py`)
- Baseline comparison → CLIP inference: compares CLIP (evidence: `gpp/eval/compare_og_ga.py`)
