Research Demo

Brain MRI Tumor Augmentation using GANs

A Deep Convolutional GAN (DCGAN) trained on brain MRI tumor scans to generate synthetic images and explore the learned latent space through LERP and SLERP interpolation.

DCGAN
Architecture
64 × 64 px
Resolution
139.55
FID Score
100
Epochs
0.0002
Learning Rate

Generate a Random Tumor

Sample a random point from the 100-dimensional latent space and decode it through the trained generator to produce a synthetic MRI scan.

Click to generate your first synthetic scan.

Generate an image
to begin

Sample Generated Tumors

A batch of 18 synthetic scans sampled from across the latent space — generated freshly on page load.

Latent Space Interpolation

Generate two distinct tumor scans, then interpolate through the latent space between them. The GAN decodes each intermediate point into a unique image — revealing how the model organises learned features.

Example Image A
Example Image A
LERP from A to B
LERP
SLERP from A to B
SLERP
Example Image B
Example Image B

Try interpolation yourself

Generate images A and B and click "interpolate" to explore the latent path.

Image A
No image yet
LERP
Run interpolation
Linear path
SLERP
Run interpolation
Spherical arc
Image B
No image yet

Generate Image A and Image B first, then click Interpolate.

LERP vs SLERP

LERPLinear Interpolation

Moves directly between two latent vectors along a straight line in Euclidean space. Simple and fast, but the midpoint of a straight line in high-dimensional space often lands in a low-density region of the learned distribution.

z = (1−t)·zA + t·zB
SLERPSpherical Interpolation

Follows the surface of the latent hypersphere, maintaining a constant magnitude at every step. This keeps intermediate points within the high-density region of the latent space, typically yielding smoother and more realistic transitions.

z = sin((1−t)Ω)/sin(Ω)·zA + sin(tΩ)/sin(Ω)·zB

Geometric intuition — LERP cuts across; SLERP follows the arc of the hypersphere

LERPABstraight pathSLERPABarc on sphere

Technical Details

A full-stack ML research demo built with modern tooling from model training through to the interactive frontend.

🧠
DCGAN Architecture
Deep Convolutional GAN with BatchNorm, ReLU generator and LeakyReLU discriminator.
🩻
Brain MRI Dataset
Trained on labelled brain MRI tumor scans sourced from Kaggle.
📊
FID Evaluation
Fréchet Inception Distance of 139.55 measures distributional similarity to real scans.
🔀
Latent Interpolation
50-frame interpolations computed server-side and returned as base64 frame sequences.
📐
LERP vs SLERP
Both paths computed per request, enabling instant client-side toggling with no extra API calls.
FastAPI Backend
Async Python backend serves generation and interpolation endpoints with PyTorch inference.
🌐
Next.js Frontend
React Server / Client components, TailwindCSS v4, in-browser GIF encoding.
🔥
PyTorch Training
Model trained using PyTorch with Adam optimiser, lr 0.0002, β₁ 0.5 for 100 epochs.