# talhasaleemm/malaria-detection architecture

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

- Interactive diagram: https://gitdiagram.com/talhasaleemm/malaria-detection
- Repository: https://github.com/talhasaleemm/malaria-detection

## Overview

This is a malaria microscopy object-detection product: users upload slides or videos and receive localized parasite detections and annotated results. The documented image flow runs from the Streamlit dashboard through a FastAPI endpoint to SAHI/YOLO inference and back for display; the dashboard also processes videos frame by frame. The repository additionally includes dataset preparation, model training, and validation workflows. Edges follow the README or shown source references; some training and dataset-stage connections are omitted because their runtime wiring is not shown.

Main entry points: [`src/app.py`](https://github.com/talhasaleemm/malaria-detection/blob/main/src/app.py) (Streamlit dashboard), [`models/production_model.pt`](https://github.com/talhasaleemm/malaria-detection/blob/main/models/production_model.pt) (YOLO weights), [`src/main.py`](https://github.com/talhasaleemm/malaria-detection/blob/main/src/main.py) (Inference API), [`src/validate_real.py`](https://github.com/talhasaleemm/malaria-detection/blob/main/src/validate_real.py) (Real-data validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clinical["Clinical workflows"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
  node_api["Inference API<br/>[main.py]"]
  node_image_results["Slide results<br/>[app.py]"]
  node_video_processor["Video processor<br/>[video_processor.py]"]
end

subgraph group_inference["Detection inference"]
  node_sahi{{"SAHI inference<br/>[main.py]"}}
  node_yolo_model["YOLO weights"]
  node_folder_detection["Folder detection<br/>[detect_folder.py]"]
end

subgraph group_data["Dataset preparation"]
  node_cell_images["Cell image inputs"]
  node_compositor["Synthetic slide compositor<br/>[data_pipeline.py]"]
  node_iml_inputs["IML dataset inputs"]
  node_iml_converter["IML annotation converter"]
  node_yolo_dataset["YOLO dataset"]
end

subgraph group_model_ops["Model workflows"]
  node_trainer["YOLO training<br/>[train_yolo.py]"]
  node_real_validation["Real-data validation<br/>[validate_real.py]"]
end

node_user(("Clinical user"))

node_user -->|"uploads slide/video"| node_dashboard
node_dashboard -->|"posts slide"| node_api
node_api -->|"runs inference"| node_sahi
node_sahi -.->|"loads weights"| node_yolo_model
node_sahi -->|"returns detections"| node_api
node_api -->|"returns JSON"| node_dashboard
node_dashboard -->|"renders annotations"| node_image_results
node_dashboard -->|"invokes processing"| node_video_processor
node_video_processor -->|"loads weights"| node_yolo_model
node_dashboard -->|"shows results"| node_user
node_cell_images -->|"supplies cells"| node_compositor
node_iml_inputs -->|"supplies annotations"| node_iml_converter
node_iml_converter -->|"writes YOLO data"| node_yolo_dataset
node_compositor -.->|"generates training data"| node_yolo_dataset
node_yolo_dataset -.->|"trains on data"| node_trainer
node_trainer -.->|"produces weights"| node_yolo_model
node_folder_detection -->|"loads weights"| node_yolo_model
node_real_validation -->|"loads weights"| node_yolo_model
node_real_validation -->|"reads test split"| node_yolo_dataset

click node_dashboard "https://github.com/talhasaleemm/malaria-detection/blob/main/src/app.py"
click node_api "https://github.com/talhasaleemm/malaria-detection/blob/main/src/main.py"
click node_image_results "https://github.com/talhasaleemm/malaria-detection/blob/main/src/app.py"
click node_video_processor "https://github.com/talhasaleemm/malaria-detection/blob/main/src/video_processor.py"
click node_sahi "https://github.com/talhasaleemm/malaria-detection/blob/main/src/main.py"
click node_yolo_model "https://github.com/talhasaleemm/malaria-detection/blob/main/models/production_model.pt"
click node_folder_detection "https://github.com/talhasaleemm/malaria-detection/blob/main/src/detect_folder.py"
click node_cell_images "https://github.com/talhasaleemm/malaria-detection/tree/main/cell_images"
click node_compositor "https://github.com/talhasaleemm/malaria-detection/blob/main/src/data_pipeline.py"
click node_iml_inputs "https://github.com/talhasaleemm/malaria-detection/tree/main/temp_iml_dataset"
click node_iml_converter "https://github.com/talhasaleemm/malaria-detection/blob/main/src/convert_iml_to_yolo.py"
click node_trainer "https://github.com/talhasaleemm/malaria-detection/blob/main/src/train_yolo.py"
click node_real_validation "https://github.com/talhasaleemm/malaria-detection/blob/main/src/validate_real.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_dashboard,node_api,node_image_results,node_video_processor,node_user toneBlue
class node_sahi,node_yolo_model,node_folder_detection toneAmber
class node_cell_images,node_compositor,node_iml_inputs,node_iml_converter,node_yolo_dataset toneMint
class node_trainer,node_real_validation toneRose
```

## Components

### Clinical workflows

- [Streamlit dashboard](https://github.com/talhasaleemm/malaria-detection/blob/main/src/app.py): `src/app.py`
- [Inference API](https://github.com/talhasaleemm/malaria-detection/blob/main/src/main.py): `src/main.py`
- [Slide results](https://github.com/talhasaleemm/malaria-detection/blob/main/src/app.py): `src/app.py`
- [Video processor](https://github.com/talhasaleemm/malaria-detection/blob/main/src/video_processor.py): `src/video_processor.py`

### Detection inference

- [SAHI inference](https://github.com/talhasaleemm/malaria-detection/blob/main/src/main.py): `src/main.py`
- [YOLO weights](https://github.com/talhasaleemm/malaria-detection/blob/main/models/production_model.pt): `models/production_model.pt`
- [Folder detection](https://github.com/talhasaleemm/malaria-detection/blob/main/src/detect_folder.py): `src/detect_folder.py`

### Dataset preparation

- [Cell image inputs](https://github.com/talhasaleemm/malaria-detection/tree/main/cell_images): `cell_images`
- [Synthetic slide compositor](https://github.com/talhasaleemm/malaria-detection/blob/main/src/data_pipeline.py): `src/data_pipeline.py`
- [IML dataset inputs](https://github.com/talhasaleemm/malaria-detection/tree/main/temp_iml_dataset): `temp_iml_dataset`
- [IML annotation converter](https://github.com/talhasaleemm/malaria-detection/blob/main/src/convert_iml_to_yolo.py): `src/convert_iml_to_yolo.py`
- **YOLO dataset**

### Model workflows

- [YOLO training](https://github.com/talhasaleemm/malaria-detection/blob/main/src/train_yolo.py): `src/train_yolo.py`
- [Real-data validation](https://github.com/talhasaleemm/malaria-detection/blob/main/src/validate_real.py): `src/validate_real.py`

### Other components

- **Clinical user**

## Connections

- Clinical user → Streamlit dashboard: uploads slide/video (evidence: `README.md`)
- Streamlit dashboard → Inference API: posts slide (evidence: `README.md`)
- Inference API → SAHI inference: runs inference (evidence: `src/main.py`)
- SAHI inference → YOLO weights: loads weights
- SAHI inference → Inference API: returns detections (evidence: `README.md`)
- Inference API → Streamlit dashboard: returns JSON (evidence: `README.md`)
- Streamlit dashboard → Slide results: renders annotations (evidence: `src/app.py`)
- Streamlit dashboard → Video processor: invokes processing (evidence: `src/app.py`)
- Video processor → YOLO weights: loads weights (evidence: `src/video_processor.py`)
- Streamlit dashboard → Clinical user: shows results (evidence: `README.md`)
- Cell image inputs → Synthetic slide compositor: supplies cells (evidence: `src/data_pipeline.py`)
- IML dataset inputs → IML annotation converter: supplies annotations (evidence: `src/convert_iml_to_yolo.py`)
- IML annotation converter → YOLO dataset: writes YOLO data (evidence: `src/convert_iml_to_yolo.py`)
- Synthetic slide compositor → YOLO dataset: generates training data
- YOLO dataset → YOLO training: trains on data
- YOLO training → YOLO weights: produces weights
- Folder detection → YOLO weights: loads weights (evidence: `src/detect_folder.py`)
- Real-data validation → YOLO weights: loads weights (evidence: `src/validate_real.py`)
- Real-data validation → YOLO dataset: reads test split (evidence: `src/validate_real.py`)
