CoolFace
Apppublic

Karthickmk/neuro-symbolic-medical-ai

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

Neuro-Symbolic AI for Explainable Medical Image Diagnosis

A full end-to-end prototype system implementing neuro-symbolic AI for explainable medical image diagnosis across chest X-ray and dermoscopy modalities, as described in the accompanying research report.

Architecture

The system combines:

  • —Neural component — Random Forest + MLP ensemble trained on HOG, colour, and statistical features
  • —Symbolic component — Domain rule engine encoding radiology and dermoscopy clinical concepts
  • —Explainability module — Feature-importance saliency overlays, concept radar charts, confusion matrices
  • —Database layer — SQLite schema linking datasets → images → concepts → predictions → explanations
  • —Web interface — Flask dashboard for pipeline control, prediction inspection, and database browsing

Requirements

Python 3.10+ is required.

bash
pip install -r requirements.txt

Quick Start

1. Start the web server (recommended)

bash
python run.py

The browser opens automatically at http://127.0.0.1:5000.

Then click "Run Pipeline" on the Pipeline page to generate synthetic data, train both models, run inference, and populate the database. The whole process takes 2–4 minutes.

2. Run pipeline first, then server

bash
python run.py --run-pipeline

3. Command-line options

--host HOST        Bind host (default: 0.0.0.0)
--port PORT        Bind port (default: 5000)
--no-browser       Skip auto-opening the browser
--run-pipeline     Execute the full pipeline before starting Flask

Web Interface Pages

PageURLDescription
Home/System overview, dataset summary, architecture diagram
Pipeline/pipelineRun pipeline, view live console log
Dashboard/dashboardModel metrics, confusion matrices, performance plots
Predictions/predictionsBrowse all stored predictions with overlays and symbolic traces
Predict/predictUpload your own image for single-image inference
Database/databaseSQLite schema viewer and recent record browser

Project Structure

neuro_symbolic_medical_ai/
├── run.py                    # Entry point — starts Flask server
├── config.py                 # Global configuration
├── requirements.txt
├── pipeline/
│   ├── database.py           # SQLite schema and CRUD
│   ├── data_generator.py     # Synthetic smoke-test image generation
│   ├── feature_extractor.py  # HOG, colour, statistical features + concepts
│   ├── model.py              # RF + MLP ensemble classifier
│   ├── symbolic_engine.py    # Rule-based clinical reasoning
│   ├── explainer.py          # Saliency overlays and visualisation
│   └── pipeline_runner.py    # Orchestrates the full pipeline
├── web/
│   ├── app.py                # Flask routes
│   ├── templates/            # Jinja2 HTML templates
│   └── static/               # CSS and JS
├── data/                     # Auto-generated synthetic images
└── outputs/
    ├── models/               # Trained classifier pickles
    ├── plots/                # Confusion matrices, performance charts
    ├── overlays/             # Per-image saliency overlays
    └── reports/              # JSON pipeline summary report

Datasets (Synthetic Smoke-Test)

The prototype generates 460 synthetic images proportionally representing four public datasets:

Dataset AliasModalitySynthetic SamplesReal Dataset
nihchestxray_demoChest X-ray160NIH Chest X-ray (112K)
covidradiographydemoChest X-ray90COVID-19 Radiography (21K)
ham10000_demoDermoscopy120HAM10000 (10K)
isic_demoDermoscopy90ISIC 2020 (33K)

Notes

  • —All performance metrics (accuracy, F1) are on synthetic data and serve only to validate the software pipeline, not clinical utility.
  • —To use real datasets, replace the contents of data/ with actual images and re-run the pipeline.
  • —The symbolic agreement rate on synthetic data is lower than ideal (~29%) because synthetic images do not faithfully reproduce the real-world correlation between visual features and clinical labels.