# vib06hav/mlpr_vib_rej_rish architecture

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

- Interactive diagram: https://gitdiagram.com/vib06hav/mlpr_vib_rej_rish
- Repository: https://github.com/vib06hav/mlpr_vib_rej_rish

## Overview

#### Purpose and Entry Points
This repository studies BDD100K vehicle-crop classification across day-to-night domain shift for `bus`, `car`, and `truck`. It measures source-only degradation, supervised target fine-tuning, and DANN adaptation. The primary experiment entry point is `main.py`; preprocessing begins in `Preprocessdata.py`. `run_direction1.bat` is a Windows execution wrapper.

#### Experiment Orchestration
`main.py` coordinates configured experiment modes, seeds, model creation, dataset construction, training, checkpointing, and result aggregation. Global paths, hyperparameters, random seeds, and run switches are centralized in `config.py`. Outputs include repository-local aggregate CSVs such as `all_results_summary.csv` and `direction1_results_summary.csv`.

#### Data Preparation and Dataset Boundary
`Preprocessdata.py` extracts vehicle crops from raw BDD100K images and annotations, organizes domain-specific processed data, and balances the dataset. Raw images and labels are external to the repo, expected beneath `C:\Users\vibha\Downloads\archive\...`. `dataset.py` is the boundary between processed crop storage and PyTorch-style training inputs: it loads crops, applies transforms, assigns class/domain metadata, and supports target-label masking for Direction 1 experiments.

#### Domain-Adaptation Directions
The core setting is daytime source crops versus nighttime target crops. Direction-specific experiment logic is represented by `main.py`, `dataset.py`, and the specialized `direction2_env_only.py` / `direction2_idd.py` scripts. Direction 1 includes target-label availability/masking sweeps; Direction 2-related scripts appear to be adjacent variants rather than the primary BDD pipeline.

#### Model and Adaptation Stack
`models.py` defines the vehicle classifier backbone/head used for standard supervised training. `dann.py` adds DANN-specific architecture pieces: gradient reversal and a domain classifier attached to learned features. This separates label prediction from domain discrimination so training can jointly optimize vehicle classification and domain-invariant representations.

#### Training and Evaluation Flow
`train.py` implements standard supervised and DANN training loops. Standard runs train on labeled source data and optionally supervised target data; DANN runs additionally consume domain labels for source and target batches through `dann.py`. `evaluate.py` computes classification metrics, per-seed aggregation, and analysis helpers, producing comparable source/target and adaptation results.

#### Visualization and Adjacent Work
`run_tsne_bdd.py` provides standalone feature-space t-SNE visualization for the BDD study. `visualise.py` supports visualization utilities. IDD scripts—including `PreprocessIDD.py`, `FinalizeIDD.py`, `eval_idd_perclass.py`, and `CullPool.py`—are adjacent work and not the central BDD day-to-night architecture.

Main entry points: [`main.py`](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/main.py) (Experiment orchestrator), [`dataset.py`](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/dataset.py) (Training dataset boundary), [`train.py`](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/train.py) (Training loops), [`models.py`](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/models.py) (Vehicle classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bdd["BDD Day-to-Night Study"]
  node_raw_bdd[("Raw BDD100K images &amp; labels<br/>external dataset")]
  node_preprocess_bdd["BDD crop preprocessing<br/>[Preprocessdata.py]"]
  node_processed_crops[("Processed domain crops<br/>dataset storage")]
  node_dataset["Training dataset boundary<br/>PyTorch dataset<br/>[dataset.py]"]
  node_config["Experiment configuration<br/>configuration module<br/>[config.py]"]
  node_main["Experiment orchestrator<br/>experiment entry point<br/>[main.py]"]
  node_wrapper["Windows run wrapper<br/>execution wrapper<br/>[run_direction1.bat]"]
  node_classifier["Vehicle classifier<br/>model definition<br/>[models.py]"]
  node_dann["DANN adaptation model<br/>adaptation architecture<br/>[dann.py]"]
  node_training["Training loops<br/>training runtime<br/>[train.py]"]
  node_evaluation["Metrics &amp; aggregation<br/>evaluation module<br/>[evaluate.py]"]
  node_results["CSV result summaries<br/>experiment outputs"]
  node_tsne["BDD feature t-SNE<br/>visualization entry point<br/>[run_tsne_bdd.py]"]
  node_visualization["Visualization utilities<br/>visualization module<br/>[visualise.py]"]
  node_direction2_env["Direction 2 environment variant<br/>adjacent experiment"]
  node_direction2_idd["Direction 2 IDD variant<br/>adjacent experiment<br/>[direction2_idd.py]"]
end

subgraph group_idd["Adjacent IDD Work"]
  node_idd_pipeline["IDD preprocessing &amp; analysis<br/>adjacent pipeline<br/>[PreprocessIDD.py]"]
end

node_raw_bdd -->|"images and annotations"| node_preprocess_bdd
node_preprocess_bdd -->|"vehicle crops"| node_processed_crops
node_processed_crops -->|"loads crops"| node_dataset
node_config -->|"run settings"| node_main
node_wrapper -->|"launches Direction 1"| node_main
node_main -->|"constructs datasets"| node_dataset
node_main -->|"creates standard model"| node_classifier
node_main -->|"creates adaptation model"| node_dann
node_dataset -->|"labeled crops and domains"| node_training
node_classifier -->|"supervised model"| node_training
node_dann -->|"label and domain heads"| node_training
node_training -->|"predictions and checkpoints"| node_evaluation
node_evaluation -->|"aggregate CSVs"| node_results
node_main -->|"coordinates outputs"| node_results
node_classifier -.->|"feature extractor"| node_tsne
node_tsne -->|"uses utilities"| node_visualization
node_direction2_env -.->|"related dataset experiments"| node_dataset
node_direction2_idd -.->|"related IDD work"| node_idd_pipeline

click node_preprocess_bdd "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/Preprocessdata.py"
click node_dataset "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/dataset.py"
click node_config "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/config.py"
click node_main "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/main.py"
click node_wrapper "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/run_direction1.bat"
click node_classifier "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/models.py"
click node_dann "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/dann.py"
click node_training "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/train.py"
click node_evaluation "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/evaluate.py"
click node_results "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/all_results_summary.csv"
click node_tsne "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/run_tsne_bdd.py"
click node_visualization "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/visualise.py"
click node_direction2_env "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/direction2_env_only.py"
click node_direction2_idd "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/direction2_idd.py"
click node_idd_pipeline "https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/PreprocessIDD.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_raw_bdd,node_preprocess_bdd,node_processed_crops,node_dataset,node_config,node_main,node_wrapper,node_classifier,node_dann,node_training,node_evaluation,node_results,node_tsne,node_visualization,node_direction2_env,node_direction2_idd toneBlue
class node_idd_pipeline toneAmber
```

## Components

### BDD Day-to-Night Study

Primary vehicle-crop domain-adaptation pipeline.

- **Raw BDD100K images & labels**: external dataset · External source data and annotations.
- [BDD crop preprocessing](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/Preprocessdata.py): preprocessing · Extracts, organizes, and balances vehicle crops. · `Preprocessdata.py`
- **Processed domain crops**: dataset storage · Daytime source and nighttime target vehicle crops.
- [Training dataset boundary](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/dataset.py): PyTorch dataset · Loads crops, transforms them, and supplies class/domain metadata. · `dataset.py`
- [Experiment configuration](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/config.py): configuration module · Centralizes paths, seeds, hyperparameters, and run switches. · `config.py`
- [Experiment orchestrator](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/main.py): experiment entry point · Builds runs, models, datasets, checkpoints, and summaries. · `main.py`
- [Windows run wrapper](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/run_direction1.bat): execution wrapper · `run_direction1.bat`
- [Vehicle classifier](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/models.py): model definition · Backbone and classification head for bus, car, and truck. · `models.py`
- [DANN adaptation model](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/dann.py): adaptation architecture · Adds gradient reversal and a domain classifier over learned features. · `dann.py`
- [Training loops](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/train.py): training runtime · Runs source-only, target fine-tuning, and DANN optimization. · `train.py`
- [Metrics & aggregation](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/evaluate.py): evaluation module · Computes classification metrics and per-seed results. · `evaluate.py`
- [CSV result summaries](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/all_results_summary.csv): experiment outputs · Aggregate comparable source, target, and adaptation results. · `all_results_summary.csv`
- [BDD feature t-SNE](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/run_tsne_bdd.py): visualization entry point · Standalone feature-space visualization for the BDD study. · `run_tsne_bdd.py`
- [Visualization utilities](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/visualise.py): visualization module · `visualise.py`
- [Direction 2 environment variant](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/direction2_env_only.py): adjacent experiment · Adjacent direction-specific variant, not the primary BDD flow. · `direction2_env_only.py`
- [Direction 2 IDD variant](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/direction2_idd.py): adjacent experiment · Adjacent direction-specific variant, not the primary BDD flow. · `direction2_idd.py`

### Adjacent IDD Work

Separate supporting experiments outside the core BDD flow.

- [IDD preprocessing & analysis](https://github.com/vib06hav/mlpr_vib_rej_rish/blob/main/PreprocessIDD.py): adjacent pipeline · Includes IDD preparation, finalization, curation, and per-class evaluation. · `PreprocessIDD.py`

## Connections

- Raw BDD100K images & labels → BDD crop preprocessing: images and annotations
- BDD crop preprocessing → Processed domain crops: vehicle crops
- Processed domain crops → Training dataset boundary: loads crops
- Experiment configuration → Experiment orchestrator: run settings
- Windows run wrapper → Experiment orchestrator: launches Direction 1
- Experiment orchestrator → Training dataset boundary: constructs datasets
- Experiment orchestrator → Vehicle classifier: creates standard model
- Experiment orchestrator → DANN adaptation model: creates adaptation model
- Training dataset boundary → Training loops: labeled crops and domains
- Vehicle classifier → Training loops: supervised model
- DANN adaptation model → Training loops: label and domain heads
- Training loops → Metrics & aggregation: predictions and checkpoints
- Metrics & aggregation → CSV result summaries: aggregate CSVs
- Experiment orchestrator → CSV result summaries: coordinates outputs
- Vehicle classifier → BDD feature t-SNE: feature extractor
- BDD feature t-SNE → Visualization utilities: uses utilities
- Direction 2 environment variant → Training dataset boundary: related dataset experiments
- Direction 2 IDD variant → IDD preprocessing & analysis: related IDD work
