All projects

Brain MRI Scans Classification

A brain tumor MRI classifier trained with Teachable Machine over four classes — glioma, meningioma, pituitary and none — exported to TensorFlow.js and served as a web app that runs the inference in the browser.

JavaScript Machine LearningTensorFlow.jsComputer Vision
mri-tumor-classifier.pdf · 1.7 MB Open the report

The problem

Extra project for the Artificial Intelligence course at the Universitat de les Illes Balears.

Classify brain MRI scans into four classes — glioma, meningioma, pituitary and no tumor — and deploy the result as a web app that runs the model in the browser, with no server doing the inference.

The emphasis is on the parts around the model rather than on the architecture itself: preparing and balancing the dataset, training and validating, and getting something small enough to ship on a static host.

How it works

  • Transfer learning — the classifier is trained with Teachable Machine on top of a pre-trained backbone, so a small dataset is enough to separate the four classes.
  • Dataset preparation — balancing across the four classes, image resizing and normalization before training.
  • Hyperparameter exploration — epochs, batch size and learning rate are swept, and the resulting models evaluated on an external test set kept out of training.
  • In-browser inference — the final model is exported to TensorFlow.js and loaded by a small web interface that displays the per-class probabilities and applies a confidence threshold, so an uncertain prediction is reported as uncertain instead of being forced into a label.

Running it

You only need a modern web browser and a static server.

  1. Clone the repository.
  2. Start a local static server — VS Code Live Server, or python -m http.server.
  3. Open the app and either upload an MRI image or pick one from the sample library.

Do not open the HTML file directly from disk: the TensorFlow.js model files are fetched over HTTP and a file:// page will fail on CORS. Always go through a local server.