Web application for fracture detection on X-ray images using YOLOv8 + Flask, with an integrated educational 3D anatomy explorer.
The repository includes:
- A Flask web app for upload, inference, and visualization.
- YOLO training and testing scripts.
- Dataset and model assets used by the UI and training pipeline.
Note: the project is under active development, so some paths/configurations may evolve.
- X-ray upload and inference from web UI.
- Fracture bounding-box overlay generation and side-by-side comparison.
- Confidence score chart for detected boxes.
- Educational 3D Anatomy Explorer with region-based models and hotspot legend.
- Region inference from filename tokens (humerus, wrist, hand) with fallback logic.
- Training and local testing scripts for YOLO-based experiments.
- Python
- Flask
- Ultralytics YOLO
- OpenCV
- HTML/CSS/JS + Three.js (for 3D viewer)
- README.md: project overview.
- Cartella_Bone_Fractures/app.py: Flask routes and inference flow.
- Cartella_Bone_Fractures/templates/index.html: main dashboard UI.
- Cartella_Bone_Fractures/templates/viewer3d.html: 3D explorer page.
- Cartella_Bone_Fractures/static/css/style.css: dashboard styling.
- Cartella_Bone_Fractures/static/models: GLB assets and attribution.
- Cartella_Bone_Fractures/train.py: YOLO training script.
- Cartella_Bone_Fractures/test_model.py: local prediction test script.
- Cartella_Bone_Fractures/saved_models: production model weights used by app.
- Cartella_Bone_Fractures/uploads: uploaded images.
- Cartella_Bone_Fractures/results: prediction outputs.
- cd Cartella_Bone_Fractures
- python -m venv .venv
- source .venv/bin/activate
- pip install --upgrade pip
- pip install flask ultralytics opencv-python werkzeug torch torchvision
If you get this error:
ImportError: libGL.so.1: cannot open shared object file
Install system package:
- sudo apt-get update
- sudo apt-get install -y libgl1
From Cartella_Bone_Fractures:
- python app.py
Available pages:
- / : main dashboard
- /viewer-3d?region=humerus : 3D explorer
Supported upload formats:
- png
- jpg
- jpeg
From Cartella_Bone_Fractures:
- python train.py
Default output path from current script:
- runs/fracture_detection/Fast-CPU/weights/best.pt
Important: verify dataset paths in your YAML before training.
From Cartella_Bone_Fractures:
- Put a test image where expected by Cartella_Bone_Fractures/test_model.py (currently prova.jpg).
- python test_model.py
- App model path is currently set in Cartella_Bone_Fractures/app.py to: Cartella_Bone_Fractures/saved_models/best.pt
- Cartella_Bone_Fractures/data.yaml currently contains Windows-style absolute paths. Update these paths for your environment if you use this file directly.
- 3D model sources and attribution are listed in: Cartella_Bone_Fractures/static/models/ATTRIBUTION.md
- No detections shown: Verify that model weights exist at the configured path and confirm image quality/format.
- App starts but 3D model is missing: Check that files exist in Cartella_Bone_Fractures/static/models.
- Training cannot find dataset: Fix train/val paths in your YAML and rerun training.
The 3D explorer is an educational visualization tool and does not represent a patient-specific reconstruction or a medical diagnosis.