b3.png

Brain3-Anomaly-SigLIP2

Brain3-Anomaly-SigLIP2 is a vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for multi-class medical image classification. It is trained to distinguish between different types of brain anomalies using the SiglipForImageClassification architecture.

Classification Report:
              precision    recall  f1-score   support

brain_glioma     0.9853    0.9725    0.9789      2000
 brain_menin     0.9361    0.9735    0.9544      2000
 brain_tumor     0.9743    0.9480    0.9610      2000

    accuracy                         0.9647      6000
   macro avg     0.9652    0.9647    0.9647      6000
weighted avg     0.9652    0.9647    0.9647      6000

download (1).png


Label Space: 3 Classes

The model classifies each image into one of the following categories:

0: brain_glioma
1: brain_menin
2: brain_tumor

Install Dependencies

pip install -q transformers torch pillow gradio

Inference Code

import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "prithivMLmods/Brain3-Anomaly-SigLIP2"  # Replace with your model path if different
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# Label mapping
id2label = {
    "0": "brain_glioma",
    "1": "brain_menin",
    "2": "brain_tumor"
}

def classify_brain_anomaly(image):
    image = Image.fromarray(image).convert("RGB")
    inputs = processor(images=image, return_tensors="pt")

    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

    prediction = {
        id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
    }

    return prediction

# Gradio Interface
iface = gr.Interface(
    fn=classify_brain_anomaly,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(num_top_classes=3, label="Brain Anomaly Classification"),
    title="Brain3-Anomaly-SigLIP2",
    description="Upload a brain scan image to classify it as glioma, meningioma, or tumor."
)

if __name__ == "__main__":
    iface.launch()

Intended Use

Brain3-Anomaly-SigLIP2 can be used for:

  • Medical Diagnostics Support โ€“ Assisting radiologists in identifying brain anomalies from MRI or CT images.
  • Academic Research โ€“ Supporting experiments in brain tumor classification tasks.
  • Medical AI Prototyping โ€“ Useful for healthcare AI pipelines involving limited anomaly classes.
  • Dataset Annotation โ€“ Pre-label brain images for manual review or semi-supervised learning.
Downloads last month
4
Safetensors
Model size
92.9M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for prithivMLmods/Brain3-Anomaly-SigLIP2

Finetuned
(98)
this model

Dataset used to train prithivMLmods/Brain3-Anomaly-SigLIP2

Collection including prithivMLmods/Brain3-Anomaly-SigLIP2