Views
No views yet
| 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 |
Gradio.py and packaged as checkpoints/best_model.pth.| 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_hub1from huggingface_hub import hf_hub_download
2import torch
3
4weights_path = hf_hub_download(
5 repo_id="nsr51324/Oral_Diseases_Image_Classification",
6 filename="checkpoints/best_model.pth"
7)
8
9checkpoint = torch.load(weights_path, map_location="cpu")
10class_names = checkpoint["class_names"]1import torch.nn as nn
2from torchvision.models import resnet50
3from torchvision import transforms
4from PIL import Image
5
6model = resnet50(weights=None)
7model.fc = nn.Sequential(
8 nn.Dropout(0.3),
9 nn.Linear(model.fc.in_features, len(class_names))
10)
11model.load_state_dict(checkpoint["state_dict"])
12model.eval()
13
14transform = transforms.Compose([
15 transforms.Resize((224, 224)),
16 transforms.ToTensor(),
17 transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
18])
19
20image = Image.open("sample.jpg").convert("RGB")
21tensor = transform(image).unsqueeze(0)
22
23with torch.no_grad():
24 probs = torch.softmax(model(tensor), dim=1)[0]
25
26pred = class_names[probs.argmax().item()]
27print(f"{pred}: {probs.max().item()*100:.2f}%")1pip install torch torchvision gradio pillow huggingface_hub
2python Gradio.pyMODEL_PATH at the top of Gradio.py to your local copy of checkpoints/best_model.pth.lr=1e-3), then fully unfrozen for fine-tuning at lr=1e-5outputs/. Summary metrics are in outputs/models_comparison.csv.