# gundatharuntej2006-hue/cv_proj architecture

> Architecture diagram of the GitHub repository gundatharuntej2006-hue/cv_proj, 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/gundatharuntej2006-hue/cv_proj
- Repository: https://github.com/gundatharuntej2006-hue/cv_proj

## Overview

This repository is a prototype for explainable TB screening from chest X-rays. Its documented user-to-result workflow accepts DICOM/PNG images, rejects unsuitable or out-of-distribution inputs, crops lung regions, classifies TB and detects lesions, then calibrates and triages cases for a dashboard worklist and PDF export. Supporting branches provide explainability, structured logs, and statistical evaluation, including external and challenge assessments. The sampled triage orchestrator shows direct component calls; broader product connections are based on the README, since several implementation modules were not sampled.

Main entry points: [`src/p4_pipeline/triage_orchestrator.py`](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/triage_orchestrator.py) (Pipeline orchestrator), [`src/p4_pipeline/conformal_triage.py`](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/conformal_triage.py) (Conformal triage), [`src/p2_gate/quality_gate.py`](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p2_gate/quality_gate.py) (Quality and OOD gate), [`src/p4_eval/tables.py`](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_eval/tables.py) (Evaluation tables)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Input and quality"]
  node_quality["Quality and OOD gate<br/>[quality_gate.py]"]
  node_orientation["View check"]
end

subgraph group_analysis["Image analysis"]
  node_preprocess["Lung preprocessing<br/>[preprocessing.py]"]
  node_classifier["TB classifier<br/>[classifier.py]"]
  node_detector["Lesion detector<br/>[dfine_detector.py]"]
  node_explain["Grad-CAM<br/>[gradcam.py]"]
end

subgraph group_decision["Triage and output"]
  node_calibration["Temperature scaling<br/>[calibration.py]"]
  node_triage["Conformal triage"]
  node_workflow["Pipeline orchestrator"]
  node_api["Pipeline API<br/>[api.py]"]
  node_dashboard["Dashboard worklist<br/>[dashboard.py]"]
  node_pdf["Case PDF export<br/>[pdf_generator.py]"]
  node_prediction_logs["Prediction logs<br/>[logging.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Evaluation tables<br/>[tables.py]"]
  node_eval_branches["External and challenge evaluation"]
  node_stats["Metrics and confidence intervals"]
end

subgraph group_core["Shared contracts"]
  node_schemas["Result schemas<br/>[schemas.py]"]
  node_governance["Validation and versioning<br/>[validators.py]"]
end

node_radiograph(("Chest X-ray"))

node_radiograph -->|"submits image"| node_quality
node_workflow -->|"evaluates"| node_quality
node_workflow -->|"predicts view"| node_orientation
node_workflow -->|"segments and crops"| node_preprocess
node_workflow -->|"predicts TB"| node_classifier
node_workflow -->|"detects lesions"| node_detector
node_workflow -->|"generates attribution"| node_explain
node_workflow -->|"calibrates probability"| node_calibration
node_workflow -->|"assigns category"| node_triage
node_api -->|"exposes pipeline"| node_workflow
node_quality -->|"rejects early"| node_workflow
node_triage -->|"feeds worklist"| node_dashboard
node_triage -->|"feeds case report"| node_pdf
node_triage -->|"records prediction"| node_prediction_logs
node_evaluation -->|"computes metrics"| node_stats
node_eval_branches -->|"uses metrics"| node_stats
node_workflow -->|"returns structured result"| node_schemas
node_evaluation -->|"checks evaluation gate"| node_governance
node_workflow -->|"stamps versions"| node_governance

click node_quality "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p2_gate/quality_gate.py"
click node_orientation "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p1_viewhead/orientation_checker.py"
click node_preprocess "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p1_data/preprocessing.py"
click node_classifier "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p2_cls/classifier.py"
click node_detector "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_det/dfine_detector.py"
click node_explain "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_xai/gradcam.py"
click node_calibration "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_stats/calibration.py"
click node_triage "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/conformal_triage.py"
click node_workflow "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/triage_orchestrator.py"
click node_api "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/api.py"
click node_dashboard "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p1_app/dashboard.py"
click node_pdf "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_ops/pdf_generator.py"
click node_prediction_logs "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_ops/logging.py"
click node_evaluation "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_eval/tables.py"
click node_eval_branches "https://github.com/gundatharuntej2006-hue/cv_proj/tree/main/src/p4_eval"
click node_stats "https://github.com/gundatharuntej2006-hue/cv_proj/tree/main/src/p4_stats"
click node_schemas "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/tbcore/schemas.py"
click node_governance "https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/tbcore/validators.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_quality,node_orientation toneBlue
class node_preprocess,node_classifier,node_detector,node_explain toneAmber
class node_calibration,node_triage,node_workflow,node_api,node_dashboard,node_pdf,node_prediction_logs toneMint
class node_evaluation,node_eval_branches,node_stats toneRose
class node_schemas,node_governance,node_radiograph toneIndigo
```

## Components

### Input and quality

- [Quality and OOD gate](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p2_gate/quality_gate.py): `src/p2_gate/quality_gate.py`
- [View check](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p1_viewhead/orientation_checker.py): `src/p1_viewhead/orientation_checker.py`

### Image analysis

- [Lung preprocessing](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p1_data/preprocessing.py): `src/p1_data/preprocessing.py`
- [TB classifier](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p2_cls/classifier.py): `src/p2_cls/classifier.py`
- [Lesion detector](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_det/dfine_detector.py): `src/p3_det/dfine_detector.py`
- [Grad-CAM](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_xai/gradcam.py): `src/p3_xai/gradcam.py`

### Triage and output

- [Temperature scaling](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_stats/calibration.py): `src/p4_stats/calibration.py`
- [Conformal triage](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/conformal_triage.py): `src/p4_pipeline/conformal_triage.py`
- [Pipeline orchestrator](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/triage_orchestrator.py): `src/p4_pipeline/triage_orchestrator.py`
- [Pipeline API](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_pipeline/api.py): `src/p4_pipeline/api.py`
- [Dashboard worklist](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p1_app/dashboard.py): `src/p1_app/dashboard.py`
- [Case PDF export](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_ops/pdf_generator.py): `src/p3_ops/pdf_generator.py`
- [Prediction logs](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p3_ops/logging.py): `src/p3_ops/logging.py`

### Evaluation

- [Evaluation tables](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/p4_eval/tables.py): `src/p4_eval/tables.py`
- [External and challenge evaluation](https://github.com/gundatharuntej2006-hue/cv_proj/tree/main/src/p4_eval): `src/p4_eval`
- [Metrics and confidence intervals](https://github.com/gundatharuntej2006-hue/cv_proj/tree/main/src/p4_stats): `src/p4_stats`

### Shared contracts

- [Result schemas](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/tbcore/schemas.py): `src/tbcore/schemas.py`
- [Validation and versioning](https://github.com/gundatharuntej2006-hue/cv_proj/blob/main/src/tbcore/validators.py): `src/tbcore/validators.py`

### Other components

- **Chest X-ray**

## Connections

- Chest X-ray → Quality and OOD gate: submits image (evidence: `README.md`)
- Pipeline orchestrator → Quality and OOD gate: evaluates (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → View check: predicts view (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → Lung preprocessing: segments and crops (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → TB classifier: predicts TB (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → Lesion detector: detects lesions (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → Grad-CAM: generates attribution (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → Temperature scaling: calibrates probability (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline orchestrator → Conformal triage: assigns category (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Pipeline API → Pipeline orchestrator: exposes pipeline (evidence: `src/p4_pipeline/api.py`)
- Quality and OOD gate → Pipeline orchestrator: rejects early (evidence: `README.md`)
- Conformal triage → Dashboard worklist: feeds worklist (evidence: `README.md`)
- Conformal triage → Case PDF export: feeds case report (evidence: `README.md`)
- Conformal triage → Prediction logs: records prediction (evidence: `README.md`)
- Evaluation tables → Metrics and confidence intervals: computes metrics (evidence: `src/p4_eval/tables.py`)
- External and challenge evaluation → Metrics and confidence intervals: uses metrics (evidence: `src/p4_eval/external.py`)
- Pipeline orchestrator → Result schemas: returns structured result (evidence: `src/p4_pipeline/triage_orchestrator.py`)
- Evaluation tables → Validation and versioning: checks evaluation gate
- Pipeline orchestrator → Validation and versioning: stamps versions
