An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
Paper β’ 2010.11929 β’ Published β’ 23
This project is a binary classification model designed to detect stroke in brain CT slices using the Vision Transformer (ViT) architecture.
Objective: Given a single axial CT slice, classify whether stroke is present:
0 β No Stroke 1 β Stroke.png slices (converted from DICOM if needed)mean β 0.189, std β 0.318
Source:ViT-Base (google/vit-base-patch16-224)π View on Hugging Face
from transformers import ViTImageProcessor, ViTForImageClassification
from PIL import Image
import torch
# Load model and processor from Hugging Face Hub
model = ViTForImageClassification.from_pretrained("Sahende/teknofest_ct_stroke_binary")
processor = ViTImageProcessor.from_pretrained("Sahende/teknofest_ct_stroke_binary")
# Load and process an image
image = Image.open("example.png").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
# Make prediction
with torch.no_grad():
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits, dim=-1).item()
print(f"π§ Predicted class: {predicted_class}")