prithivMLmods commited on
Commit
f5f19ef
·
verified ·
1 Parent(s): ad18f31

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -0
README.md CHANGED
@@ -2,8 +2,26 @@
2
  license: apache-2.0
3
  datasets:
4
  - prithivMLmods/Brain3-Anomaly-Classification
 
 
 
 
 
 
 
 
 
 
 
 
5
  ---
6
 
 
 
 
 
 
 
7
  ```py
8
  Classification Report:
9
  precision recall f1-score support
@@ -18,3 +36,84 @@ weighted avg 0.9652 0.9647 0.9647 6000
18
  ```
19
 
20
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/-YBXtGneTQ6BrB9o5YiZ-.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - prithivMLmods/Brain3-Anomaly-Classification
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-224
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - brain
13
+ - tumor
14
+ - biology
15
+ - chemistry
16
+ - medical
17
  ---
18
 
19
+ ![b3.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/LvOpYoEOjWPr9bozOAaBE.png)
20
+
21
+ # **Brain3-Anomaly-SigLIP2**
22
+
23
+ > **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.
24
+
25
  ```py
26
  Classification Report:
27
  precision recall f1-score support
 
36
  ```
37
 
38
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/-YBXtGneTQ6BrB9o5YiZ-.png)
39
+
40
+ ---
41
+
42
+ ## **Label Space: 3 Classes**
43
+
44
+ The model classifies each image into one of the following categories:
45
+
46
+ ```
47
+ 0: brain_glioma
48
+ 1: brain_menin
49
+ 2: brain_tumor
50
+ ```
51
+
52
+ ---
53
+
54
+ ## **Install Dependencies**
55
+
56
+ ```bash
57
+ pip install -q transformers torch pillow gradio
58
+ ```
59
+
60
+ ---
61
+
62
+ ## **Inference Code**
63
+
64
+ ```python
65
+ import gradio as gr
66
+ from transformers import AutoImageProcessor, SiglipForImageClassification
67
+ from PIL import Image
68
+ import torch
69
+
70
+ # Load model and processor
71
+ model_name = "prithivMLmods/Brain3-Anomaly-SigLIP2" # Replace with your model path if different
72
+ model = SiglipForImageClassification.from_pretrained(model_name)
73
+ processor = AutoImageProcessor.from_pretrained(model_name)
74
+
75
+ # Label mapping
76
+ id2label = {
77
+ "0": "brain_glioma",
78
+ "1": "brain_menin",
79
+ "2": "brain_tumor"
80
+ }
81
+
82
+ def classify_brain_anomaly(image):
83
+ image = Image.fromarray(image).convert("RGB")
84
+ inputs = processor(images=image, return_tensors="pt")
85
+
86
+ with torch.no_grad():
87
+ outputs = model(**inputs)
88
+ logits = outputs.logits
89
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
90
+
91
+ prediction = {
92
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
93
+ }
94
+
95
+ return prediction
96
+
97
+ # Gradio Interface
98
+ iface = gr.Interface(
99
+ fn=classify_brain_anomaly,
100
+ inputs=gr.Image(type="numpy"),
101
+ outputs=gr.Label(num_top_classes=3, label="Brain Anomaly Classification"),
102
+ title="Brain3-Anomaly-SigLIP2",
103
+ description="Upload a brain scan image to classify it as glioma, meningioma, or tumor."
104
+ )
105
+
106
+ if __name__ == "__main__":
107
+ iface.launch()
108
+ ```
109
+
110
+ ---
111
+
112
+ ## **Intended Use**
113
+
114
+ **Brain3-Anomaly-SigLIP2** can be used for:
115
+
116
+ * **Medical Diagnostics Support** – Assisting radiologists in identifying brain anomalies from MRI or CT images.
117
+ * **Academic Research** – Supporting experiments in brain tumor classification tasks.
118
+ * **Medical AI Prototyping** – Useful for healthcare AI pipelines involving limited anomaly classes.
119
+ * **Dataset Annotation** – Pre-label brain images for manual review or semi-supervised learning.