Update README.md
Browse files
README.md
CHANGED
@@ -49,7 +49,24 @@ Thus please make sure to feed only fundus image into the model to obtain reasona
|
|
49 |
Use the code below to get started with the model.
|
50 |
|
51 |
```python
|
|
|
|
|
|
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
```
|
55 |
|
|
|
49 |
Use the code below to get started with the model.
|
50 |
|
51 |
```python
|
52 |
+
from transformers import AutoImageProcessor, ResNetForImageClassification
|
53 |
+
import torch
|
54 |
+
from datasets import load_dataset
|
55 |
|
56 |
+
dataset = load_dataset("huggingface/cats-image")
|
57 |
+
image = dataset["test"]["image"][0]
|
58 |
+
|
59 |
+
processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
|
60 |
+
model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50")
|
61 |
+
|
62 |
+
inputs = processor(image, return_tensors="pt")
|
63 |
+
|
64 |
+
with torch.no_grad():
|
65 |
+
logits = model(**inputs).logits
|
66 |
+
|
67 |
+
# model predicts one of the 1000 ImageNet classes
|
68 |
+
predicted_label = logits.argmax(-1).item()
|
69 |
+
print(model.config.id2label[predicted_label])
|
70 |
|
71 |
```
|
72 |
|