Downloads · 30 days
108
4% of all-time downloads
HumaP/vit_base_patch16_224_in21k_lung_and_colon_histopathology_pt
vit_base_patch16_224_in21k_lung_and_colon_histopathology_pt is a image classification model from HumaP. Use it when you need a label for an image. It is set up for transformers.
Google ViT model is finetuned on lung and colon histopathology image classification dataset. The dataset is available on Kaggle.
Downloads · 30 days
108
4% of all-time downloads
All-time downloads
2.7K
Public
Repo size
1.4 GB
Likes
2
Public
Click a slice to open those files.
.pt687 MB · 67%
From the Hugging Face model README
Google ViT model is finetuned on lung and colon histopathology image classification dataset. The dataset is available on Kaggle.
It is a multiclass image classification dataset. This dataset contains 25,000 histopathological images with 5 classes.
There are five classes in the dataset, each with 5,000 images, being:
| Epoch | Training Loss | Validation Loss | Validation Accuracy |
|---|---|---|---|
| 1 | 0.075800 | 0.029827 | 0.994600 |
| 2 | 0.039400 | 0.008961 | 0.998800 |
| 3 | 0.017400 | 0.005077 | 0.999200 |
from transformers import ViTImageProcessor, ViTForImageClassification
from PIL import Image
imageurl = 'test images/lung01.jpg'
image = Image.open(imageurl)
processor = ViTImageProcessor.from_pretrained('HumaP/vit_base_patch16_224_in21k_lung_and_colon_histopathology_pt')
model = ViTForImageClassification.from_pretrained('HumaP/vit_base_patch16_224_in21k_lung_and_colon_histopathology_pt')
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])