# anguyen8/peeb architecture

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

- Interactive diagram: https://gitdiagram.com/anguyen8/peeb
- Repository: https://github.com/anguyen8/peeb

## Overview

PEEB is a research implementation of a part-based image classifier: it matches detected visual parts to class descriptions, supporting training, zero-shot/generalized evaluation, and editable explanations. The documented workflow prepares dataset metadata and teacher logits, trains a part-text model and calibrates box prediction, then fine-tunes or evaluates on downstream datasets. The graph includes the documented descriptor and explanation capabilities; several runtime connections are limited to imports recorded in the source index, so unsampled internals are not inferred.

Main entry points: [`src/data_loader/dataset_wrapper.py`](https://github.com/anguyen8/peeb/blob/main/src/data_loader/dataset_wrapper.py) (Dataset wrapper), [`src/train_owlvit.py`](https://github.com/anguyen8/peeb/blob/main/src/train_owlvit.py) (Training and evaluation), [`src/utils.py`](https://github.com/anguyen8/peeb/blob/main/src/utils.py) (Descriptor utilities), [`src/data_loader/nabirds.py`](https://github.com/anguyen8/peeb/blob/main/src/data_loader/nabirds.py) (NABirds data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and preparation"]
  node_metadata["Dataset metadata<br/>[create_metadata.py]"]
  node_dataset_api["Dataset wrapper<br/>[dataset_wrapper.py]"]
  node_bird_soup["BirdSoup data<br/>[bird_soup.py]"]
  node_cub["CUB data<br/>[cub.py]"]
  node_nabirds["NABirds data<br/>[nabirds.py]"]
  node_nabirds_annotations["NABirds annotations<br/>[nabirds_horn.py]"]
  node_augmentation["Image augmentation<br/>[augmentation.py]"]
end

subgraph group_model["Model workflow"]
  node_box_precompute["Box precomputation"]
  node_training["Training and evaluation<br/>[train_owlvit.py]"]
  node_classifier["OWL-ViT classifier<br/>[owlvit_cls.py]"]
  node_inference["OWL-ViT inference"]
  node_box_logits["Box-logit updates"]
  node_config["Experiment configuration<br/>[configs.py]"]
  node_model_assets["Pretrained models<br/>[Model_card.md]"]
end

subgraph group_language["Descriptors"]
  node_descriptors["Class descriptors"]
  node_chatgpt["Descriptor generation<br/>[chatgpt.py]"]
  node_prompting["Prompt engineering"]
  node_shared_utils["Descriptor utilities<br/>[utils.py]"]
end

subgraph group_explain["Evaluation and explanations"]
  node_iou["Box metrics<br/>[iou_tools.py]"]
  node_plots["Explanation plots<br/>[peeb_plots.py]"]
  node_plot_tools["Plot utilities<br/>[plot_tools.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"trains or evaluates"| node_training
node_training -->|"loads datasets"| node_dataset_api
node_training -->|"uses classifier"| node_classifier
node_training -->|"uses utilities"| node_shared_utils
node_dataset_api -->|"selects dataset"| node_bird_soup
node_dataset_api -->|"selects dataset"| node_cub
node_dataset_api -->|"selects dataset"| node_nabirds
node_bird_soup -->|"uses augmentation"| node_augmentation
node_cub -->|"uses augmentation"| node_augmentation
node_nabirds -->|"uses augmentation"| node_augmentation
node_nabirds -->|"loads annotations"| node_nabirds_annotations
node_box_precompute -->|"loads datasets"| node_dataset_api
node_box_logits -->|"loads datasets"| node_dataset_api
node_box_logits -->|"uses utilities"| node_shared_utils
node_training -.->|"reads configuration"| node_config
node_shared_utils -->|"reads settings"| node_config
node_chatgpt -->|"uses utilities"| node_shared_utils
node_researcher -->|"edits descriptions"| node_descriptors
node_descriptors -->|"provides class text"| node_training
node_plots -->|"uses box metrics"| node_iou
node_plots -->|"uses plotting tools"| node_plot_tools
node_model_assets -.->|"supports inference"| node_inference
node_metadata -.->|"supplies metadata"| node_dataset_api

click node_metadata "https://github.com/anguyen8/peeb/blob/main/src/datasets/create_metadata.py"
click node_dataset_api "https://github.com/anguyen8/peeb/blob/main/src/data_loader/dataset_wrapper.py"
click node_bird_soup "https://github.com/anguyen8/peeb/blob/main/src/data_loader/bird_soup.py"
click node_cub "https://github.com/anguyen8/peeb/blob/main/src/data_loader/cub.py"
click node_nabirds "https://github.com/anguyen8/peeb/blob/main/src/data_loader/nabirds.py"
click node_nabirds_annotations "https://github.com/anguyen8/peeb/blob/main/src/data_loader/nabirds_horn.py"
click node_augmentation "https://github.com/anguyen8/peeb/blob/main/src/data_loader/augmentation.py"
click node_box_precompute "https://github.com/anguyen8/peeb/blob/main/src/precompute_boxes.py"
click node_training "https://github.com/anguyen8/peeb/blob/main/src/train_owlvit.py"
click node_classifier "https://github.com/anguyen8/peeb/blob/main/src/owlvit_cls.py"
click node_inference "https://github.com/anguyen8/peeb/blob/main/src/owlvit_inference.py"
click node_box_logits "https://github.com/anguyen8/peeb/blob/main/src/update_boxes_logits.py"
click node_config "https://github.com/anguyen8/peeb/blob/main/src/configs.py"
click node_descriptors "https://github.com/anguyen8/peeb/tree/main/data/descriptors"
click node_chatgpt "https://github.com/anguyen8/peeb/blob/main/src/chatgpt.py"
click node_prompting "https://github.com/anguyen8/peeb/blob/main/src/prompt_engineering.py"
click node_shared_utils "https://github.com/anguyen8/peeb/blob/main/src/utils.py"
click node_iou "https://github.com/anguyen8/peeb/blob/main/src/misc/iou_tools.py"
click node_plots "https://github.com/anguyen8/peeb/blob/main/src/misc/peeb_plots.py"
click node_plot_tools "https://github.com/anguyen8/peeb/blob/main/src/misc/plot_tools.py"
click node_model_assets "https://github.com/anguyen8/peeb/blob/main/Model_card.md"

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_metadata,node_dataset_api,node_bird_soup,node_cub,node_nabirds,node_nabirds_annotations,node_augmentation toneBlue
class node_box_precompute,node_training,node_classifier,node_inference,node_box_logits,node_config,node_model_assets toneAmber
class node_descriptors,node_chatgpt,node_prompting,node_shared_utils toneMint
class node_iou,node_plots,node_plot_tools toneRose
class node_researcher toneIndigo
```

## Components

### Data and preparation

- [Dataset metadata](https://github.com/anguyen8/peeb/blob/main/src/datasets/create_metadata.py): `src/datasets/create_metadata.py`
- [Dataset wrapper](https://github.com/anguyen8/peeb/blob/main/src/data_loader/dataset_wrapper.py): `src/data_loader/dataset_wrapper.py`
- [BirdSoup data](https://github.com/anguyen8/peeb/blob/main/src/data_loader/bird_soup.py): `src/data_loader/bird_soup.py`
- [CUB data](https://github.com/anguyen8/peeb/blob/main/src/data_loader/cub.py): `src/data_loader/cub.py`
- [NABirds data](https://github.com/anguyen8/peeb/blob/main/src/data_loader/nabirds.py): `src/data_loader/nabirds.py`
- [NABirds annotations](https://github.com/anguyen8/peeb/blob/main/src/data_loader/nabirds_horn.py): `src/data_loader/nabirds_horn.py`
- [Image augmentation](https://github.com/anguyen8/peeb/blob/main/src/data_loader/augmentation.py): `src/data_loader/augmentation.py`

### Model workflow

- [Box precomputation](https://github.com/anguyen8/peeb/blob/main/src/precompute_boxes.py): `src/precompute_boxes.py`
- [Training and evaluation](https://github.com/anguyen8/peeb/blob/main/src/train_owlvit.py): `src/train_owlvit.py`
- [OWL-ViT classifier](https://github.com/anguyen8/peeb/blob/main/src/owlvit_cls.py): `src/owlvit_cls.py`
- [OWL-ViT inference](https://github.com/anguyen8/peeb/blob/main/src/owlvit_inference.py): `src/owlvit_inference.py`
- [Box-logit updates](https://github.com/anguyen8/peeb/blob/main/src/update_boxes_logits.py): `src/update_boxes_logits.py`
- [Experiment configuration](https://github.com/anguyen8/peeb/blob/main/src/configs.py): `src/configs.py`
- [Pretrained models](https://github.com/anguyen8/peeb/blob/main/Model_card.md): `Model_card.md`

### Descriptors

- [Class descriptors](https://github.com/anguyen8/peeb/tree/main/data/descriptors): `data/descriptors`
- [Descriptor generation](https://github.com/anguyen8/peeb/blob/main/src/chatgpt.py): `src/chatgpt.py`
- [Prompt engineering](https://github.com/anguyen8/peeb/blob/main/src/prompt_engineering.py): `src/prompt_engineering.py`
- [Descriptor utilities](https://github.com/anguyen8/peeb/blob/main/src/utils.py): `src/utils.py`

### Evaluation and explanations

- [Box metrics](https://github.com/anguyen8/peeb/blob/main/src/misc/iou_tools.py): `src/misc/iou_tools.py`
- [Explanation plots](https://github.com/anguyen8/peeb/blob/main/src/misc/peeb_plots.py): `src/misc/peeb_plots.py`
- [Plot utilities](https://github.com/anguyen8/peeb/blob/main/src/misc/plot_tools.py): `src/misc/plot_tools.py`

### Other components

- **Researcher**

## Connections

- Researcher → Training and evaluation: trains or evaluates (evidence: `README.md`)
- Training and evaluation → Dataset wrapper: loads datasets (evidence: `src/train_owlvit.py`)
- Training and evaluation → OWL-ViT classifier: uses classifier (evidence: `src/train_owlvit.py`)
- Training and evaluation → Descriptor utilities: uses utilities (evidence: `src/train_owlvit.py`)
- Dataset wrapper → BirdSoup data: selects dataset (evidence: `src/data_loader/dataset_wrapper.py`)
- Dataset wrapper → CUB data: selects dataset (evidence: `src/data_loader/dataset_wrapper.py`)
- Dataset wrapper → NABirds data: selects dataset (evidence: `src/data_loader/dataset_wrapper.py`)
- BirdSoup data → Image augmentation: uses augmentation (evidence: `src/data_loader/bird_soup.py`)
- CUB data → Image augmentation: uses augmentation (evidence: `src/data_loader/cub.py`)
- NABirds data → Image augmentation: uses augmentation (evidence: `src/data_loader/nabirds.py`)
- NABirds data → NABirds annotations: loads annotations (evidence: `src/data_loader/nabirds.py`)
- Box precomputation → Dataset wrapper: loads datasets (evidence: `src/precompute_boxes.py`)
- Box-logit updates → Dataset wrapper: loads datasets (evidence: `src/update_boxes_logits.py`)
- Box-logit updates → Descriptor utilities: uses utilities (evidence: `src/update_boxes_logits.py`)
- Training and evaluation → Experiment configuration: reads configuration
- Descriptor utilities → Experiment configuration: reads settings (evidence: `src/utils.py`)
- Descriptor generation → Descriptor utilities: uses utilities (evidence: `src/chatgpt.py`)
- Researcher → Class descriptors: edits descriptions (evidence: `README.md`)
- Class descriptors → Training and evaluation: provides class text (evidence: `README.md`)
- Explanation plots → Box metrics: uses box metrics (evidence: `src/misc/peeb_plots.py`)
- Explanation plots → Plot utilities: uses plotting tools (evidence: `src/misc/peeb_plots.py`)
- Pretrained models → OWL-ViT inference: supports inference
- Dataset metadata → Dataset wrapper: supplies metadata
