Views
No views yet
Normal_AZAN - Normal glomerulus with Azan stainingNormal_HE - Normal glomerulus with H&E stainingNormal_PAMS - Normal glomerulus with PAMS stainingNormal_PAS - Normal glomerulus with PAS stainingNormal_PICRO - Normal glomerulus with Picro stainingCrescente_AZAN - Crescentic glomerulus with Azan stainingCrescente_HE - Crescentic glomerulus with H&E stainingCrescente_PAMS - Crescentic glomerulus with PAMS stainingCrescente_PAS - Crescentic glomerulus with PAS stainingCrescente_PICRO - Crescentic glomerulus with Picro staining1from transformers import AutoImageProcessor, AutoModelForImageClassification
2from PIL import Image
3import torch
4
5# Load model and processor
6model_name = "CleitonOERocha/vision-transformer-glomerulus-classifier"
7processor = AutoImageProcessor.from_pretrained(model_name)
8model = AutoModelForImageClassification.from_pretrained(model_name)
9
10# Load and process image
11image = Image.open("your_image.jpg")
12inputs = processor(images=image, return_tensors="pt")
13
14# Make prediction
15with torch.no_grad():
16 outputs = model(**inputs)
17 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
18 predicted_class_id = predictions.argmax().item()
19 predicted_class = model.config.id2label[predicted_class_id]
20 confidence = predictions.max().item()
21
22print(f"Predicted class: {predicted_class}")
23print(f"Confidence: {confidence:.4f}")| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Crescente_AZAN | 0.9500 | 0.9344 | 0.9421 | 61 |
| Crescente_HE | 0.9665 | 0.9914 | 0.9788 | 233 |
| Crescente_PAMS | 0.9737 | 0.9487 | 0.9610 | 78 |
| Crescente_PAS | 0.9607 | 0.9661 | 0.9634 | 177 |
| Crescente_PICRO | 0.7179 | 0.6364 | 0.6747 | 44 |
| Normal_AZAN | 0.8714 | 0.9683 | 0.9173 | 63 |
| Normal_HE | 0.9908 | 0.9908 | 0.9908 | 434 |
| Normal_PAMS | 0.9785 | 0.9681 | 0.9733 | 94 |
| Normal_PAS | 0.9835 | 0.8151 | 0.8914 | 146 |
| Normal_PICRO | 0.6667 | 0.9565 | 0.7857 | 46 |