How vivek02sharma/neuroscan works
Project type and purpose
• This is a machine-learning powered web application built with Streamlit.
• Its purpose is to let users upload an MRI image, preprocess it, run inference through a pre-trained CNN (brain-tumor-model.h5), and display the predicted tumor class and associated probabilities.
• It also includes a training pipeline (train.py) that can retrain the CNN on the brain-tumor-dataset and produce an updated model file.
File structure
• Top-level files:
• main.py – the Streamlit app entry point (UI + inference logic)
• train.py – the training pipeline script
• brain-tumor-model.h5 – the serialized Keras/TensorFlow model
• brain-tumor-dataset/ – raw MRI images organized by class for training
• brain-tumor-classification.ipynb – exploratory notebook
• requirements.txt – Python dependencies
• .streamlit/config.toml – Streamlit runtime configuration
• .devcontainer/ – VS Code devcontainer settings
• Pattern: single-page web app (frontend + backend combined in main.py) + separate training workflow.
Key insights from the README
• Tech stack: Python 3.7+, Streamlit for UI, TensorFlow/Keras for model, Pillow for image I/O.
• Workflow:
1. User uploads image
2. Preprocessing (grayscale + resize to 300×300)
3. Model prediction
4. Class & probabilities
• Optional: retrain model via train.py using the organized dataset.
Main components
a. Presentation layer (Streamlit UI in main.py)
b. Preprocessing module (image loader, convert-to-grayscale, resize)
c. Inference engine (TensorFlow/Keras model loader + predictor)
d. Data storage
– Model storage (brain-tumor-model.h5)
– Training data (brain-tumor-dataset/)
e. Training pipeline (train.py)
f. External libraries/frameworks (Streamlit, TensorFlow, Pillow)
g. Optional: Dev environment config (.devcontainer)
Relationships and interactions
• User → Streamlit UI: upload MRI image file
• UI → Preprocessing: pass raw image
• Preprocessing → Inference engine: standardized image array
• Inference engine → Model file: loads brain-tumor-model.h5 once at start
• Inference engine → Output: class labels + probability scores
• UI ← Inference results: display to user
• Training pipeline (train.py) → Reads brain-tumor-dataset → Applies data augmentation/preprocessing → Trains CNN → Writes updated brain-tumor-model.h5
• Devcontainer config provides a reproducible dev/workspace environment.
Architectural patterns and design principles
• Layered architecture:
• Presentation (Streamlit)
• Application logic (preprocessing + prediction)
• Model artifact layer (stored H5)
• Data persistence (dataset folder)
• Single-process, event-driven web server
• Separation of concerns: main.py focuses on inference/UI, train.py on model training.
Diagramming recommendations
• “Streamlit App (main.py)”
• “Image Preprocessor”
• “CNN Inference Engine (TensorFlow)”
• “Model Storage (.h5)”
• “Training Pipeline (train.py)”
• “Dataset Storage (brain-tumor-dataset/)”
• Blue for user-facing/UI
• Green for data processing modules
• Orange for ML model artifacts
• Gray for storage/configuration