
## Description  

[Google ViT](https://huggingface.co/google/vit-base-patch16-224-in21k) model is finetuned on lung and colon histopathology image classification dataset. 
The dataset is available on [Kaggle](https://www.kaggle.com/datasets/andrewmvd/lung-and-colon-cancer-histopathological-images). 

## About Dataset

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:

* Lung benign tissue
* Lung adenocarcinoma
* Lung squamous cell carcinoma
* Colon adenocarcinoma
* Colon benign tissue

## Training Results

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

## How to use
```python
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])
```
{"tags": ["medical"], "metrics": ["accuracy"], "pipeline_tag": "image-classification", "basemodel": "google/vit-base-patch16-224-in21k"}
transformers pytorch vit image-classification medical autotrain_compatible endpoints_compatible region:us