How shivammitra/parkinson-disease-detection works
Purpose and Entry Points
This is a local Parkinson’s-disease screening prototype that classifies spiral and wave drawing images as healthy or Parkinson’s, with optional clinical-data integration. Primary executable paths are training (train.py, enhanced_train.py), inference (predict.py, enhanced_predict.py), synthetic-data generation (enhanced_data_generator.py), and interactive diagnostics (diagnostic_app.py).
Configuration and Data Boundary
config.py centralizes model/data parameters and expected clinical columns. Image datasets are loaded and preprocessed through data_loader.py; the repository also includes a tabular source, data.xlsx.csv. Input data is an external filesystem boundary: images are expected in spiral/wave and class-specific directories, while trained artifacts are written to model-save locations configured by the application.
Data Preparation and Augmentation
The data pipeline converts drawing images into model-ready tensors and, for traditional ML, feature vectors. enhanced_data_generator.py creates configurable synthetic spiral and wave samples to expand training data; prepare_data.py and generate_sample_data.py support dataset preparation/sample generation. This stage separates raw images from normalized, augmented, or synthesized training inputs.
Model Families
Core model definitions are split between baseline and enhanced architectures:
• model.py: CNN, transfer-learning, and traditional-model-oriented implementations.
• enhanced_model.py: deeper CNN variants, MobileNet/EfficientNet adaptations, and ensemble behavior.
• utils.py: shared feature/processing support used across model workflows.
The system supports direct image CNN classification, pretrained transfer-learning backbones (VGG16/ResNet50/MobileNet/EfficientNet), HOG-driven Random Forest/SVM/Gradient Boosting models, and an ensemble that combines model predictions.
Training and Evaluation Flow
train.py dispatches baseline or classical model training, including selecting a named model or training all configured models. enhanced_train.py runs the enhanced model path with epochs, batch size, and augmentation controls. Training consumes prepared images/features, handles stated class-imbalance strategies such as SMOTE, and persists checkpoints for later inference. evaluate.py calculates classification quality including accuracy, precision/recall/F1, sensitivity, specificity, ROC/AUC.
Prediction and User Interfaces
CLI inference begins at predict.py or enhanced_predict.py: an image is preprocessed consistently with the selected saved model, then returned with class/confidence output. predict.py --web_interface exposes local interactive inference; web_interface.py and debug_gradio.py provide Gradio-facing UI paths. Additional front ends—diagnostic_app.py, improved_app.py, and simple_app.py—support uploading drawings, comparing model variants, visualizing confidence, and testing generated patterns.
Runtime and External Dependencies
The project is Python-based (requirements.txt, setup.py) and depends materially on TensorFlow for CNN/transfer-learning models, scikit-learn for HOG/classical ML and evaluation, OpenCV for image processing, and Gradio for local browser-based interfaces. There is no indicated hosted backend or external production service; execution, datasets, model checkpoints, and Gradio serving are local-machine concerns.
Main entry points: data_loader.py Image loader & preprocessing · train.py Baseline/classical training · enhanced_train.py Enhanced training · predict.py Baseline inference
Components 19
Data preparation
- Drawing image filesystem · Spiral and wave images organized by diagnostic class.
- Clinical tabular data
data.xlsx.csv - Configuration · Central model, data, and clinical-column settings.
config.py - Image loader & preprocessing · Converts drawing images into normalized tensors and feature inputs.
data_loader.py - Synthetic drawing generator · Creates configurable spiral and wave training samples.
enhanced_data_generator.py - Dataset preparation · Prepares datasets and sample data.
prepare_data.py - Prepared training inputs · Normalized, augmented, synthesized images and feature vectors.
Model workflows
- Baseline model definitions · CNN, transfer-learning, and classical-model implementations.
model.py - Enhanced model definitions · Deep CNN, adapted backbones, and ensemble behavior.
enhanced_model.py - Shared features & processing · Supports HOG-oriented classical and image model workflows.
utils.py - Baseline/classical training · Selects named or all baseline and traditional models.
train.py - Enhanced training · Runs augmented enhanced-model training and imbalance handling.
enhanced_train.py - Evaluation metrics · Calculates classification and ROC/AUC metrics.
evaluate.py - Saved checkpoints · Locally persisted trained models for inference.
Local interfaces
- Baseline inference · Preprocesses an image and returns class confidence.
predict.py - Enhanced inference · Runs inference using enhanced saved models.
enhanced_predict.py - Gradio interfaces · Browser interfaces for upload, comparison, confidence, and diagnostics.
web_interface.py - Diagnostic app · Interactive drawing diagnostics and generated-pattern testing.
diagnostic_app.py - Local user
Connections 22
- Configuration → Image loader & preprocessing: configures
- Drawing image filesystem → Image loader & preprocessing: loads
- Synthetic drawing generator → Prepared training inputs: generates
- Drawing image filesystem → Dataset preparation: prepares
- Dataset preparation → Prepared training inputs: produces
- Image loader & preprocessing → Prepared training inputs: normalizes
- Shared features & processing → Baseline model definitions: supports features
- Prepared training inputs → Baseline/classical training: trains from
- Prepared training inputs → Enhanced training: trains from
- Baseline model definitions → Baseline/classical training: selected by
- Enhanced model definitions → Enhanced training: trained by
- Baseline/classical training → Saved checkpoints: saves
- Enhanced training → Saved checkpoints: saves
- Saved checkpoints → Evaluation metrics: evaluates
- Saved checkpoints → Baseline inference: loads
- Saved checkpoints → Enhanced inference: loads
- Image loader & preprocessing → Baseline inference: preprocesses input
- Image loader & preprocessing → Enhanced inference: preprocesses input
- Local user → Gradio interfaces: uses
- Local user → Diagnostic app: uses
- Gradio interfaces → Baseline inference: invokes
- Diagnostic app → Enhanced inference: invokes