Research and education only. Not a medical device. No patient data is shipped or collected.
01 extract frames
02 annotate
03 split by patient
04 evaluate honestly
11 MBreference detector
3research classes
12legacy scripts consolidated
0clinical claims
The abstract
A small camera. A hard problem. A pipeline you can audit.
Bladder cancer is often found through cystoscopy, a procedure in which a thin camera inspects the lining of the bladder. Most new diagnoses are non-muscle-invasive, and recurrence is common enough that surveillance becomes a long relationship. The procedure is operator-dependent, the video is rich, and the documentation is often thinner than the evidence deserves.
This repository turns that workflow into reproducible software. It extracts annotated frames, converts annotations, splits data with a written manifest, trains a frame classifier, runs a single-class lesion detector, and reports metrics a clinical reader can inspect: sensitivity, specificity, predictive values, and a confusion matrix. It also includes an interactive 3D environment that teaches the logic behind those numbers.
Every stage is a file contract. Every result is traceable to a seed, a split, a threshold, and a commit. Nothing here is a medical device, and the project says so before you have to ask.
“The most important sentence in medical AI is not ‘the model is accurate.’ It is ‘accurate on whom, compared with what, at which threshold, and with what uncertainty?’”
🌱 Beginner guide
Read this and you are a professional.
No medical degree. No machine-learning PhD. Seven ideas, in the order they actually matter. By the end, you will know more than most interview candidates.
01 · THE CAMERA
Cystoscopy is the front door
A thin scope enters through the urethra and looks at the bladder wall. The result is a video, not a single photo. Lighting, angle, and the operator's hand all change what you see.
Why it matters: the model sees frames, but the clinician sees a procedure.
02 · THE MAP
Annotations turn pixels into labels
A clinician draws a box around a suspicious region and attaches a label. That box is a claim about the world. If the box is wrong, the model learns the wrong lesson efficiently.
Why it matters: annotation quality is a ceiling on model quality.
03 · THE TEXTBOOK
A dataset is a curated textbook
Images plus labels are the examples. A dataset is not neutral: it reflects who was imaged, on which device, at which hospital, and who decided what counted as disease.
Why it matters: “works on my dataset” is a statement about the dataset first.
04 · THE EXAM
Split by patient, not by frame
Frames from one procedure look alike. If some go into training and others into test, the model can memorise the patient and look brilliant. That is leakage, not learning.
Why it matters: a patient-level split is the difference between a demo and evidence.
05 · THE STUDENT
The model finds patterns, not meaning
A convolutional network learns textures, edges, colours, and shapes. It does not know what cancer is. It knows which pixel patterns were labelled cancer in the data it saw.
Why it matters: domain shift is not a bug; it is the default.
06 · THE REPORT CARD
One accuracy number is a red flag
Sensitivity asks how many true cases you found. Specificity asks how many healthy cases you cleared. PPV and NPV depend on how common the disease is in the room. Always ask for the confusion matrix.
Why it matters: the threshold is a choice, and the choice has consequences.
07 · THE CLINIC
A model is not a product
Clinical use needs a defined intended use, external validation, human-factors evidence, quality systems, cybersecurity, and a regulatory pathway. A notebook is the beginning of that work, not the end.
Why it matters: “the AUC is high” has never treated a patient.
THE ONE THING
Ask “compared with what?”
Compared with a second cystoscopy? With histopathology? With a generalist? With the same model at a different threshold? The comparison is the claim.
Why it matters: precision without a reference is decoration.
“
You do not need to trust the model. You need to be able to inspect the claim. That is a skill, and it is learnable in an afternoon.
You will know more than most interview candidates.
The pipeline
From video to verdict — without the black box.
Six stages. Each one has an input, an output, and a reason to exist. Select a stage to see the contract and the command.
Stage 01Capture
Keep only the moments that matter.
A cystoscopy video can run for minutes. The annotations mark the seconds worth learning from. Extract those frames, keep their timestamps, and write the same stem to the image and its annotation.
Watch: timestamp units. Milliseconds in a seconds field produce empty outputs, not errors.
Interactive lab
Move the threshold. Watch the trade-off.
A score is not a decision. You choose the cut-off, and every cut-off buys something at the cost of something else. This lab uses a synthetic cohort so the arithmetic is visible.
How far apart the model pushes cancer and normal scores. Low separation means no threshold can save you.
At or above this score, the case is flagged. Move it and watch false negatives trade places with false alarms.
Sensitivity—true cases found
Specificity—healthy cases cleared
PPV—flagged that are real
NPV—cleared that are real
—TP
—FP
—FN
—TN
Synthetic cohort: 120 cases, 36 cancer and 84 normal. The model is imaginary; the arithmetic is real. The shipped detector is a single-class TFLite model and is not used on this page.
Read the clue, inspect the mucosa, and choose the region that matches. Every answer adds a concept to your brain network. Turn sound on for narration, or keep it silent and read the captions.
Round 1 / 5
Score 0
Streak 0
Nodes 1
Mission briefing
Learn the wall of the bladder.
You will see three stylised regions each round. A clue describes one of them. Pick it. The explanation matters more than the score.
Stylised anatomy · orientation, not diagnosis
Mission complete
Observer
You built a small network. The next step is to inspect the evidence behind each concept.
0score
0%accuracy
1nodes
This is orientation, not a clinical skill assessment.
Correct
Papillary lesion
3D view unavailable. The mission still works: use the region buttons below. Descriptions are enabled.
Your clue
Press start to receive the first clue.
Knowledge check
The 90-second check.
Eight questions. No sign-up, no tracking, no leaderboard. Wrong answers explain themselves.
0 correct
Question 1 of 8
Loading question…
Result
0 / 8
The evidence
Numbers, with the caveats attached.
These are context numbers from the literature and public datasets. They are not results produced by this repository, and they do not validate the shipped detector.
~75–80%of bladder cancer diagnoses are non-muscle-invasive. Surveillance is a long relationship, not a one-off test.EAU NMIBC guidelines
0.919 / 0.764cancer identification vs grade accuracy in a 2026 evaluation of an AI-assisted cystoscopy system. Detection is not grading.iScience, 2026 · AINCDS evaluation
8,067 / 1,754public images in CystoDS and the Lazo dataset. Useful for reproduction; not a substitute for external validation.CystoDS (OSF) · Zenodo 7741476
What this repository gives you
A reproducible pipeline from frames to metrics
Patient-level splitting guidance and a manifest contract
A single-class TFLite detector for engineering experiments
An evaluation checklist and a 3D teaching environment
What it does not give you
Clinical validation or a performance claim
FDA clearance, CE marking, or any regulatory approval
A trained classifier or the original training dataset
Permission to use patient data without the required approvals
For teams building responsibly
A pilot, not a promise.
Most cystoscopy AI pilots fail on the unglamorous parts: annotation quality, patient-level splits, device shift, clinician trust, and the evidence a buyer actually asks for. This repository is a head start on those parts.
01
Faster first experimentGo from annotated video to a split dataset and a baseline metric without rebuilding file plumbing.
02
Lower evidence riskThe evaluation guide forces threshold discipline, patient-level splits, and subgroup reporting before the pilot starts.
03
Better communicationThe 3D layer explains the pipeline to clinical, regulatory, and commercial teams in one sitting.
04
Permissive licenceMIT allows commercial use and modification. You remain responsible for your evidence and your regulatory pathway.
The package is intentionally light at import time. Annotation conversion, splits, and metrics work with NumPy alone; OpenCV and TensorFlow are only needed by the stages that use them.
Python 3.10+ · MIT · no telemetry · no patient data
No. It is research and education software. It has not been cleared, certified, or approved by any regulator, and it must not be used for diagnosis, screening, or treatment. Read DISCLAIMER.md.
Does it include a trained classifier?
No. The repository ships a single-class TFLite detector and the training code for a three-class frame classifier. To use the classifier, you train it on data you are allowed to use. This is stated in MODEL_FACTS.md.
Why are the classes NMIBC, Normal, and Ta?
That is the original research convention. It is not a mutually exclusive clinical taxonomy: Ta is a stage within NMIBC. A clinically meaningful system would separate detection, staging, grading, and histology, and would be validated against pathology. The glossary explains the terms.
What does “patient-level split” mean and why does it matter?
All frames from one patient go into exactly one split. If frames from the same procedure appear in both training and test, the model can memorise the patient and look better than it is. That is data leakage. See EVALUATION.md.
Can I use it commercially?
The code is MIT licensed. You may use, modify, and distribute it commercially, provided you keep the copyright and permission notice. The licence does not grant rights to patient data, third-party datasets, trademarks, or regulatory approval. You remain responsible for your own evidence and compliance.
Does the website collect data or use patient images?
No. The site is static, has no analytics, and uses synthetic or stylised visuals. The simulator is a teaching model with a synthetic cohort, not the shipped detector. Narration uses the browser's local speech synthesis.
How do I cite it?
Use the metadata in CITATION.cff. If you use a public dataset, cite that dataset too. If you build on the detector, state that it is single-class and unvalidated.
How can I contribute?
Read CONTRIBUTING.md. The rules that matter most: no patient data, no invented clinical claims, and a reproducible command for every result. Security issues go through the private advisory flow in SECURITY.md.
Start here
Inspect the pipeline. Then inspect the claims.
Clone it, run the tests, read the evaluation protocol, and decide for yourself what the evidence supports. If you build something better, send a pull request.