YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
title: RSNA Pneumonia Detection Faster R-CNN
tags:
- object-detection
- medical
- pneumonia
- faster-rcnn
- pytorch
library_name: torchvision
---
# RSNA Pneumonia Detection Model (Faster R-CNN ResNet50-FPN)
This repository contains a Faster R-CNN ResNet50-FPN model trained for detecting Pneumonia (Lung Opacity) from chest X-ray images, based on the RSNA Pneumonia Detection Challenge dataset.
## Model Details
- **Architecture**: Faster R-CNN ResNet50-FPN
- **Task**: Object Detection
- **Classes**: `background`, `pneumonia` (2 classes total)
- **Input Image Size**: 512x512
- **Training Data**: Subset of RSNA Pneumonia Detection Challenge dataset.
## How to Use
You can load this model using PyTorch and Torchvision:
```python
import torch
import torchvision
from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
# Define your model architecture
def get_model(num_classes):
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(
weights=torchvision.models.detection.FasterRCNN_ResNet50_FPN_Weights.DEFAULT
)
in_features = model.roi_heads.box_predictor.cls_score.in_features
model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)
return model
# Load the model directly from the Hugging Face Hub
# Ensure you have the 'accelerate' library installed for download progress
# pip install accelerate
# Create a dummy model instance to load state_dict into
num_classes = 2 # 2 for background and pneumonia
model = get_model(num_classes)
# Load the state_dict
# The model file will be downloaded by the HfApi internally
from huggingface_hub import hf_hub_download
model_path_in_hub = hf_hub_download(repo_id="jayanthapoojary1989/rsna-pneumonia-faster-rcnn", filename="faster_rcnn_pneumonia_model.pth")
model.load_state_dict(torch.load(model_path_in_hub, map_location='cpu')) # Use 'cpu' for loading then move to device
model.eval() # Set to evaluation mode
# Example inference (assuming 'image' is a preprocessed tensor suitable for the model)
# You would load and preprocess your image here (e.g., PIL Image -> ToTensor)
# image = your_transform(PIL.Image.open("path/to/image.jpg")).unsqueeze(0) # Add batch dim
# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# model.to(device)
# image = image.to(device)
# with torch.no_grad():
# predictions = model(image)
# print(predictions)
Disclaimer
This model is provided for research and educational purposes. Use in clinical settings requires rigorous validation, regulatory approval, and expert medical supervision.
- Downloads last month
- 3
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support