Downloads · 30 days
0
nsr51324/Oral_Diseases_Image_Classification
Oral_Diseases_Image_Classification is a image classification model from nsr51324. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Jul 11, 2026
Repo size
278 MB
Likes
1
Public
Click a slice to open those files.
.pth278 MB · 98%
From the Hugging Face model README
ResNet50 fine-tuned to classify 6 intraoral conditions from a single photo — benchmarked against 3 other architectures, evaluated on a held-out test set.
This repository hosts the winning checkpoint from a 4-way benchmark of image classifiers trained to recognize intraoral conditions:
Calculus · Caries · Gingivitis · Ulcers · Tooth Discoloration · Hypodontia
Four architectures were trained under identical conditions (same data split, same augmentation, same evaluation protocol) and compared on a test set none of them saw during training:
| Rank | Model | Params (trainable) | Test Accuracy | Test F1 (macro) |
|---|---|---|---|---|
| 🥇 | ResNet50 (this checkpoint) | 23,520,326 | 94.77% | 0.9411 |
| 🥈 | DenseNet121 | 6,960,006 | 94.51% | 0.9351 |
| 🥉 | EfficientNet-B0 | 4,015,234 | 94.17% | 0.9335 |
| 4 | ScratchCNN (no pretraining) | 11,179,590 | 83.45% | 0.8236 |
ResNet50 (ImageNet-pretrained, fine-tuned in two stages — freeze then unfreeze) came out on top and is the model served by Gradio.py and packaged as checkpoints/best_model.pth.
This model is a research and educational tool for preliminary visual screening. It is not a certified diagnostic device and must not be used to replace examination by a licensed dentist or physician. Performance depends on image quality and lighting similar to the training data, and may not generalize to conditions or populations outside the training distribution.
| Path | Description |
|---|---|
checkpoints/best_model.pth | Final ResNet50 checkpoint — a dict with state_dict, model_name, class_names, and test_f1. |
checkpoints/ | Also contains the individually saved weights for the other 3 models trained in the same run. |
notebooks/ | The full training notebook — data prep, transforms, model definitions, training loop, evaluation. |
outputs/ | models_comparison.csv, per-model loss/accuracy curves, and confusion matrices. |
Gradio.py | Standalone web demo — upload an image, get the predicted class, confidence, and full probability breakdown. |
huggingface_hubfrom huggingface_hub import hf_hub_download
import torch
weights_path = hf_hub_download(
repo_id="nsr51324/Oral_Diseases_Image_Classification",
filename="checkpoints/best_model.pth"
)
checkpoint = torch.load(weights_path, map_location="cpu")
class_names = checkpoint["class_names"]
import torch.nn as nn
from torchvision.models import resnet50
from torchvision import transforms
from PIL import Image
model = resnet50(weights=None)
model.fc = nn.Sequential(
nn.Dropout(0.3),
nn.Linear(model.fc.in_features, len(class_names))
)
model.load_state_dict(checkpoint["state_dict"])
model.eval()
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
image = Image.open("sample.jpg").convert("RGB")
tensor = transform(image).unsqueeze(0)
with torch.no_grad():
probs = torch.softmax(model(tensor), dim=1)[0]
pred = class_names[probs.argmax().item()]
print(f"{pred}: {probs.max().item()*100:.2f}%")
pip install torch torchvision gradio pillow huggingface_hub
python Gradio.py
Point MODEL_PATH at the top of Gradio.py to your local copy of checkpoints/best_model.pth.
Trained on nsr51324/Oral_Diseases, sourced from the Oral Diseases dataset on Kaggle (salmansajid05), split 80/10/10 (train/val/test) with stratification to preserve class balance across all three sets.
lr=1e-3), then fully unfrozen for fine-tuning at lr=1e-5Full classification report, confusion matrix, and training curves for all 4 models are in outputs/. Summary metrics are in outputs/models_comparison.csv.
This model is provided for research and educational purposes only. It is not intended for clinical decision-making. Always consult a qualified healthcare professional for medical diagnosis.
MIT. The underlying dataset has its own terms — see the dataset card before commercial use.
Nasr Mohamed — AI Engineer 🤗 huggingface.co/nsr51324