Model Card for ResNet50V2 COVID 19 Radiography Classifier
This model is an image classifier for chest X ray analysis. It predicts one of four classes and supports Grad CAM visualization for interpretability.
Model Details
Model Description
This model uses transfer learning with ResNet50V2 to classify chest X ray images into:
- COVID
- Lung Opacity
- Normal
- Viral Pneumonia
The project includes a Gradio app for interactive inference and Grad CAM overlays.
- Developed by: Omar Rehan
- Funded by: Not publicly disclosed
- Shared by: AIOmarRehan
- Model type: CNN image classifier (transfer learning)
- Language(s) (NLP): Not applicable
- License: MIT
- Finetuned from model: ResNet50V2 pretrained on ImageNet
Model Sources
- Repository: https://huggingface.co/spaces/AIOmarRehan/
- Paper: https://arxiv.org/abs/1603.05027 (ResNet)
- Demo: Gradio Space URL above
Uses
Direct Use
- Interactive chest X ray classification in a Gradio interface
- Class probability output for 4 classes
- Grad CAM heatmap generation for prediction explanation
- Educational and research workflows
Downstream Use
- Integration into research dashboards
- Baseline model for experiments on radiography classification
- Component in AI-assisted triage prototypes (with human oversight)
Out-of-Scope Use
- Clinical diagnosis without radiologist review
- Emergency or high risk medical decision making as a standalone tool
- Use on non chest X ray modalities without validation
- Use in populations or imaging settings not represented in training/evaluation
Bias, Risks, and Limitations
- Performance depends on dataset quality, class balance, and acquisition settings
- Potential domain shift across hospitals, devices, and protocols
- Prediction confidence is not equivalent to calibrated clinical certainty
- Grad CAM is an interpretability aid and not proof of causal reasoning
- Potential false positives and false negatives can have clinical impact
Recommendations
- Use only as a decision support or research tool
- Keep a qualified clinician in the loop for any medical interpretation
- Validate on local data before any operational use
- Monitor errors by class and subgroup and retrain periodically
- Combine with additional clinical context and confirmatory testing
How to Get Started with the Model
Use the Gradio app.
Local
# Terminal commands
# 1) pip install -r requirements.txt
# 2) python -m app.main
# 3) open http://127.0.0.1:7860
Inference example (Python)
from PIL import Image
from app.model import predict, gradcam
img = Image.open("sample_xray.png").convert("RGB")
label, confidence, probs = predict(img)
overlay = gradcam(img, interpolant=0.5)
print(label, confidence)
print(probs)
Training Details
Training Data
- Dataset:
AIOmarRehan/COVID-19 - Task: 4 class chest X ray classification
- Notes: Dataset balancing and augmentation were applied in the training workflow.
Training Procedure
Preprocessing
- Resize images to model input size (299 x 299)
- Convert to RGB
- Normalize pixels to [0, 1]
- Training augmentations include random horizontal and vertical flips, brightness, and contrast adjustments
- Additional offline augmentation used to improve class balance
Training Hyperparameters
- Training regime: fp16 mixed precision (mixed float16) for training pipeline
- Loss: sparse categorical crossentropy
- Optimizer: Adam
- Callbacks: EarlyStopping, ModelCheckpoint, ReduceLROnPlateau
- Transfer strategy: frozen backbone feature extraction followed by partial fine tuning
Speeds, Sizes, Times
- Saved model format:
.h5 - Inference latency (CPU): prediction around 2 seconds, Grad CAM around 1 to 2 seconds after warmup
- First Grad CAM call: may be slower due to graph compilation and warmup
Evaluation
Testing Data, Factors & Metrics
Testing Data
- Held out test split from the same dataset family used for training.
Factors
- Class level behavior across COVID, Lung Opacity, Normal, Viral Pneumonia
- Error patterns inspected via confusion matrix
- Explainability inspected via Grad CAM overlays
Metrics
- Accuracy
- Precision (macro and per class)
- Recall (macro and per class)
- F1 score (macro and per class)
- Confusion matrix
- ROC curves (one vs rest and macro average AUC)
Results
Evaluation in the project reports strong classification behavior across standard metrics, with full plots and reports available in the repository notebook and README.
Summary
The model is suitable for research and educational classification workflows on chest X ray data with interpretability support through Grad CAM.
Model Examination
- Grad CAM is used to visualize salient regions influencing predictions.
- Examination should be combined with expert clinical review, especially for difficult or ambiguous cases.
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator.
- Hardware Type: Not fully tracked
- Hours used: Not fully tracked
- Cloud Provider: Mixed (local and hosted runtime)
- Compute Region: Not specified
- Carbon Emitted: Not estimated in this release
Technical Specifications
Model Architecture and Objective
- Backbone: ResNet50V2 (ImageNet pretrained)
- Head: GlobalAveragePooling2D + Dense(512, ReLU) + Dropout(0.5) + Dense(4, Softmax)
- Objective: Multi class chest X ray classification
Compute Infrastructure
- Training and experimentation performed in notebook based environment
- Inference and demo deployment via Gradio and optional Docker containerization
Hardware
- CPU supported for inference
- GPU optional for faster training and inference
Software
- Python 3.10
- TensorFlow 2.17.0
- Gradio
- NumPy, Pillow, OpenCV, scikit-learn
Citation
BibTeX:
@article{he2016identity,
title={Identity Mappings in Deep Residual Networks},
author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
journal={ECCV},
year={2016}
}
@inproceedings{selvaraju2017gradcam,
title={Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization},
author={Selvaraju, Ramprasaath R. and Cogswell, Michael and Das, Abhishek and Vedantam, Ramakrishna and Parikh, Devi and Batra, Dhruv},
booktitle={ICCV},
year={2017}
}
APA:
He, K., Zhang, X., Ren, S., & Sun, J. (2016). Identity Mappings in Deep Residual Networks. ECCV. Selvaraju, R. R., Cogswell, M., Das, A., Vedantam, R., Parikh, D., & Batra, D. (2017). Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. ICCV.
Glossary
- Transfer learning: Reusing pretrained visual features and adapting to a new task
- Grad CAM: Gradient based class activation mapping for visual explanations
- Macro average: Unweighted average across classes
More Information
This model card should be updated when new datasets, calibration analyses, or external validation results are added.
Model Card Authors
Omar Rehan
Model Card Contact
Hugging Face profile: https://huggingface.co/AIOmarRehan