# lindawangg/covid-net architecture

> Architecture diagram of the GitHub repository lindawangg/covid-net, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lindawangg/covid-net
- Repository: https://github.com/lindawangg/covid-net

## Overview

##### Project type and purpose
- This is a research-oriented machine-learning pipeline, not a web or full-stack application.
- Its goal is to detect COVID-19 (and pneumonia) from chest X-rays and assess disease severity.

##### File structure
- Top-level “create_*” directories: Jupyter notebooks that assemble raw sources into training/testing datasets (COVIDx, RICORD).
- data.py: data loader / preprocessing functions.
- train_tf.py and train_risknet.py: different training scripts (TensorFlow-based model vs. RiskNet variant).
- eval*.py: evaluation scripts for overall performance and pneumonia subset.
- inference*.py: scripts to run model inference (COVID detection, pneumonia, severity).
- labels/: text files listing image IDs and ground-truth labels for train/test splits.
- assets/: published papers and PDFs, for reference.
- docs/: markdown documentation on models, datasets, training & inference procedures.
- annotations/: CSV of severity annotations.
- requirements.txt: dependency list for environment setup.

##### Available documentation
- Although README.md is empty, docs/ contains:
- COVIDx dataset description
- Model architectures (COVIDNet, RiskNet)
- Training, evaluation, inference workflows
- FAQs and notes on severity scoring

##### Main components and their interactions
a. Data ingestion & preprocessing
- Raw DICOM/PNG X-ray files and annotation CSVs → create_COVIDx notebooks → standardized dataset
- RICORD data mapping → create_ricord_dataset notebooks
- data.py exposes loader API for training/inference scripts
b. Model training
- train_tf.py and train_risknet.py invoke data.py to read processed data → train models → output saved checkpoints/artifacts
c. Evaluation
- eval.py, eval_pneumonia.py load model checkpoints → compute metrics on hold-out sets → output reports/plots
d. Inference
- inference.py, inference_pneumonia.py, inference_severity.py load a trained model → run on new images → produce predictions
e. Documentation & assets
- docs/ and assets/ contain supporting materials but do not participate in the runtime pipeline

##### Architectural patterns & design principles
- Modular pipeline: clear separation of data preparation, training, evaluation, inference
- Reusable data loader (data.py) for all downstream scripts
- Directory-per-responsibility: notebooks for dataset creation, scripts for compute, docs and assets isolated
- Scripts follow pull-based design: each stage pulls inputs from previous stage’s outputs

##### Detail without over-splitting
- Logical piece (dataset creation, loader, model training, eval, inference)
- Data flow is end-to-end from raw data to final predictions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    ExtData[(Raw DICOM/PNG & External CSV)]:::datablue
    Labels[(labels/)]:::datablue
    SEV_ANN[(annotations/severity_annotations.csv)]:::datablue

    %% Preprocessing Notebooks
    NB1["create_COVIDx.ipynb"]:::compute
    NB2["create_COVIDxSev.ipynb"]:::compute
    NB3["create_COVIDx_binary.ipynb"]:::compute
    NB4["create_ricord_dataset.ipynb"]:::compute
    ProcessedData[(Processed Datasets)]:::datablue

    ExtData -->|"use raw images"| NB1
    ExtData -->|"use raw images"| NB2
    ExtData -->|"use raw images"| NB3
    ExtData -->|"use raw images"| NB4
    NB1 -->|"produce TFRecords"| ProcessedData
    NB2 -->|"produce TFRecords"| ProcessedData
    NB3 -->|"produce TFRecords"| ProcessedData
    NB4 -->|"produce TFRecords"| ProcessedData

    %% Data Loader
    DataPy["data.py"]:::compute
    ProcessedData -->|"load processed data"| DataPy
    Labels -->|"load labels"| DataPy
    SEV_ANN -->|"load annotations"| DataPy

    %% Training Engines
    Train1["train_tf.py"]:::compute
    Train2["train_risknet.py"]:::compute
    DataPy -->|"fetch train/test sets"| Train1
    DataPy -->|"fetch train/test sets"| Train2

    %% Model Artifacts
    Checkpoints[(Model Checkpoints)]:::datablue
    Train1 -->|"save checkpoints"| Checkpoints
    Train2 -->|"save checkpoints"| Checkpoints

    %% Evaluation Engines
    Eval1["eval.py"]:::compute
    Eval2["eval_pneumonia.py"]:::compute
    Checkpoints -->|"load checkpoint"| Eval1
    Checkpoints -->|"load checkpoint"| Eval2

    %% Inference Engines
    Inf1["inference.py"]:::compute
    Inf2["inference_pneumonia.py"]:::compute
    Inf3["inference_severity.py"]:::compute
    Checkpoints -->|"load checkpoint"| Inf1
    Checkpoints -->|"load checkpoint"| Inf2
    Checkpoints -->|"load checkpoint"| Inf3

    %% Documentation & Assets
    Docs["docs/"]:::docsorange
    Assets["assets/"]:::docsorange
    requirements["requirements.txt"]:::docsorange

    Docs -.->|"reference workflows"| DataPy
    Docs -.->|"reference architectures"| Train1
    Assets -.->|"supplementary papers"| NB1
    requirements -.->|"environment specs"| Train1
    requirements -.->|"environment specs"| Eval1
    requirements -.->|"environment specs"| Inf1

    %% Click Events
    click NB1 "https://github.com/lindawangg/covid-net/blob/master/create_COVIDx.ipynb"
    click NB2 "https://github.com/lindawangg/covid-net/blob/master/create_COVIDxSev.ipynb"
    click NB3 "https://github.com/lindawangg/covid-net/blob/master/create_COVIDx_binary.ipynb"
    click NB4 "https://github.com/lindawangg/covid-net/blob/master/create_ricord_dataset/create_ricord_dataset.ipynb"
    click DataPy "https://github.com/lindawangg/covid-net/blob/master/data.py"
    click Train1 "https://github.com/lindawangg/covid-net/blob/master/train_tf.py"
    click Train2 "https://github.com/lindawangg/covid-net/blob/master/train_risknet.py"
    click Eval1 "https://github.com/lindawangg/covid-net/blob/master/eval.py"
    click Eval2 "https://github.com/lindawangg/covid-net/blob/master/eval_pneumonia.py"
    click Inf1 "https://github.com/lindawangg/covid-net/blob/master/inference.py"
    click Inf2 "https://github.com/lindawangg/covid-net/blob/master/inference_pneumonia.py"
    click Inf3 "https://github.com/lindawangg/covid-net/blob/master/inference_severity.py"
    click Labels "https://github.com/lindawangg/covid-net/tree/master/labels/"
    click SEV_ANN "https://github.com/lindawangg/covid-net/blob/master/annotations/severity_annotations.csv"
    click Docs "https://github.com/lindawangg/covid-net/tree/master/docs/"
    click Assets "https://github.com/lindawangg/covid-net/tree/master/assets/"
    click requirements "https://github.com/lindawangg/covid-net/blob/master/requirements.txt"

    %% Styles
    classDef datablue fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef compute fill:#c8e6c9,stroke:#388e3c,color:#1b5e20
    classDef docsorange fill:#ffe0b2,stroke:#fb8c00,color:#e65100
```
