NeuronZero
commited on
Commit
•
5810f7d
1
Parent(s):
4a2ad50
Update README.md
Browse files
README.md
CHANGED
@@ -26,23 +26,24 @@ The Swin Transformer is a type of Vision Transformer. It builds hierarchical fea
|
|
26 |
|
27 |
### How to use
|
28 |
|
29 |
-
Here is how to use this model to
|
30 |
|
31 |
```python
|
32 |
-
from transformers import AutoImageProcessor,
|
33 |
from PIL import Image
|
34 |
import requests
|
35 |
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
|
|
|
|
41 |
|
42 |
inputs = processor(images=image, return_tensors="pt")
|
43 |
outputs = model(**inputs)
|
44 |
logits = outputs.logits
|
45 |
-
# model predicts one of the 1000 ImageNet classes
|
46 |
predicted_class_idx = logits.argmax(-1).item()
|
47 |
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
48 |
```
|
|
|
26 |
|
27 |
### How to use
|
28 |
|
29 |
+
Here is how to use this model to identify meningioma tumor from a MRI scan:
|
30 |
|
31 |
```python
|
32 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
33 |
from PIL import Image
|
34 |
import requests
|
35 |
|
36 |
+
processor = AutoImageProcessor.from_pretrained("NeuronZero/MRI-Reader")
|
37 |
+
model = AutoModelForImageClassification.from_pretrained("NeuronZero/MRI-Reader")
|
38 |
|
39 |
+
# Dataset url: https://www.kaggle.com/datasets/sartajbhuvaji/brain-tumor-classification-mri
|
40 |
+
|
41 |
+
image_url = "https://storage.googleapis.com/kagglesdsdata/datasets/672377/1183165/Testing/meningioma_tumor/image%28112%29.jpg?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=databundle-worker-v2%40kaggle-161607.iam.gserviceaccount.com%2F20240326%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240326T125018Z&X-Goog-Expires=345600&X-Goog-SignedHeaders=host&X-Goog-Signature=32461d8d00888de5030d0dac653ecf5301c79a9445320a29c515713611fc8ec5bd6de1f1be490041f0dd937d7165f2bd3176ca926f2f33787a6ca7dbae1db2ce0b3a482a27a6258d4fe64c92ef7004c81488bfede784e50f22742e214cc303e8e9a52c6b4bc1db20e8aafba80589e87028e2f3212436c45fd7bc0a6978af3c2a2a5cbc25dcddf1489aecacaeebc75b93b2e111d391cf82c50a38906f88eec30e928285f043527972eed6d0dd2cd53b7e61c1be82bbefd6f8f38ffe438155e0dcf386425693a61c8c5857d6f4dbea7a8351e496160da261778c5f26d5496243f863ca65caf2b630701a998e79ce0bfa32291b19410a0f72d3399cea86b695c7dd"
|
42 |
+
image = Image.open(requests.get(image_url, stream=True).raw)
|
43 |
|
44 |
inputs = processor(images=image, return_tensors="pt")
|
45 |
outputs = model(**inputs)
|
46 |
logits = outputs.logits
|
|
|
47 |
predicted_class_idx = logits.argmax(-1).item()
|
48 |
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
49 |
```
|