Downloads · 30 days
12
10% of all-time downloads
Shivamnegi92/cancer-classification-vit
cancer-classification-vit is a image classification model from Shivamnegi92. Use it when you need a label for an image. The card lists the license as mit.
This model is a fine-tuned Vision Transformer (ViT) for binary classification of medical images to detect cancer. The model classifies images into two categories: - Normal (Label 0): Healthy tissue - Malignant (Label…
Downloads · 30 days
12
10% of all-time downloads
All-time downloads
119
Public
Parameters
85.8M
343 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors343 MB · 100%
From the Hugging Face model README
This model is a fine-tuned Vision Transformer (ViT) for binary classification of medical images to detect cancer. The model classifies images into two categories:
The model achieves the following performance on the test dataset:
| Metric | Value |
|---|---|
| Accuracy | 83.38% |
| Precision | 71.50% |
| Recall (Sensitivity) | 72.25% |
| Specificity | 88.02% |
| F1 Score | 0.7187 |
| MCC | 0.6009 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch
# Load model and processor
model = AutoModelForImageClassification.from_pretrained("Shivamnegi92/cancer-classification-vit")
processor = AutoImageProcessor.from_pretrained("Shivamnegi92/cancer-classification-vit")
# Load and preprocess image
image = Image.open("path/to/your/image.jpg")
inputs = processor(images=image, return_tensors="pt")
# Make prediction
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1)
# Interpret results
class_names = ["Normal", "Malignant"]
confidence = predictions[0][predicted_class].item()
result = class_names[predicted_class.item()]
print(f"Prediction: {result}")
print(f"Confidence: {confidence:.4f}")
This model is for research and educational purposes only. It should NOT be used for actual medical diagnosis.
If you use this model in your research, please cite:
@misc{cancer-classification-vit-2024,
title={Cancer Image Classification using Vision Transformer},
author={Shivam Negi},
year={2024},
howpublished={\url{https://huggingface.co/Shivamnegi92/cancer-classification-vit}}
}
For questions or issues regarding this model, please open an issue in the model repository.
Keywords: cancer detection, medical imaging, vision transformer, image classification, healthcare AI, diagnostic assistance