Model Card for PneumoniaDetectionCNN: Chest X-Ray Classifier

PneumoniaDetectionCNN is a convolutional neural network (CNN) model trained to classify chest X-ray images into two categories: Normal and Pneumonia. The model was designed to support medical research and educational purposes by leveraging deep learning for medical imaging classification.

โš ๏ธ Disclaimer: This model is intended for research and educational purposes only. It is not a substitute for professional medical diagnosis. Always consult a licensed healthcare provider for medical decisions.


Model Details

Key Features:

  • Binary classification of chest X-rays (Normal vs Pneumonia)
  • CNN-based architecture trained from scratch
  • Input size: 224x224 (grayscale, normalized)
  • Data preprocessing with augmentation to handle class imbalance
  • Evaluated on separate validation and test sets with ~96% accuracy

Skills & Technologies Used:

  • TensorFlow / Keras for model design & training
  • ImageDataGenerator for augmentation
  • Matplotlib & Seaborn for visualization
  • Hugging Face Hub for model hosting
  • Kaggle for dataset and training environment

  • Developed by: Rawan Alwadeya
  • Model type: Convolutional Neural Network (CNN)
  • Language(s): N/A (Image model)
  • License: MIT

Uses

This model can be used for:

  • Research in medical imaging AI
  • Educational demonstrations of CNNs for binary classification
  • Portfolio projects showcasing model training, data preprocessing, and deployment

Example Usage

import numpy as np
from keras.models import load_model
from PIL import Image
import requests
from io import BytesIO

# Load the model from Hugging Face Hub
from huggingface_hub import hf_hub_download

model_path = hf_hub_download(repo_id="RawanAlwadeya/PneumoniaDetectionCNN", filename="chest_xray_cnn.h5")
model = load_model(model_path)

# Preprocess an example image
def preprocess_image(image):
    IMG_SIZE = (224, 224)
    image = image.convert("L")   # grayscale
    image = image.resize(IMG_SIZE)
    img_array = np.array(image) / 255.0
    img_array = np.expand_dims(img_array, axis=(0, -1))  # batch + channel
    return img_array

# Example: load an image from URL
url = "https://example.com/sample_xray.jpg"
response = requests.get(url)
image = Image.open(BytesIO(response.content))

img_array = preprocess_image(image)
prediction = model.predict(img_array)[0][0]

if prediction >= 0.5:
    print("โš ๏ธ Likely Pneumonia")
else:
    print("โœ… Likely Normal")
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support