# sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images architecture

> Architecture diagram of the GitHub repository sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images
- Repository: https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images

## Overview

Step 1: Identify Project Type and Purpose
- This is a research‐driven machine‐learning pipeline implemented as Jupyter notebooks.
- Purpose: Bi‐level classification of chest X-ray images into Normal, Pneumonia, or COVID-19.
- Key stages: feature extraction with a pre‐trained CNN (VGG19) and two levels of shallow‐learner classification.

Step 2: Analyze File Structure
- Top-level consists of five Jupyter notebooks and one image (flow chart):
1. Feature Extraction_vgg19 (1).ipynb – extract deep features.
2. Test_hier.ipynb – orchestrates the two‐level (hierarchical) prediction.
3. Testing_covidxc.ipynb – level-1 test (Normal vs Infected).
4. Testing_lv2_covidxc.ipynb – level-2 test (Pneumonia vs COVID).
- No “src/” or “lib/” folders; the notebooks themselves define modules.
- No deployment scripts; it is an experimental/research pipeline.

Step 3: Extract Insights from README
- The flow chart in README shows data flowing through feature‐extractor → level-1 classifier → level-2 classifier → results.
- Frameworks: Python, Jupyter, Keras (VGG19), scikit-learn (Logistic Regression, k-NN, CART, RF, XGBoost).
- Dataset size is 3,168 labeled chest X-ray images.

Step 4: Key Components & Their Interactions
a. Components
1. Data Source: Balanced CXR image dataset (disk or drive).
2. Preprocessing Module: image resizing, normalization.
3. Feature Extraction Module: VGG19 pre-trained CNN.
4. Level-1 Classifier Module: ensemble of shallow learners (LR, k-NN, CART, RF, XGB).
5. Level-2 Classifier Module: same set of classifiers for infected cases.
6. Evaluation & Reporting Module: accuracy metrics, confusion matrices, plots.
7. Orchestration (Notebooks): coordinate end-to-end flow.

b. Relationships / Data Flow
- Data Source → Preprocessing → Feature Extraction → Level-1 Classifier.
- Level-1 output (“Infected”) branches into Level-2 Classifier; “Normal” is final.
- Both classifier outputs feed into the Evaluation & Reporting module.

c. Architectural Patterns & Principles
- Pipeline pattern: sequential stages with clear data transformations.
- Hierarchical decision tree: first filter, then refine.
- Modular design: each notebook/module handles one responsibility.
- Reproducibility emphasis via Jupyter notebooks and saved flow chart.

d. Technologies & Frameworks
- Python 3.x
- Jupyter Notebook
- Keras/TensorFlow (VGG19)
- scikit-learn (shallow learners)
- NumPy, Pandas, Matplotlib/Seaborn (data handling & visualization)

- Since this is an ML research pipeline, focus on data flow and module boundaries rather than client-server separation.
- Two-level classification hierarchy.
- How notebooks orchestrate or call into preprocessing/feature extraction/classification code.

Step 6: Diagramming Best Practices
##### Clear labels
- Name each component (e.g., “VGG19 Feature Extractor”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Store
    Dataset[(Dataset<br/>3,168 CXR Images)]:::data

    %% Processing Modules
    Preprocessing["Preprocessing<br/>224×224 Resize<br/>Normalization"]:::process
    FeatureExtract["VGG19 Feature Extractor<br/>4,096-D Features"]:::process
    Level1["Level-1 Classifier<br/>Normal vs Infected"]:::process
    decision{"Infected?"}:::decision
    NormalOut["Output: Normal"]:::data
    Level2["Level-2 Classifier<br/>Pneumonia vs COVID-19"]:::process
    Results["Evaluation & Reporting<br/>Metrics, Confusion Matrices, Plots"]:::process

    %% Orchestration Notebook
    TestHier[/Orchestration Notebook<br/>Hierarchical Pipeline/]:::notebook

    %% Project Overview Reference
    README["Project Overview<br/>Flow Chart Reference"]:::data

    %% Data Flow
    Dataset --> Preprocessing --> FeatureExtract --> Level1 --> decision
    decision -->|No| NormalOut --> Results
    decision -->|Yes| Level2 --> Results

    %% Orchestration Control Flow
    TestHier -.-> Preprocessing
    TestHier -.-> FeatureExtract
    TestHier -.-> Level1
    TestHier -.-> Level2
    TestHier -.-> Results

    %% Project Overview link
    README --- TestHier

    %% Click Events
    click Preprocessing "https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images/blob/main/Feature Extraction_vgg19 (1).ipynb"
    click Level1 "https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images/blob/main/Testing_covidxc.ipynb"
    click Level2 "https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images/blob/main/Testing_lv2_covidxc.ipynb"
    click TestHier "https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images/blob/main/Test_hier.ipynb"
    click Results "https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images/blob/main/Test_hier.ipynb"
    click README "https://github.com/sdrxc/bi-level-prediction-model-for-screening-covid-19-from-chest-x-ray-images/blob/main/README.md"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef process fill:#90EE90,stroke:#000,stroke-width:1px
    classDef notebook fill:#FFA500,stroke:#000,stroke-width:1px
    classDef decision fill:#FFD700,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
```
