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:
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.
1from keras.models import load_model
2model = load_model("knee_oa_classifier.keras")
3
4# Preprocess and predict (image should be (162, 300, 1) when using a url to an image
5response = requests.get(url)
6img = Image.open(BytesIO(response.content))
7img = img.convert('L').resize((162, 300))
8display(img)
9img_array = np.array(img)
10img_array = img_array.reshape((1, 162, 300, 1)) # Add batch and channel dimensions
11
12pred_probs = model.predict(img_array)
13pred_class_index = np.argmax(pred_probs)
14pred_class_label = train_ds.class_names[pred_class_index]
15
16for pred_prob in pred_probs:
17 for i, class_name in enumerate(train_ds.class_names):
18 display(f'{class_name} -> {pred_prob[i]*100}')
19 display('')