🩻 Pneumonia Detection Model (CNN)

🧠 Overview

This model is a Convolutional Neural Network (CNN) trained to classify chest X-ray images as either Normal or Pneumonia.
It demonstrates the application of deep learning to medical imaging classification and serves as an educational and research toolnot for clinical use.


⚙️ Model Details

  • Architecture: Custom CNN (3 convolutional + 2 dense layers)
  • Framework: TensorFlow / Keras
  • Input size: 150×150 RGB images
  • Output: Binary classification — 0 = Normal, 1 = Pneumonia
  • Dataset: Chest X-Ray Images (Pneumonia)Kermany et al., Cell (2018)

📚 Dataset Information

Source:
Kermany, D.S., Goldbaum, M., Cai, W. et al.
Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning,
Cell (2018), 172(5), 1122–1131.e9
DOI: 10.1016/j.cell.2018.02.010

License: Creative Commons Attribution 4.0 International (CC BY 4.0)


🩺 Intended Use

This model is designed for:

  • Machine learning and data science education
  • Research in medical image analysis
  • Prototyping of AI healthcare applications

⚠️ Disclaimer:
This model is not a medical device and should not be used for clinical or diagnostic purposes.
It is provided solely for educational and research use.


🧩 How It Works

  1. The user uploads a chest X-ray image (.jpg or .png).
  2. The image is resized to 150×150 pixels and normalized to [0, 1].
  3. The CNN processes the image and outputs a probability:
    • 0 → Normal
    • 1 → Pneumonia
  4. The final classification is the class with the highest confidence score.

📊 Evaluation Report

🧾 Classification Metrics

Metric Normal Pneumonia
Precision 0.962 0.829
Recall 0.659 0.985
F1-score 0.783 0.900
Support 232 389

Overall accuracy: 0.863
Macro F1-score: 0.841
Weighted F1-score: 0.856


📉 ROC Curve

ROC Curve

AUC = 0.959


📊 Confusion Matrix

Confusion Matrix

True Label Predicted Normal Predicted Pneumonia
Normal 153 79
Pneumonia 6 383

💡 Example Usage

import tensorflow as tf import numpy as np from tensorflow.keras.preprocessing import image # Load model model = tf.keras.models.load_model("cnn_pneumonia.keras") # Load and preprocess image img_path = "test_image.jpg" img = image.load_img(img_path, target_size=(150, 150)) img_array = image.img_to_array(img) / 255.0 img_array = np.expand_dims(img_array, axis=0) # Predict prediction = model.predict(img_array)[0][0] label = "Pneumonia" if prediction > 0.5 else "Normal" confidence = prediction if prediction > 0.5 else 1 - prediction print(f"Prediction: {label} ({confidence:.2f} confidence)") 
Downloads last month
20
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 1 Ask for provider support