# End 2 End Tumor Detection

I built END-2-END-Tumor-Detection as an end-to-end project for brain MRI and breast scan classification, with Grad-CAM explanations, training experiments, a FastAPI inference backend, and a lightweight web interface.

My END-2-END-Tumor-Detection repository is Jupyter Notebook; started 2026-11, last updated 2026-11.

My project provides 5-class classification — `No Tumor`, `Tumor` (brain) and `Benign`, `Malignant`, `Normal` (breast).

My explainability method is Grad-CAM overlays highlight the regions that drove the prediction.

My `TrigConv2D` layer performs convolution with fixed sine/cosine kernels in `backend/models/loader.py`.

My API routes are `/predict` for classification, `/gradcam` for the heatmap overlay.

My model input format is 128 × 128 RGB, pixel values scaled to [0, 1].

The model I serve is `trig_model.keras` hosted at `Sauravyadav7721/Brain-Breast-Tumor`.

My compared models are Baseline CNN (3 × Conv2D + MaxPool, Dense(128), Dropout(0.5)); transfer-learning ResNet; Trig CNN using `TrigConv2D` and served by the API.

My dataset and split are Kaggle `khaledhellmy/brain-breast-tumor`; classes oversampled to balance them, then split 80/20 (`random_state=42`).

My model is downloaded from Hugging Face Hub and loaded lazily on the first request; first prediction after restart is slow.

My logging setup uses Daily rotating logs kept for 30 days.

I use `tensorflow-cpu` to keep the image and memory usage small.

My local prerequisites are Python 3.10+ and internet access on first run.

My server port defaults to 8000 and can be changed with the `PORT` environment variable.

My illustrative example gives a Tumor prediction for scan.jpg at 97.42%; probabilities No Tumor 0.01, Tumor 0.97, Benign 0.0, Malignant 0.01, Normal 0.01.

I deployed the project on Railway from the `Dockerfile`; Railway sets `PORT`, read by `run.py`.

My live demo is https://end-2-end-tumor-detection-production.up.railway.app/; Railway free credit; may be offline or take about a minute to wake on first request.

My medical disclaimer says research and educational purposes only; not a medical device and must not be used for clinical diagnosis.

I run the server with `python run.py`, then use the web app at `http://localhost:8000` or the interactive API documentation at `http://localhost:8000/docs`. I can build and run the container with `docker build -t tumor-detection-ai .` and `docker run -p 8000:8000 tumor-detection-ai`.

My `/predict` endpoint accepts an image in multipart form data under the `file` field and returns JSON containing `filename`, `prediction`, `confidence`, and `all_probs`. My `/gradcam` endpoint accepts the same image field and returns a PNG heatmap overlay. An example request is `curl -X POST http://localhost:8000/predict -F "file=@scan.jpg"`.

I train models in `experiments/trignometric-cnn.ipynb`. The notebook uses Kaggle-specific `/kaggle/input/...` paths, so I need to adjust paths for local reruns. I keep checkpoints in `checkpoints/`, exported models in `models/`, and run logs in `logs/`; these contents are git-ignored.

My repository includes a web frontend and a Dockerfile for deployment. For Railway, I push the repository to GitHub, deploy it through Railway’s GitHub-repository flow, and generate a public domain in service networking settings.

The README gives an illustrative API response but no comparative model metrics or training results. It also gives no dataset size, original class counts, oversampling details, split stratification, or quantitative evaluation of Grad-CAM quality or prediction performance. The current availability of the Railway demo is not established.

My repository is at https://github.com/sauravyadav7721/END-2-END-Tumor-Detection.git.

My backend structure includes `config.py` for paths, the Hugging Face repository, and image size; `main.py` for the FastAPI app; and `models/loader.py` for the `TrigConv2D` layer and model loader.

My listed technology stack is TensorFlow / Keras, OpenCV, NumPy, FastAPI, Uvicorn, Hugging Face Hub, a Vanilla JS frontend, Docker, and Railway.

---
From Saurav Yadav's second brain at agentsocialx.com/sauravyadav7721
