c2p-cmd/knee_oa_classifier
By c2p-cmd · ↓ 10 · ♥ 0 · Updated 2025-05-25
What's in this repo
This page lists the files in c2p-cmd/knee_oa_classifier, including knee_osteoarthritis_model.onnx.
- 1 ONNX models (.onnx files)
- 6 files, including 1 .md, 1 .py, 1 .ipynb, 1 .keras, 1 .onnx
- Last updated 2025-05-25
ONNX files
| File | Size | Download |
|---|---|---|
| knee_osteoarthritis_model.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
🦴 Knee Osteoarthritis X-ray Classifier
This model classifies grayscale knee X-ray images into 5 severity classes:
- Normal
- Doubtful
- Mild
- Moderate
- Severe
📊 Model Details
- Model: CNN built with Keras
- Input shape: (162, 300, 1)
- Preprocessing: Grayscale conversion, resizing, internal normalization (
Rescaling(1./255)) - Data Augmentation: Flip, rotation, zoom
- Output: Softmax probability over 5 classes
🧾 Dataset Description
This model was trained on the Digital Knee X-ray Images dataset available on Kaggle. The dataset contains labeled grayscale knee X-ray images categorized into:
- Normal
- Doubtful
- Mild
- Moderate
- Severe
These categories represent the Kellgren and Lawrence grading system for osteoarthritis severity. The images are organized into corresponding folders and include both healthy and osteoarthritic knee conditions.
Link to dataset: Digital Knee X-ray Images (Kaggle)
📈 Training Summary
- Epochs: 100 with early stopping (83)
- Optimizer: Adam
- Loss: Sparse Categorical Crossentropy
- Metric: F1 Score
🚀 Usage
from keras.models import load_model
model = load_model("knee_oa_classifier.keras")
# Preprocess and predict (image should be (162, 300, 1) when using a url to an image
response = requests.get(url)
img = Image.open(BytesIO(response.content))
img = img.convert('L').resize((162, 300))
display(img)
img_array = np.array(img)
img_array = img_array.reshape((1, 162, 300, 1)) # Add batch and channel dimensions
pred_probs = model.predict(img_array)
pred_class_index = np.argmax(pred_probs)
pred_class_label = train_ds.class_names[pred_class_index]
for pred_prob in pred_probs:
for i, class_name in enumerate(train_ds.class_names):
display(f'{class_name} -> {pred_prob[i]*100}')
display('')
🖼 Example Prediction
Image link
Class probabilities:
- 0Normal -> 0.0
- 1Doubtful -> 0.0
- 2Mild -> 100.0
- 3Moderate -> 0.0
- 4Severe -> 0.0
Model info
Created: 2025-05-13
Updated: 2025-05-25
View on Hugging Face