NeuronZero commited on
Commit
43db832
1 Parent(s): 2e31111

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -15
README.md CHANGED
@@ -38,24 +38,23 @@ No validation metrics available
38
 
39
  ### How to use
40
 
41
- Here is how to use this model to classify an image of :
42
 
43
  ```python
44
- from transformers import AutoImageProcessor, ResNetForImageClassification
45
- import torch
46
- from datasets import load_dataset
47
 
48
- dataset = load_dataset("huggingface/cats-image")
49
- image = dataset["test"]["image"][0]
50
 
51
- processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
52
- model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50")
53
 
54
- inputs = processor(image, return_tensors="pt")
 
55
 
56
- with torch.no_grad():
57
- logits = model(**inputs).logits
58
-
59
- # model predicts one of the 1000 ImageNet classes
60
- predicted_label = logits.argmax(-1).item()
61
- print(model.config.id2label[predicted_label])
 
38
 
39
  ### How to use
40
 
41
+ Here is how to use this model to identify a neutrophil from a picture of a blood sample:
42
 
43
  ```python
44
+ from transformers import AutoImageProcessor, AutoModelForImageClassification
45
+ from PIL import Image
46
+ import requests
47
 
48
+ processor = AutoImageProcessor.from_pretrained("NeuronZero/MRI-Reader")
49
+ model = AutoModelForImageClassification.from_pretrained("NeuronZero/MRI-Reader")
50
 
51
+ #dataset URL: https://www.kaggle.com/datasets/paultimothymooney/blood-cells
 
52
 
53
+ image_url = https://storage.googleapis.com/kagglesdsdata/datasets/9232/29380/dataset-master/dataset-master/JPEGImages/BloodImage_00014.jpg?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=databundle-worker-v2%40kaggle-161607.iam.gserviceaccount.com%2F20240404%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240404T094650Z&X-Goog-Expires=345600&X-Goog-SignedHeaders=host&X-Goog-Signature=8382f4e4b34038ad9176686e9d1155a757bbc41dcf99ee8cf5b5e049fa2994a9b877de41121c3dcea9b35c67076ddd5b3ff5ec970cbf5ac8f5a3eea1149eb68b8a0e79f91084a8598cefca35be190718b402bd6f581051f436ac771c85d3239834adc933e874fa31a6db696a968676610b6da955abd6145974b535b0509d196f68c8964c3dfb2404a0ad2248d1e80eb60d463e5ea58688820b46e6fc95f6fc3919e327905c2920912b8bda2241f8bcae8c886a66513ec62a8960188387322fbd1162caea76b1ecd04c433be5fbc5cd9f9a46e1a696df3cd0981b7e6243c6e5fd041ec928a080ea2845cdbea85fbfb38ff9024627c8a148c47ae50c4154197cfc
54
+ image = Image.open(requests.get(image_url, stream=True).raw)
55
 
56
+ inputs = processor(images=image, return_tensors="pt")
57
+ outputs = model(**inputs)
58
+ logits = outputs.logits
59
+ predicted_class_idx = logits.argmax(-1).item()
60
+ print("Predicted class:", model.config.id2label[predicted_class_idx])