# nguyenthang060706/dsr_301m- architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenthang060706/dsr_301m-
- Repository: https://github.com/nguyenthang060706/dsr_301m-

## Overview

This repository is a research workflow for training and evaluating compact waste classifiers for university-canteen edge devices. Images and label mappings feed baseline and knowledge-distillation experiments; evaluation and tuning compare fine-grained and three-way decisions, and selected models are exported and quantized for deployment. The graph includes documented data preparation and domain-adaptation goals, but their detailed runtime connections are not all visible in the excerpts, so those links are omitted or cited to the README rather than inferred.

Main entry points: [`src/dsr/data.py`](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/data.py) (Dataset loading), [`scripts/export_and_quantize_tier_b.py`](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/export_and_quantize_tier_b.py) (Export and quantization), [`src/dsr/models.py`](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/models.py) (Model registry), [`src/dsr/train_kd.py`](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/train_kd.py) (Distillation training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_data_sources["Waste images"]
  node_label_map["Label mapping<br/>[label_map.csv]"]
  node_data_prep["Dataset preparation"]
  node_agreement["Label agreement"]
  node_dataset["Dataset loading<br/>[data.py]"]
end

subgraph group_training["Model training"]
  node_baseline["Baseline training<br/>[train.py]"]
  node_kd_training["Distillation training<br/>[train_kd.py]"]
  node_kd_losses["KD objectives<br/>[losses.py]"]
  node_models["Model registry<br/>[models.py]"]
  node_features["Feature extraction<br/>[features.py]"]
  node_pilot["Recipe pilot<br/>[pilot_recipe.py]"]
  node_tuning["DKD tuning<br/>[tune_dkd.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["Classification metrics<br/>[metrics.py]"]
  node_evaluation_tools["Holdout and audits<br/>[eval_holdout.py]"]
  node_analysis["Experiment analysis"]
end

subgraph group_deployment["Edge deployment"]
  node_deployment_export["Export and quantization"]
  node_static_quant["Static quantization"]
  node_onnx_models["ONNX models"]
end

node_researcher(("Researcher"))

node_researcher -->|"prepares data"| node_data_prep
node_data_sources -->|"supplies images"| node_data_prep
node_label_map -->|"maps labels"| node_dataset
node_data_prep -.->|"creates splits"| node_dataset
node_researcher -->|"checks labels"| node_agreement
node_dataset -->|"loads samples"| node_baseline
node_dataset -->|"loads samples"| node_kd_training
node_models -->|"builds model"| node_baseline
node_models -->|"builds student"| node_kd_training
node_kd_losses -->|"computes KD loss"| node_kd_training
node_features -.->|"provides features"| node_kd_training
node_researcher -->|"runs pilot"| node_pilot
node_dataset -->|"loads samples"| node_pilot
node_models -->|"builds model"| node_pilot
node_researcher -->|"tunes DKD"| node_tuning
node_dataset -->|"loads samples"| node_tuning
node_kd_losses -->|"computes DKD"| node_tuning
node_baseline -.->|"computes scores"| node_metrics
node_evaluation_tools -->|"loads evaluation data"| node_dataset
node_evaluation_tools -.->|"reports scores"| node_metrics
node_analysis -->|"reads dataset module"| node_dataset
node_researcher -->|"exports candidate"| node_deployment_export
node_deployment_export -->|"loads calibration data"| node_dataset
node_deployment_export -->|"creates model"| node_models
node_deployment_export -->|"writes ONNX"| node_onnx_models
node_static_quant -->|"loads calibration data"| node_dataset
node_static_quant -.->|"writes quantized model"| node_onnx_models

click node_data_sources "https://github.com/nguyenthang060706/dsr_301m-/tree/main/data"
click node_label_map "https://github.com/nguyenthang060706/dsr_301m-/blob/main/data/mappings/label_map.csv"
click node_data_prep "https://github.com/nguyenthang060706/dsr_301m-/tree/main/scripts"
click node_agreement "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/calc_agreement_multiobject.py"
click node_dataset "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/data.py"
click node_baseline "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/train.py"
click node_kd_training "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/train_kd.py"
click node_kd_losses "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/losses.py"
click node_models "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/models.py"
click node_features "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/features.py"
click node_pilot "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/pilot_recipe.py"
click node_tuning "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/tune_dkd.py"
click node_metrics "https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/metrics.py"
click node_evaluation_tools "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/eval_holdout.py"
click node_analysis "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/analyze_soft_targets.py"
click node_deployment_export "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/export_and_quantize_tier_b.py"
click node_static_quant "https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/quantize_static_tier_b.py"
click node_onnx_models "https://github.com/nguyenthang060706/dsr_301m-/tree/main/deploy/onnx"

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_sources,node_label_map,node_data_prep,node_agreement,node_dataset toneBlue
class node_baseline,node_kd_training,node_kd_losses,node_models,node_features,node_pilot,node_tuning toneAmber
class node_metrics,node_evaluation_tools,node_analysis toneMint
class node_deployment_export,node_static_quant,node_onnx_models toneRose
class node_researcher toneIndigo
```

## Components

### Data preparation

- [Waste images](https://github.com/nguyenthang060706/dsr_301m-/tree/main/data): `data`
- [Label mapping](https://github.com/nguyenthang060706/dsr_301m-/blob/main/data/mappings/label_map.csv): `data/mappings/label_map.csv`
- [Dataset preparation](https://github.com/nguyenthang060706/dsr_301m-/tree/main/scripts): `scripts`
- [Label agreement](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/calc_agreement_multiobject.py): `scripts/calc_agreement_multiobject.py`
- [Dataset loading](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/data.py): `src/dsr/data.py`

### Model training

- [Baseline training](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/train.py): `src/dsr/train.py`
- [Distillation training](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/train_kd.py): `src/dsr/train_kd.py`
- [KD objectives](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/losses.py): `src/dsr/losses.py`
- [Model registry](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/models.py): `src/dsr/models.py`
- [Feature extraction](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/features.py): `src/dsr/features.py`
- [Recipe pilot](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/pilot_recipe.py): `scripts/pilot_recipe.py`
- [DKD tuning](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/tune_dkd.py): `scripts/tune_dkd.py`

### Evaluation

- [Classification metrics](https://github.com/nguyenthang060706/dsr_301m-/blob/main/src/dsr/metrics.py): `src/dsr/metrics.py`
- [Holdout and audits](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/eval_holdout.py): `scripts/eval_holdout.py`
- [Experiment analysis](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/analyze_soft_targets.py): `scripts/analyze_soft_targets.py`

### Edge deployment

- [Export and quantization](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/export_and_quantize_tier_b.py): `scripts/export_and_quantize_tier_b.py`
- [Static quantization](https://github.com/nguyenthang060706/dsr_301m-/blob/main/scripts/quantize_static_tier_b.py): `scripts/quantize_static_tier_b.py`
- [ONNX models](https://github.com/nguyenthang060706/dsr_301m-/tree/main/deploy/onnx): `deploy/onnx`

### Other components

- **Researcher**

## Connections

- Researcher → Dataset preparation: prepares data (evidence: `README.md`)
- Waste images → Dataset preparation: supplies images (evidence: `README.md`)
- Label mapping → Dataset loading: maps labels (evidence: `src/dsr/data.py`)
- Dataset preparation → Dataset loading: creates splits (evidence: `scripts/audit_week1.py`)
- Researcher → Label agreement: checks labels (evidence: `README.md`)
- Dataset loading → Baseline training: loads samples (evidence: `src/dsr/train.py`)
- Dataset loading → Distillation training: loads samples (evidence: `src/dsr/train_kd.py`)
- Model registry → Baseline training: builds model (evidence: `src/dsr/train.py`)
- Model registry → Distillation training: builds student (evidence: `src/dsr/train_kd.py`)
- KD objectives → Distillation training: computes KD loss (evidence: `src/dsr/train_kd.py`)
- Feature extraction → Distillation training: provides features
- Researcher → Recipe pilot: runs pilot (evidence: `README.md`)
- Dataset loading → Recipe pilot: loads samples (evidence: `scripts/pilot_recipe.py`)
- Model registry → Recipe pilot: builds model (evidence: `scripts/pilot_recipe.py`)
- Researcher → DKD tuning: tunes DKD (evidence: `README.md`)
- Dataset loading → DKD tuning: loads samples (evidence: `scripts/tune_dkd.py`)
- KD objectives → DKD tuning: computes DKD (evidence: `scripts/tune_dkd.py`)
- Baseline training → Classification metrics: computes scores
- Holdout and audits → Dataset loading: loads evaluation data (evidence: `scripts/eval_holdout.py`)
- Holdout and audits → Classification metrics: reports scores
- Experiment analysis → Dataset loading: reads dataset module (evidence: `scripts/analyze_soft_targets.py`)
- Researcher → Export and quantization: exports candidate (evidence: `README.md`)
- Export and quantization → Dataset loading: loads calibration data (evidence: `scripts/export_and_quantize_tier_b.py`)
- Export and quantization → Model registry: creates model (evidence: `scripts/export_and_quantize_tier_b.py`)
- Export and quantization → ONNX models: writes ONNX (evidence: `scripts/export_and_quantize_tier_b.py`)
- Static quantization → Dataset loading: loads calibration data (evidence: `scripts/quantize_static_tier_b.py`)
- Static quantization → ONNX models: writes quantized model
