Upload 2 files
Browse files- .gitattributes +1 -0
- README.md +72 -3
- knee_oa_classifier.keras +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
knee_oa_classifier.keras filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🦴 Knee Osteoarthritis X-ray Classifier
|
| 2 |
+
|
| 3 |
+
This model classifies grayscale knee X-ray images into 5 severity classes:
|
| 4 |
+
|
| 5 |
+
- **Normal**
|
| 6 |
+
- **Doubtful**
|
| 7 |
+
- **Mild**
|
| 8 |
+
- **Moderate**
|
| 9 |
+
- **Severe**
|
| 10 |
+
|
| 11 |
+
## 📊 Model Details
|
| 12 |
+
|
| 13 |
+
- Model: CNN built with Keras
|
| 14 |
+
- Input shape: (162, 300, 1)
|
| 15 |
+
- Preprocessing: Grayscale conversion, resizing, internal normalization (`Rescaling(1./255)`)
|
| 16 |
+
- Data Augmentation: Flip, rotation, zoom
|
| 17 |
+
- Output: Softmax probability over 5 classes
|
| 18 |
+
|
| 19 |
+
## 🧾 Dataset Description
|
| 20 |
+
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:
|
| 21 |
+
|
| 22 |
+
1. Normal
|
| 23 |
+
2. Doubtful
|
| 24 |
+
3. Mild
|
| 25 |
+
4. Moderate
|
| 26 |
+
5. Severe
|
| 27 |
+
|
| 28 |
+
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.
|
| 29 |
+
|
| 30 |
+
Link to dataset: [Digital Knee X-ray Images (Kaggle)](https://www.kaggle.com/datasets/orvile/digital-knee-x-ray-images/data)
|
| 31 |
+
|
| 32 |
+
## 📈 Training Summary
|
| 33 |
+
|
| 34 |
+
- Epochs: 100 with early stopping (83)
|
| 35 |
+
- Optimizer: Adam
|
| 36 |
+
- Loss: Sparse Categorical Crossentropy
|
| 37 |
+
- Metric: F1 Score
|
| 38 |
+
|
| 39 |
+
## 🚀 Usage
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
from keras.models import load_model
|
| 43 |
+
model = load_model("knee_oa_classifier.keras")
|
| 44 |
+
|
| 45 |
+
# Preprocess and predict (image should be (162, 300, 1) when using a url to an image
|
| 46 |
+
response = requests.get(url)
|
| 47 |
+
img = Image.open(BytesIO(response.content))
|
| 48 |
+
img = img.convert('L').resize((162, 300))
|
| 49 |
+
display(img)
|
| 50 |
+
img_array = np.array(img)
|
| 51 |
+
img_array = img_array.reshape((1, 162, 300, 1)) # Add batch and channel dimensions
|
| 52 |
+
|
| 53 |
+
pred_probs = model.predict(img_array)
|
| 54 |
+
pred_class_index = np.argmax(pred_probs)
|
| 55 |
+
pred_class_label = train_ds.class_names[pred_class_index]
|
| 56 |
+
|
| 57 |
+
for pred_prob in pred_probs:
|
| 58 |
+
for i, class_name in enumerate(train_ds.class_names):
|
| 59 |
+
display(f'{class_name} -> {pred_prob[i]*100}')
|
| 60 |
+
display('')
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## 🖼 Example Prediction
|
| 64 |
+
|
| 65 |
+
Image [link]("https://storage.googleapis.com/kagglesdsdata/datasets/5697473/9389485/OS%20Collected%20Data/Osteopenia/Osteopenia%2010.jpg?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=gcp-kaggle-com%40kaggle-161607.iam.gserviceaccount.com%2F20250513%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250513T112322Z&X-Goog-Expires=259200&X-Goog-SignedHeaders=host&X-Goog-Signature=9e41a414c2260b2090ef9c53e4d37a543e6075779074aa5a38e756c299147309380ee57f591f224fb8d992c63ce7f797655f647fc57ff4dca602997ff7efd1bf944e2737782cb2812a2da1f8d8c5f93ed33066df3b7983701e0fdd87c5d96395c45b4ea5be14fe7fab58495c99772e814e42f83a6db24d8b8760eeac2cd58c4581fc57cccbb2fb46a2040c521ef8b332105e6b43de0f0a6c23d5324102349bc13ecefb93d1d1cd8881fadb3d29f49d8662c8f70190c8e5903672c56d9c1ad4cead65f267dbec4774d682772d2afe9d1a8f003899ac931c4698649365be9c9170d8e5336c13e29584508c1c4b1b2dc928ac64ac763b4c1579e8eee9c265a2c644")
|
| 66 |
+
|
| 67 |
+
Class probabilities:
|
| 68 |
+
- 0Normal -> 0.0
|
| 69 |
+
- 1Doubtful -> 0.0
|
| 70 |
+
- 2Mild -> 100.0
|
| 71 |
+
- 3Moderate -> 0.0
|
| 72 |
+
- 4Severe -> 0.0
|
knee_oa_classifier.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9177fc0d5809793cf652438e1d3aa6e09466a200b698f6ea3fa42441888c0ecc
|
| 3 |
+
size 146693011
|