YOLOv8-based dental detection model that identifies teeth, caries, cavities, cracks, and other intraoral conditions from dental images.
- 9-class detection: tooth, caries, cavity, crack, calculus, gingivitis, hypodontia, mouth ulcer, tooth discoloration
- Dual dataset pipeline: Merges DentalAI (DatasetNinja) annotations with the Kaggle 6-Class Intraoral Disease Dataset
- Automated class balancing: Over/under-sampling with augmentation
- Patient reports: Human-readable detection summaries
- Flask API: REST endpoint for integration
- Python 3.9+
- CUDA-capable GPU recommended (CPU works but is slow)
- Kaggle API credentials configured for dataset download
-
Clone the repo and install dependencies:
pip install -r requirements.txt
-
Download the DentalAI dataset from DatasetNinja and place the
dentalai-DatasetNinja/folder in the project root: -
Download the Roboflow dataset too https://universe.roboflow.com/ds/VIfxZmemET?key=IZUynBzy09
-
Open the notebook and run cells sequentially:
dental_detection_complete.ipynb
| Step | Description |
|---|---|
| 1 | Download Kaggle 6-Class Intraoral Disease Dataset |
| 2 | Convert DatasetNinja annotations → YOLO format |
| 3 | Convert Kaggle classification images → YOLO format |
| 4 | Merge both datasets into a unified set |
| 5 | Validate merged dataset |
| 6 | Analyze & balance class distribution |
| 7 | Train YOLOv8 model |
| 8 | Evaluate model performance |
| 9 | Run inference with DentalDetector class |
| 10 | Export Flask API (app.py) |
The training cell auto-detects GPU/CPU. Edit the CONFIG dict in Step 7 to adjust:
CONFIG = {
"model": "yolov8s.pt", # or yolov8m.pt / yolov8l.pt
"epochs": 100,
"batch_size": 16, # reduce to 8 or 4 if out-of-memory
"img_size": 640,
"device": 0, # 0 = GPU, "cpu" = CPU
}
Note: Set
deviceto0if you have a CUDA GPU. The notebook defaults to CPU if no GPU is detected.
After training, a Flask API is generated at app.py:
python app.py| Endpoint | Method | Description |
|---|---|---|
/detect |
POST | Send a base64-encoded image, receive detections |
/health |
GET | Health check & loaded class list |
SmileGuard-Train/
├── dental_detection_complete.ipynb # Main training notebook
├── requirements.txt # Python dependencies
├── app.py # Flask API (generated by notebook)
├── yolov8s.pt # Pre-trained YOLOv8 weights
├── dentalai-DatasetNinja/ # DatasetNinja source dataset
├── yolo_dataset/ # Converted YOLO labels (DatasetNinja)
├── kaggle_yolo/ # Converted YOLO labels (Kaggle)
├── yolo_dataset_merged/ # Combined dataset
├── yolo_dataset_balanced/ # Balanced dataset (used for training)
└── Dental_Detection/ # Training outputs & weights
| Issue | Fix |
|---|---|
| Low accuracy | Add more data or increase epochs to 150–200 |
| False positives | Raise confidence threshold to 0.6–0.7 |
| Out of memory | Reduce batch_size to 8 or 4 |
| Slow training | Use yolov8n.pt or reduce img_size to 416 |
See dentalai-DatasetNinja/LICENSE.md for dataset license terms.