Update README.md
Browse files
README.md
CHANGED
@@ -32,17 +32,17 @@ You can use the model for fine-tuning of semantic segmentation. See the [model h
|
|
32 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
33 |
|
34 |
```python
|
35 |
-
from transformers import
|
36 |
from PIL import Image
|
37 |
import requests
|
38 |
|
39 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
40 |
image = Image.open(requests.get(url, stream=True).raw)
|
41 |
|
42 |
-
|
43 |
model = SegformerForImageClassification.from_pretrained("nvidia/mit-b0")
|
44 |
|
45 |
-
inputs =
|
46 |
outputs = model(**inputs)
|
47 |
logits = outputs.logits
|
48 |
# model predicts one of the 1000 ImageNet classes
|
|
|
32 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
33 |
|
34 |
```python
|
35 |
+
from transformers import SegformerImageProcessor, SegformerForImageClassification
|
36 |
from PIL import Image
|
37 |
import requests
|
38 |
|
39 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
40 |
image = Image.open(requests.get(url, stream=True).raw)
|
41 |
|
42 |
+
image_processor = SegformerImageProcessor.from_pretrained("nvidia/mit-b0")
|
43 |
model = SegformerForImageClassification.from_pretrained("nvidia/mit-b0")
|
44 |
|
45 |
+
inputs = image_processor(images=image, return_tensors="pt")
|
46 |
outputs = model(**inputs)
|
47 |
logits = outputs.logits
|
48 |
# model predicts one of the 1000 ImageNet classes
|