Dental X-ray Analysis

DICOM in, pathology boxes and a structured radiology-style report out: CV detection wired to LLM reasoning.

ML / DL2025All work

Fig. 01Dental radiographs with detected cavities and confidence scores, plus the generated clinical report.
Dental radiographs with detected cavities and confidence scores, plus the generated clinical report.

What it is

What it does

A two-container pipeline for dental radiographs: upload DICOM, normalise pixels to PNG, detect pathologies with a hosted vision model, draw annotated bounding boxes, then have GPT turn the raw detections into a clinician-readable report with per-finding confidence and advice, all validated as JSON before it reaches the UI.

Why it exists

Two dentists can read the same X-ray and disagree. I wouldn't trust a black box either. I split the job: let the vision model find the boxes, let the LLM write the report, and make both stages inspectable on the image itself.

CV
+ LLM pipeline
DICOM
Native support
JSON
Report schema

Repo Amit-kr26/dental-xrayStack FastAPI · React · Pydicom · Roboflow · OpenAI GPT-4.1 · Docker

Build6decisions

How it is built

DICOM handling

pydicom reads ds.pixel_array, applies min-max normalisation to uint8 and saves PNG; JPEG-compressed DICOM decodes thanks to pylibjpeg, and InvalidDicomError maps to HTTP 400.

Detection call

routers/process.py posts to Roboflow model adr/6 with confidence 0.30 and 0.50 NMS overlap, receiving centre-format boxes.

Annotation drawing

PIL converts centre coordinates to corners and draws red rectangles with '{class} {confidence:.2f}' labels above each finding.

Schema-bound reporting

GPT-4.1 plays dental radiologist over the annotations JSON and must return {detected_pathologies, details[{pathology, location, confidence}], clinical_advice}. Class names like cavity_upper_left_molar are split into finding + location, fences stripped before json.loads.

Graceful degradation

Missing OPENAI_API_KEY falls back to a dummy report instead of crashing the pipeline.

Tested + containerised

pytest mocks the exact Roboflow URL to assert both success and invalid-file paths; docker-compose runs uvicorn :8000 beside an nginx-served React build on :3000.

How the pieces connect

Vision Report React upload DICOM, nginx :3000 FastAPI /process multipart file pydicom min-max, to PNG Roboflow adr/6 conf 30, overlap 50 Predictions JSON centre-format boxes PIL annotation red boxes + class Annotated PNG static/annotated GPT-4.1 fences stripped Clinical report pathology, location Response JSON image, image, report the annotations JSON, not the drawing