# owais-kamdar/retinal-fundus-disorder-detection architecture

> Architecture diagram of the GitHub repository owais-kamdar/retinal-fundus-disorder-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/owais-kamdar/retinal-fundus-disorder-detection
- Repository: https://github.com/owais-kamdar/retinal-fundus-disorder-detection

## Overview

##### Main Components
- User Interface: The Streamlit web application (main.py) that users interact with.
- Data Management: The directories holding the dataset:
- data/raw: Stores the original retinal images.
- data/processed: Contains pre-processed data used by the traditional ML approach.
- data/outputs: Holds any outputs, possibly from experiments or prediction results.
- Classification Approaches: Three distinct pipelines, each implemented as its own module:
- Naïve Rule-Based Classifier: Found in scripts/naive (main_test.py and model.py). Uses image features like edge density, brightness, and optic disc detection for classification.
- Deep Learning (EfficientNet-B4): Found in scripts/deep (model.py) together with the corresponding pretrained or fine-tuned model stored as mobilenetv3.pth in the models/ directory.
- Model Artifacts: The models directory hosts pre-trained weights and pipeline artifacts for both traditional and deep learning approaches.
- Notebooks: The experimentation and exploratory analysis documents (EDA.ipynb, naive_eva.ipynb) which give insights into data analysis and evaluation but are not part of the final runtime architecture.

##### Relationships and Data Flows
- Data Flow:
- User uploads an image via the Streamlit UI.
- The front-end (main.py) then dispatches the image to the different classification pipelines.
- Each approach (naïve, traditional, deep) processes the image separately:
▪ The naïve approach uses rule-based calculations.
▪ The traditional ML approach applies preprocessing (feature extraction, PCA) before the SVM model predicts.
▪ The deep learning module processes the input through the EfficientNet-based CNN.
- Results from all classifiers are then consolidated and displayed to the user through the UI.
- Data and Model Dependencies:
- Pre-processing scripts (setup.sh and scripts like make_dataset.sh) ensure that raw data is prepared (data/processed) for the machine learning pipelines.
- Model artifacts are loaded from the models directory during inference or training.

##### Architectural Patterns and Technologies
- Separation of Concerns: Differentiated pipelines for each classification approach allow for independent development, testing, and evaluation.
- Modular Design: The clear segregation in the file structure (scripts/naive, scripts/traditional, scripts/deep) reflects a modular approach.
- Integration: The Streamlit application acts as a unifying layer that integrates results from all three approaches.
- Technologies and Libraries:
- Python is the main language.
- SVM model leveraging scikit-learn (likely) for the traditional approach.
- Deep learning framework support for EfficientNet, possibly using PyTorch (indicated by the .pth extension and GPU/TPU requirement).
- Utility and setup scripts for environment configuration (setup.sh) and dependency management (requirements.txt, packages.txt).

##### Final Checklist
- Each component (UI, naive classifier, traditional ML classifier, deep learning classifier, data management, model repository) must be clearly marked.
- Aspects such as pre-processing steps, model training/inference, external dataset locations, and deployment scripts (setup.sh).

## Diagram (Mermaid)

```mermaid
flowchart TD 
    %% UI Layer
    subgraph "User Interface Layer"
        UI["Streamlit UI (main.py)"]:::ui
    end

    %% Classification Pipelines
    subgraph "Classification Pipelines"
        NAIV["Naïve Rule-Based Classifier"]:::naive
        TRAD["Traditional ML Classifier (SVM)"]:::traditional
        DEEP["Deep Learning Classifier (EfficientNet-B4)"]:::deep
    end

    %% Data Management
    subgraph "Data Management"
        RAW["Raw Data (data/raw)"]:::data
        PROC["Processed Data (data/processed)"]:::data
        OUT["Outputs (data/outputs)"]:::data
    end

    %% Model Artifacts
    subgraph "Model Artifacts"
        MODELS["Models Directory (models)"]:::models
    end

    %% Notebooks
    subgraph "Notebooks"
        NOTE["Data Analysis & Evaluation (notebooks)"]:::notebooks
    end

    %% Setup & Dependencies
    subgraph "Setup & Dependencies"
        SETUP["Setup Script (setup.sh)"]:::setup
        REQ["Requirements (requirements.txt)"]:::setup
        PACK["Packages (packages.txt)"]:::setup
    end

    %% Connections: UI to Classification Pipelines
    UI -->|"upload"| NAIV
    UI -->|"upload"| TRAD
    UI -->|"upload"| DEEP

    %% Connections: Classification Pipelines return results to UI
    NAIV -->|"results"| UI
    TRAD -->|"results"| UI
    DEEP -->|"results"| UI

    %% Data Flow in Data Management
    RAW -->|"process"| PROC
    PROC -->|"finalize"| OUT

    %% Data dependency: Traditional ML uses processed data
    PROC -->|"input"| TRAD

    %% Model Artifacts dependency: Traditional and Deep load models
    MODELS -->|"model_load"| TRAD
    MODELS -->|"model_load"| DEEP

    %% Setup & Dependencies interactions
    SETUP -->|"prepare"| RAW
    SETUP -->|"install"| MODELS
    SETUP -->|"configure"| UI

    %% Click Events
    click UI "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/blob/main/main.py"
    click RAW "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/data/raw"
    click PROC "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/data/processed"
    click OUT "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/data/outputs"
    click NAIV "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/scripts/naive"
    click TRAD "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/scripts/traditional"
    click DEEP "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/blob/main/scripts/deep/model.py"
    click MODELS "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/models"
    click NOTE "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/tree/main/notebooks"
    click SETUP "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/blob/main/setup.sh"
    click REQ "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/blob/main/requirements.txt"
    click PACK "https://github.com/owais-kamdar/retinal-fundus-disorder-detection/blob/main/packages.txt"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef naive fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef traditional fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef deep fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef data fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef models fill:#e2d6f3,stroke:#5a2d82,stroke-width:2px;
    classDef notebooks fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef setup fill:#faf2cc,stroke:#8a6d3b,stroke-width:2px;
```
